Open Mehul-Kumar-27 opened 8 months ago
Running tool: /usr/local/go/bin/go test -timeout 30s -run ^TestApiService$ github.com/riotpot/test/api [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) [GIN-debug] GET /api/proxies/ --> github.com/riotpot/pkg/api.getProxies (3 handlers) [GIN-debug] POST /api/proxies/ --> github.com/riotpot/pkg/api.createProxy (3 handlers) [GIN-debug] GET /api/proxies/:id/ --> github.com/riotpot/pkg/api.getProxy (3 handlers) [GIN-debug] PATCH /api/proxies/:id/ --> github.com/riotpot/pkg/api.patchProxy (3 handlers) [GIN-debug] DELETE /api/proxies/:id/ --> github.com/riotpot/pkg/api.delProxy (3 handlers) [GIN-debug] POST /api/proxies/:id/port --> github.com/riotpot/pkg/api.changeProxyPort (3 handlers) [GIN-debug] POST /api/proxies/:id/status --> github.com/riotpot/pkg/api.changeProxyStatus (3 handlers) [GIN-debug] GET /api/proxies/:id/:id/ --> github.com/riotpot/pkg/api.getService (3 handlers) [GIN-debug] PATCH /api/proxies/:id/:id/ --> github.com/riotpot/pkg/api.patchService (3 handlers) [GIN-debug] DELETE /api/proxies/:id/:id/ --> github.com/riotpot/pkg/api.delService (3 handlers) [GIN-debug] GET /api/services/ --> github.com/riotpot/pkg/api.getServices (3 handlers) [GIN-debug] POST /api/services/ --> github.com/riotpot/pkg/api.createService (3 handlers) [GIN-debug] POST /api/services/new/ --> github.com/riotpot/pkg/api.newServiceAndProxy (3 handlers) [GIN-debug] GET /api/services/:id/ --> github.com/riotpot/pkg/api.getService (3 handlers) [GIN-debug] PATCH /api/services/:id/ --> github.com/riotpot/pkg/api.patchService (3 handlers) [GIN-debug] DELETE /api/services/:id/ --> github.com/riotpot/pkg/api.delService (3 handlers) [GIN] 2024/03/01 - 18:45:57 | 400 | 111.422µs | | POST "/api/services/" [GIN] 2024/03/01 - 18:45:57 | 200 | 33.123µs | | GET "/api/services/" --- FAIL: TestApiService (0.00s) /home/mehul/dev/gsoc/riotpot/test/api/api_test.go:82: Error Trace: /home/mehul/dev/gsoc/riotpot/test/api/api_test.go:82 Error: Not equal: expected: &api.CreateService{Name:"Test Service", Port:8080, Host:"localhost", Network:"tcp", Interaction:""} actual : &api.CreateService{Name:"", Port:0, Host:"", Network:"", Interaction:""} Diff: --- Expected +++ Actual @@ -1,6 +1,6 @@ (*api.CreateService)({ - Name: (string) (len=12) "Test Service", - Port: (int) 8080, - Host: (string) (len=9) "localhost", - Network: (string) (len=3) "tcp", + Name: (string) "", + Port: (int) 0, + Host: (string) "", + Network: (string) "", Interaction: (string) "" Test: TestApiService /home/mehul/dev/gsoc/riotpot/test/api/api_test.go:91: Error Trace: /home/mehul/dev/gsoc/riotpot/test/api/api_test.go:91 Error: Not equal: expected: 1 actual : 0 Test: TestApiService FAIL FAIL github.com/riotpot/test/api 0.013s FAIL
Also I found this conflicting that in the api_test.go while we initialize the router we register the api.ServicesRouter to the router -: https://github.com/honeynet/riotpot/blob/6d13c90eba5c67f53a5fcb877edf29ddbd494a9f/test/api/api_test.go#L24,
api_test.go
But in the parse.go we register the api.ServiceRouter -: https://github.com/honeynet/riotpot/blob/6d13c90eba5c67f53a5fcb877edf29ddbd494a9f/cmd/riotpot/parse.go#L75
parse.go
So probably in the parse.go we should add the api.Services.Router, because in the current implementation the endpoints provided by the servicesRoutes are not available because they are not registered either as the parent or a child.
api.Services.Router
servicesRoutes
Also I found this conflicting that in the
api_test.go
while we initialize the router we register the api.ServicesRouter to the router -: https://github.com/honeynet/riotpot/blob/6d13c90eba5c67f53a5fcb877edf29ddbd494a9f/test/api/api_test.go#L24,But in the
parse.go
we register the api.ServiceRouter -: https://github.com/honeynet/riotpot/blob/6d13c90eba5c67f53a5fcb877edf29ddbd494a9f/cmd/riotpot/parse.go#L75So probably in the
parse.go
we should add theapi.Services.Router
, because in the current implementation the endpoints provided by theservicesRoutes
are not available because they are not registered either as the parent or a child.