From 304bec914bec82686f3afd2530499bb7020cd99a Mon Sep 17 00:00:00 2001 From: GilbertPlazas Date: Mon, 17 Nov 2025 20:15:06 +0000 Subject: [PATCH 1/6] Add new lab API (POST & GET) --- internal/sbi/api_student.go | 38 +++++++++++++++++++++++++++++++++++++ internal/sbi/router.go | 3 +++ internal/sbi/server.go | 17 +++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 internal/sbi/api_student.go diff --git a/internal/sbi/api_student.go b/internal/sbi/api_student.go new file mode 100644 index 0000000..8677ae8 --- /dev/null +++ b/internal/sbi/api_student.go @@ -0,0 +1,38 @@ +package sbi + +import ( + "net/http" + + "github.com/gin-gonic/gin" +) + +func GetStudentData(c *gin.Context) { + c.JSON(http.StatusOK, gin.H{ + "student": "Gilbert", + "semester": 7, + "university": "UDC", + "message": "Datos obtenidos correctamente", + }) +} + +type StudentRequest struct { + Name string `json:"name" binding:"required"` + Semester int `json:"semester"` + Career string `json:"career"` +} + +func RegisterStudent(c *gin.Context) { + var req StudentRequest + + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) + return + } + + c.JSON(http.StatusCreated, gin.H{ + "status": "registrado correctamente", + "name": req.Name, + "semester": req.Semester, + "career": req.Career, + }) +} diff --git a/internal/sbi/router.go b/internal/sbi/router.go index b62139f..c595491 100644 --- a/internal/sbi/router.go +++ b/internal/sbi/router.go @@ -45,6 +45,9 @@ func newRouter(s *Server) *gin.Engine { spyFamilyGroup := router.Group("/spyfamily") applyRoutes(spyFamilyGroup, s.getSpyFamilyRoute()) + studentGroup := router.Group("/student") + applyRoutes(studentGroup, s.getStudentRoute()) + return router } diff --git a/internal/sbi/server.go b/internal/sbi/server.go index 0ac33fe..d052e5c 100644 --- a/internal/sbi/server.go +++ b/internal/sbi/server.go @@ -112,3 +112,20 @@ func (s *Server) shutdownHttpServer() { logger.SBILog.Errorf("HTTP server shutdown failed: %+v", err) } } + +func (s *Server) getStudentRoute() []Route { + return []Route{ + { + Name: "GetStudentData", + Method: "GET", + Pattern: "/data", + APIFunc: GetStudentData, + }, + { + Name: "RegisterStudent", + Method: "POST", + Pattern: "/register", + APIFunc: RegisterStudent, + }, + } +} From a839296fa060218407c5f225b321c97e1bce1f8e Mon Sep 17 00:00:00 2001 From: GilbertPlazas Date: Mon, 17 Nov 2025 21:02:56 +0000 Subject: [PATCH 2/6] Add CI pipeline with Github Actions --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dd6e660 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI Pipeline + +on: + push: + branches: [ main, feature/new-api ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.20 + + - name: Download dependencies + run: go mod tidy + + - name: Build project + run: CGO_ENABLED=0 go build -o bin/nf ./cmd/main.go + + - name: Upload binary artifact + uses: actions/upload-artifact@v3 + with: + name: nf-binary + path: bin/nf From f710adb43e4ede89ef4cdd505fea1247a8d0bb28 Mon Sep 17 00:00:00 2001 From: GilbertPlazas Date: Mon, 17 Nov 2025 21:22:41 +0000 Subject: [PATCH 3/6] ci: update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd6e660..48862a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: run: CGO_ENABLED=0 go build -o bin/nf ./cmd/main.go - name: Upload binary artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: nf-binary path: bin/nf From 6d2351a3be44500d396324c3f8fb3b5d85af9daf Mon Sep 17 00:00:00 2001 From: GilbertPlazas Date: Mon, 17 Nov 2025 21:29:06 +0000 Subject: [PATCH 4/6] ci: update2 --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 48862a7..609bb40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,12 +15,14 @@ jobs: uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: 1.20 + go-version: 1.21 - name: Download dependencies - run: go mod tidy + run: | + go mod tidy + go mod download - name: Build project run: CGO_ENABLED=0 go build -o bin/nf ./cmd/main.go From 4e9c15887cb25ab44cdf547d6e7a12d1f4ce0e90 Mon Sep 17 00:00:00 2001 From: GilbertPlazas Date: Mon, 17 Nov 2025 21:42:39 +0000 Subject: [PATCH 5/6] CI: Complete --- .github/workflows/ci.yml | 121 ++++++++++++++++++++++++++++++++------- 1 file changed, 99 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 609bb40..533420b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,34 +1,111 @@ -name: CI Pipeline +name: Functionality Test on: push: - branches: [ main, feature/new-api ] + branches: + - main pull_request: - branches: [ main ] jobs: build: - runs-on: ubuntu-latest - + runs-on: [self-hosted, linux, x64] steps: - - name: Checkout repository - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - name: Setup Go - uses: actions/setup-go@v5 - with: - go-version: 1.21 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.24.5 - - name: Download dependencies - run: | - go mod tidy - go mod download + - name: Start MongoDB + uses: supercharge/mongodb-github-action@1.7.0 + with: + mongodb-version: 4.4 - - name: Build project - run: CGO_ENABLED=0 go build -o bin/nf ./cmd/main.go + - name: Install dependencies + run: | + sudo apt-get -y update + sudo apt-get -y install netcat-openbsd psmisc iproute2 git gcc g++ cmake autoconf libtool pkg-config libmnl-dev libyaml-dev - - name: Upload binary artifact - uses: actions/upload-artifact@v4 - with: - name: nf-binary - path: bin/nf + - name: Build + run: | + git submodule init + git submodule sync + git submodule update + make + - name: Basic Test + run: | + ls bin/ -al + ./test_ci.sh TestNasReroute + sleep 1 + ./test_ci.sh TestRegistration + sleep 1 + ./test_ci.sh TestGUTIRegistration + sleep 1 + ./test_ci.sh TestServiceRequest + sleep 1 + ./test_ci.sh TestXnHandover + sleep 1 + ./test_ci.sh TestDeregistration + sleep 1 + ./test_ci.sh TestPDUSessionReleaseRequest + sleep 1 + ./test_ci.sh TestPaging + sleep 1 + ./test_ci.sh TestN2Handover + sleep 1 + ./test_ci.sh TestReSynchronization + sleep 1 + ./test_ci.sh TestDuplicateRegistration + sleep 1 + ./test_ci.sh TestEAPAKAPrimeAuthentication + sleep 1 + ./test_ci.sh TestMultiAmfRegistration + sleep 1 + ./test_ci.sh TestDC + sleep 1 + ./test_ci.sh TestDynamicDC + sleep 1 + ./test_ci.sh TestXnDCHandover + - name: ULCL Test + run: ./test_ci_ulcl.sh TestRequestTwoPDUSessions + - name: Basic Test (OAuth) + run: | + ls bin/ -al + ./test_ci.sh TestNasReroute oauth + sleep 1 + ./test_ci.sh TestRegistration oauth + sleep 1 + ./test_ci.sh TestGUTIRegistration oauth + sleep 1 + ./test_ci.sh TestServiceRequest oauth + sleep 1 + ./test_ci.sh TestXnHandover oauth + sleep 1 + ./test_ci.sh TestDeregistration oauth + sleep 1 + ./test_ci.sh TestPDUSessionReleaseRequest oauth + sleep 1 + ./test_ci.sh TestPaging oauth + sleep 1 + ./test_ci.sh TestN2Handover oauth + sleep 1 + ./test_ci.sh TestReSynchronization oauth + sleep 1 + ./test_ci.sh TestDuplicateRegistration oauth + sleep 1 + ./test_ci.sh TestEAPAKAPrimeAuthentication oauth + sleep 1 + ./test_ci.sh TestMultiAmfRegistration oauth + sleep 1 + ./test_ci.sh TestDC oauth + sleep 1 + ./test_ci.sh TestDynamicDC oauth + sleep 1 + ./test_ci.sh TestXnDCHandover oauth + - name: ULCL Test (OAuth) + run: ./test_ci_ulcl.sh TestRequestTwoPDUSessions oauth + # - name: Non3GPP Test + # run: ./test_ci.sh TestNon3GPP + - name: TNGF Registration Test + run: ./test_ci.sh TestTngf From 9f28ed51028ca15c5c45e2b66b87a0080e1068d9 Mon Sep 17 00:00:00 2001 From: GilbertPlazas Date: Mon, 17 Nov 2025 21:51:29 +0000 Subject: [PATCH 6/6] CI: Complete --- .github/workflows/ci.yml | 121 +++++++-------------------------------- 1 file changed, 22 insertions(+), 99 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 533420b..609bb40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,111 +1,34 @@ -name: Functionality Test +name: CI Pipeline on: push: - branches: - - main + branches: [ main, feature/new-api ] pull_request: + branches: [ main ] jobs: build: - runs-on: [self-hosted, linux, x64] + runs-on: ubuntu-latest + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v3 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.24.5 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 1.21 - - name: Start MongoDB - uses: supercharge/mongodb-github-action@1.7.0 - with: - mongodb-version: 4.4 + - name: Download dependencies + run: | + go mod tidy + go mod download - - name: Install dependencies - run: | - sudo apt-get -y update - sudo apt-get -y install netcat-openbsd psmisc iproute2 git gcc g++ cmake autoconf libtool pkg-config libmnl-dev libyaml-dev + - name: Build project + run: CGO_ENABLED=0 go build -o bin/nf ./cmd/main.go - - name: Build - run: | - git submodule init - git submodule sync - git submodule update - make - - name: Basic Test - run: | - ls bin/ -al - ./test_ci.sh TestNasReroute - sleep 1 - ./test_ci.sh TestRegistration - sleep 1 - ./test_ci.sh TestGUTIRegistration - sleep 1 - ./test_ci.sh TestServiceRequest - sleep 1 - ./test_ci.sh TestXnHandover - sleep 1 - ./test_ci.sh TestDeregistration - sleep 1 - ./test_ci.sh TestPDUSessionReleaseRequest - sleep 1 - ./test_ci.sh TestPaging - sleep 1 - ./test_ci.sh TestN2Handover - sleep 1 - ./test_ci.sh TestReSynchronization - sleep 1 - ./test_ci.sh TestDuplicateRegistration - sleep 1 - ./test_ci.sh TestEAPAKAPrimeAuthentication - sleep 1 - ./test_ci.sh TestMultiAmfRegistration - sleep 1 - ./test_ci.sh TestDC - sleep 1 - ./test_ci.sh TestDynamicDC - sleep 1 - ./test_ci.sh TestXnDCHandover - - name: ULCL Test - run: ./test_ci_ulcl.sh TestRequestTwoPDUSessions - - name: Basic Test (OAuth) - run: | - ls bin/ -al - ./test_ci.sh TestNasReroute oauth - sleep 1 - ./test_ci.sh TestRegistration oauth - sleep 1 - ./test_ci.sh TestGUTIRegistration oauth - sleep 1 - ./test_ci.sh TestServiceRequest oauth - sleep 1 - ./test_ci.sh TestXnHandover oauth - sleep 1 - ./test_ci.sh TestDeregistration oauth - sleep 1 - ./test_ci.sh TestPDUSessionReleaseRequest oauth - sleep 1 - ./test_ci.sh TestPaging oauth - sleep 1 - ./test_ci.sh TestN2Handover oauth - sleep 1 - ./test_ci.sh TestReSynchronization oauth - sleep 1 - ./test_ci.sh TestDuplicateRegistration oauth - sleep 1 - ./test_ci.sh TestEAPAKAPrimeAuthentication oauth - sleep 1 - ./test_ci.sh TestMultiAmfRegistration oauth - sleep 1 - ./test_ci.sh TestDC oauth - sleep 1 - ./test_ci.sh TestDynamicDC oauth - sleep 1 - ./test_ci.sh TestXnDCHandover oauth - - name: ULCL Test (OAuth) - run: ./test_ci_ulcl.sh TestRequestTwoPDUSessions oauth - # - name: Non3GPP Test - # run: ./test_ci.sh TestNon3GPP - - name: TNGF Registration Test - run: ./test_ci.sh TestTngf + - name: Upload binary artifact + uses: actions/upload-artifact@v4 + with: + name: nf-binary + path: bin/nf