diff --git a/.golangci.yml b/.golangci.yml index 27a210d..1393938 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -169,13 +169,8 @@ linters-settings: - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf - # enable or disable analyzers by name - enable: - - atomicalign - enable-all: false - disable: - - shadow - disable-all: false + # enable all analyzers + enable-all: true depguard: list-type: blacklist include-go-root: false diff --git a/context/context.go b/context/context.go index 1d6915a..5858adf 100644 --- a/context/context.go +++ b/context/context.go @@ -49,16 +49,15 @@ func init() { } type NSSFContext struct { - NfId string - Name string - UriScheme models.UriScheme - RegisterIPv4 string - // HttpIpv6Address string + NfId string + Name string + UriScheme models.UriScheme + RegisterIPv4 string BindingIPv4 string - SBIPort int NfService map[models.ServiceName]models.NfService NrfUri string SupportedPlmnList []models.PlmnId + SBIPort int } // Initialize NSSF context with configuration factory diff --git a/factory/config.go b/factory/config.go index edc997d..b9432d0 100644 --- a/factory/config.go +++ b/factory/config.go @@ -26,8 +26,8 @@ const ( type Config struct { Info *Info `yaml:"info"` Configuration *Configuration `yaml:"configuration"` - Subscriptions []Subscription `yaml:"subscriptions,omitempty"` Logger *logger_util.Logger `yaml:"logger"` + Subscriptions []Subscription `yaml:"subscriptions,omitempty"` } type Info struct { @@ -100,8 +100,8 @@ type MappingFromPlmnConfig struct { } type Subscription struct { - SubscriptionId string `yaml:"subscriptionId"` SubscriptionData *models.NssfEventSubscriptionCreateData `yaml:"subscriptionData"` + SubscriptionId string `yaml:"subscriptionId"` } var ConfigPodTrigger chan bool diff --git a/producer/nssaiavailability_store.go b/producer/nssaiavailability_store.go index 6c250ad..0431fb6 100644 --- a/producer/nssaiavailability_store.go +++ b/producer/nssaiavailability_store.go @@ -39,7 +39,7 @@ func NSSAIAvailabilityDeleteProcedure(nfId string) *models.ProblemDetails { } } - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: fmt.Sprintf("AMF ID '%s' does not exist", nfId), @@ -87,7 +87,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc } factory.ConfigLock.RUnlock() if !hitAmf { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: fmt.Sprintf("AMF ID '%s' does not exist", nfId), @@ -114,7 +114,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc patch, err := jsonpatch.DecodePatch(patchJSON) if err != nil { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.MALFORMED_REQUEST, Status: http.StatusBadRequest, Detail: err.Error(), @@ -124,7 +124,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc modified, err := patch.Apply(original) if err != nil { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.INVALID_REQUEST, Status: http.StatusConflict, Detail: err.Error(), @@ -136,7 +136,7 @@ func NSSAIAvailabilityPatchProcedure(nssaiAvailabilityUpdateInfo plugin.PatchDoc err = json.Unmarshal(modified, &factory.NssfConfig.Configuration.AmfList[amfIdx].SupportedNssaiAvailabilityData) factory.ConfigLock.Unlock() if err != nil { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.INVALID_REQUEST, Status: http.StatusBadRequest, Detail: err.Error(), diff --git a/producer/nssaiavailability_subscription.go b/producer/nssaiavailability_subscription.go index d7443ed..d716839 100644 --- a/producer/nssaiavailability_subscription.go +++ b/producer/nssaiavailability_subscription.go @@ -60,7 +60,7 @@ func NSSAIAvailabilityPostProcedure(createData models.NssfEventSubscriptionCreat if err != nil { logger.Nssaiavailability.Warnf(err.Error()) - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: err.Error(), @@ -99,7 +99,7 @@ func NSSAIAvailabilityUnsubscribeProcedure(subscriptionId string) *models.Proble } // No specific subscription ID exists - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: fmt.Sprintf("Subscription ID '%s' is not available", subscriptionId), diff --git a/producer/subscription_id_document.go b/producer/subscription_id_document.go index 3b0e070..0dc6885 100644 --- a/producer/subscription_id_document.go +++ b/producer/subscription_id_document.go @@ -20,6 +20,7 @@ import ( "github.com/omec-project/http_wrapper" "github.com/omec-project/nssf/logger" "github.com/omec-project/openapi/models" + "reflect" ) // HandleNSSAIAvailabilityUnsubscribe - Deletes an already existing NSSAI availability notification subscription @@ -32,12 +33,12 @@ func HandleNSSAIAvailabilityUnsubscribe(request *http_wrapper.Request) *http_wra if problemDetails == nil { return http_wrapper.NewResponse(http.StatusNoContent, nil, nil) - } else if problemDetails != nil { - return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) + } else if reflect.DeepEqual(*problemDetails, models.ProblemDetails{}) { + problemDetails = &models.ProblemDetails{ + Status: http.StatusForbidden, + Cause: "UNSPECIFIED", + } + return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) } - problemDetails = &models.ProblemDetails{ - Status: http.StatusForbidden, - Cause: "UNSPECIFIED", - } - return http_wrapper.NewResponse(http.StatusForbidden, nil, problemDetails) + return http_wrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) } diff --git a/test/param.go b/test/param.go index b6eee8d..7c44c3e 100644 --- a/test/param.go +++ b/test/param.go @@ -26,11 +26,9 @@ type TestingUtil struct { } type TestingNsselection struct { - ConfigFile string - GenerateNonRoamingQueryParameter func() NsselectionQueryParameter - - GenerateRoamingQueryParameter func() NsselectionQueryParameter + GenerateRoamingQueryParameter func() NsselectionQueryParameter + ConfigFile string } type TestingNssaiavailability struct {