Skip to content

Commit

Permalink
chore: Adds lint checks (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
gruyaume committed Jan 6, 2024
1 parent 18c2823 commit 3c3e0af
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 4 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,24 +226,22 @@ linters:
- errcheck
- staticcheck
- unused
# - gosimple
# - structcheck
- gosimple
- ineffassign
- typecheck
# Additional
# - lll
- godox
#- gomnd
#- goconst
- goconst
# - gocognit
# - maligned
# - nestif
# - gomodguard
- gomodguard
- nakedret
# - gci
- misspell
# - gofumpt
# - whitespace
- whitespace
- unconvert
- predeclared
- noctx
Expand Down
23 changes: 14 additions & 9 deletions producer/ue_authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ import (
"github.com/omec-project/openapi/models"
)

const UPSTREAM_SERVER_ERROR = "UPSTREAM_SERVER_ERROR"
const USER_NOT_FOUND_ERROR = "USER_NOT_FOUND"
const SERVING_NETWORK_NOT_AUTHORIZED_ERROR = "SERVING_NETWORK_NOT_AUTHORIZED"
const AV_GENERATION_PROBLEM_ERROR = "AV_GENERATION_PROBLEM"

// Generates a random int between 0 and 255
func GenerateRandomNumber() (uint8, error) {
max := big.NewInt(256)
Expand Down Expand Up @@ -110,7 +115,7 @@ func UeAuthPostRequestProcedure(updateAuthenticationInfo models.AuthenticationIn
servingNetworkAuthorized := ausf_context.IsServingNetworkAuthorized(snName)
if !servingNetworkAuthorized {
var problemDetails models.ProblemDetails
problemDetails.Cause = "SERVING_NETWORK_NOT_AUTHORIZED"
problemDetails.Cause = SERVING_NETWORK_NOT_AUTHORIZED_ERROR
problemDetails.Status = http.StatusForbidden
logger.UeAuthPostLog.Infoln("403 forbidden: serving network NOT AUTHORIZED")
return nil, "", &problemDetails
Expand Down Expand Up @@ -140,9 +145,9 @@ func UeAuthPostRequestProcedure(updateAuthenticationInfo models.AuthenticationIn
logger.UeAuthPostLog.Infoln(err.Error())
var problemDetails models.ProblemDetails
if authInfoResult.AuthenticationVector == nil {
problemDetails.Cause = "AV_GENERATION_PROBLEM"
problemDetails.Cause = AV_GENERATION_PROBLEM_ERROR
} else {
problemDetails.Cause = "UPSTREAM_SERVER_ERROR"
problemDetails.Cause = UPSTREAM_SERVER_ERROR
}
problemDetails.Status = http.StatusInternalServerError
return nil, "", &problemDetails
Expand Down Expand Up @@ -310,7 +315,7 @@ func Auth5gAkaComfirmRequestProcedure(updateConfirmationData models.Confirmation
logger.Auth5gAkaComfirmLog.Infof("supiSuciPair does not exist, confirmation failed (queried by %s)\n",
ConfirmationDataResponseID)
var problemDetails models.ProblemDetails
problemDetails.Cause = "USER_NOT_FOUND"
problemDetails.Cause = USER_NOT_FOUND_ERROR
problemDetails.Status = http.StatusBadRequest
return nil, &problemDetails
}
Expand All @@ -319,7 +324,7 @@ func Auth5gAkaComfirmRequestProcedure(updateConfirmationData models.Confirmation
if !ausf_context.CheckIfAusfUeContextExists(currentSupi) {
logger.Auth5gAkaComfirmLog.Infof("SUPI does not exist, confirmation failed (queried by %s)\n", currentSupi)
var problemDetails models.ProblemDetails
problemDetails.Cause = "USER_NOT_FOUND"
problemDetails.Cause = USER_NOT_FOUND_ERROR
problemDetails.Status = http.StatusBadRequest
return nil, &problemDetails
}
Expand Down Expand Up @@ -347,7 +352,7 @@ func Auth5gAkaComfirmRequestProcedure(updateConfirmationData models.Confirmation
logger.Auth5gAkaComfirmLog.Infoln(sendErr.Error())
var problemDetails models.ProblemDetails
problemDetails.Status = http.StatusInternalServerError
problemDetails.Cause = "UPSTREAM_SERVER_ERROR"
problemDetails.Cause = UPSTREAM_SERVER_ERROR

return nil, &problemDetails
}
Expand All @@ -364,15 +369,15 @@ func EapAuthComfirmRequestProcedure(updateEapSession models.EapSession, eapSessi
if !ausf_context.CheckIfSuciSupiPairExists(eapSessionID) {
logger.Auth5gAkaComfirmLog.Infoln("supiSuciPair does not exist, confirmation failed")
var problemDetails models.ProblemDetails
problemDetails.Cause = "USER_NOT_FOUND"
problemDetails.Cause = USER_NOT_FOUND_ERROR
return nil, &problemDetails
}

currentSupi := ausf_context.GetSupiFromSuciSupiMap(eapSessionID)
if !ausf_context.CheckIfAusfUeContextExists(currentSupi) {
logger.Auth5gAkaComfirmLog.Infoln("SUPI does not exist, confirmation failed")
var problemDetails models.ProblemDetails
problemDetails.Cause = "USER_NOT_FOUND"
problemDetails.Cause = USER_NOT_FOUND_ERROR
return nil, &problemDetails
}

Expand Down Expand Up @@ -422,7 +427,7 @@ func EapAuthComfirmRequestProcedure(updateEapSession models.EapSession, eapSessi
udmUrl); sendErr != nil {
logger.EapAuthComfirmLog.Infoln(sendErr.Error())
var problemDetails models.ProblemDetails
problemDetails.Cause = "UPSTREAM_SERVER_ERROR"
problemDetails.Cause = UPSTREAM_SERVER_ERROR
return nil, &problemDetails
}
ausfCurrentContext.AuthStatus = models.AuthResult_SUCCESS
Expand Down
1 change: 0 additions & 1 deletion producer/ue_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ func TestGenerateRandomNumber(t *testing.T) {
}

fmt.Printf("Random number: %d\n", value)

}
6 changes: 2 additions & 4 deletions service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func (ausf *AUSF) setLogLevel() {
}
pathUtilLogger.SetReportCaller(factory.AusfConfig.Logger.PathUtil.ReportCaller)
}

}

func (ausf *AUSF) FilterCli(c *cli.Context) (args []string) {
Expand Down Expand Up @@ -191,7 +190,7 @@ func (ausf *AUSF) updateConfig(commChannel chan *protos.NetworkSliceResponse) bo
break
}
}
if found == false {
if !found {
context.PlmnList = append(context.PlmnList, temp)
logger.GrpcLog.Infoln("Plmn added in the context", context.PlmnList)
}
Expand All @@ -200,7 +199,7 @@ func (ausf *AUSF) updateConfig(commChannel chan *protos.NetworkSliceResponse) bo
}
}
}
if minConfig == false {
if !minConfig {
// first slice Created
if len(context.PlmnList) > 0 {
minConfig = true
Expand Down Expand Up @@ -423,6 +422,5 @@ func (ausf *AUSF) registerNF() {
ausf.StartKeepAliveTimer(prof)
logger.CfgLog.Infof("Sent Register NF Instance with updated profile")
}

}
}

0 comments on commit 3c3e0af

Please sign in to comment.