Skip to content

Commit

Permalink
fix: devices use unique connections now
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdmike committed Jul 15, 2024
1 parent 1136f33 commit 3f3e29d
Show file tree
Hide file tree
Showing 34 changed files with 4,496 additions and 3,947 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ mock: ### run mockgen
mockgen -source ./internal/usecase/ciraconfigs/interfaces.go -package v1 -mock_names Repository=MockCIRAConfigsRepository,Feature=MockCIRAConfigsFeature > ./internal/controller/http/v1/ciraconfigs_mocks_test.go
mockgen -source ./internal/usecase/devices/interfaces.go -package devices_test > ./internal/usecase/devices/mocks_test.go
mockgen -source ./internal/usecase/devices/interfaces.go -package v1 -mock_names Repository=MockDeviceManagementRepository,Feature=MockDeviceManagementFeature > ./internal/controller/http/v1/devicemanagement_mocks_test.go
mockgen -source ./internal/usecase/amtexplorer/interfaces.go -package v1 -mock_names Repository=MockAMTExplorerRepository,Feature=MockAMTExplorerFeature,WSMAN=MockAMTExplorerWSMAN > ./internal/controller/http/v1/amtexplorer_mocks_test.go
mockgen -source ./internal/usecase/amtexplorer/interfaces.go -package amtexplorer_test > ./internal/usecase/amtexplorer/mocks_test.go
mockgen -source ./internal/usecase/devices/wsman/interfaces.go -package v1 > ./internal/controller/http/v1/wsman_mocks_test.go
mockgen -source ./internal/usecase/devices/wsman/interfaces.go -package devices_test > ./internal/usecase/devices/wsman_mocks_test.go
mockgen -source ./internal/usecase/domains/interfaces.go -package domains_test > ./internal/usecase/domains/mocks_test.go
mockgen -source ./internal/usecase/domains/interfaces.go -package v1 -mock_names Repository=MockDomainsRepository,Feature=MockDomainsFeature > ./internal/controller/http/v1/domains_mocks_test.go
mockgen -source ./internal/usecase/ieee8021xconfigs/interfaces.go -package ieee8021xconfigs_test > ./internal/usecase/ieee8021xconfigs/mocks_test.go
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/http/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewRouter(handler *gin.Engine, l logger.Interface, t usecase.Usecases, cfg
h2 := handler.Group("/api/v1")
{
v1.NewDeviceRoutes(h2, t.Devices, l)
v1.NewAmtRoutes(h2, t.Devices, l)
v1.NewAmtRoutes(h2, t.Devices, t.AMTExplorer, l)
}

h := handler.Group("/api/v1/admin")
Expand Down
1,050 changes: 1,050 additions & 0 deletions internal/controller/http/v1/amtexplorer_mocks_test.go

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions internal/controller/http/v1/devicemanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import (
"github.com/gin-gonic/gin"

"github.com/open-amt-cloud-toolkit/console/internal/entity/dto"
"github.com/open-amt-cloud-toolkit/console/internal/usecase/amtexplorer"
"github.com/open-amt-cloud-toolkit/console/internal/usecase/devices"
"github.com/open-amt-cloud-toolkit/console/pkg/logger"
)

type deviceManagementRoutes struct {
d devices.Feature
a amtexplorer.Feature
l logger.Interface
}

func NewAmtRoutes(handler *gin.RouterGroup, d devices.Feature, l logger.Interface) {
r := &deviceManagementRoutes{d, l}
func NewAmtRoutes(handler *gin.RouterGroup, d devices.Feature, amt amtexplorer.Feature, l logger.Interface) {
r := &deviceManagementRoutes{d, amt, l}

h := handler.Group("/amt")
{
Expand Down Expand Up @@ -381,7 +383,7 @@ func (r *deviceManagementRoutes) getNetworkSettings(c *gin.Context) {
// @Failure 500 {object} response
// @Router /api/v1/devices [get]
func (r *deviceManagementRoutes) getCallList(c *gin.Context) {
items := r.d.GetExplorerSupportedCalls()
items := r.a.GetExplorerSupportedCalls()

c.JSON(http.StatusOK, items)
}
Expand All @@ -399,7 +401,7 @@ func (r *deviceManagementRoutes) executeCall(c *gin.Context) {
guid := c.Param("guid")
call := c.Param("call")

result, err := r.d.ExecuteCall(c.Request.Context(), guid, call, "")
result, err := r.a.ExecuteCall(c.Request.Context(), guid, call, "")
if err != nil {
r.l.Error(err, "http - explorer - v1 - executeCall")
ErrorResponse(c, err)
Expand Down
1,344 changes: 20 additions & 1,324 deletions internal/controller/http/v1/devicemanagement_mocks_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions internal/controller/http/v1/devicemanagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ func deviceManagementTest(t *testing.T) (*MockDeviceManagementFeature, *gin.Engi

log := logger.New("error")
deviceManagement := NewMockDeviceManagementFeature(mockCtl)

amtExplorerMock := NewMockAMTExplorerFeature(mockCtl)
engine := gin.New()
handler := engine.Group("/api/v1")

NewAmtRoutes(handler, deviceManagement, log)
NewAmtRoutes(handler, deviceManagement, amtExplorerMock, log)

return deviceManagement, engine
}
Expand Down
Loading

0 comments on commit 3f3e29d

Please sign in to comment.