X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fsecurityservice%2Fsecurity_test.go;h=7043cca1fc0b406421746497168d3c6b21546818;hb=b4cee94bd251b0bb92fc435fbe74ea1079d43356;hp=33e19c1643c04fa539053126a51f355669113d6f;hpb=2ba4580c67fbe7994141e4cd2701f7bd22b69ebf;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/securityservice/security_test.go b/capifcore/internal/securityservice/security_test.go index 33e19c1..7043cca 100644 --- a/capifcore/internal/securityservice/security_test.go +++ b/capifcore/internal/securityservice/security_test.go @@ -60,10 +60,14 @@ func TestPostSecurityIdTokenInvokerRegistered(t *testing.T) { requestHandler := getEcho(&serviceRegisterMock, &publishRegisterMock, &invokerRegisterMock) data := url.Values{} - data.Set("client_id", "id") - data.Add("client_secret", "secret") + clientId := "id" + clientSecret := "secret" + aefId := "aefId" + path := "path" + data.Set("client_id", clientId) + data.Add("client_secret", clientSecret) data.Add("grant_type", "client_credentials") - data.Add("scope", "scope#aefId:path") + data.Add("scope", "scope#"+aefId+":"+path) encodedData := data.Encode() result := testutil.NewRequest().Post("/securities/invokerId/token").WithContentType("application/x-www-form-urlencoded").WithBody([]byte(encodedData)).Go(t, requestHandler) @@ -73,13 +77,13 @@ func TestPostSecurityIdTokenInvokerRegistered(t *testing.T) { err := result.UnmarshalBodyToObject(&resultResponse) assert.NoError(t, err, "error unmarshaling response") assert.NotEmpty(t, resultResponse.AccessToken) - assert.Equal(t, "scope#aefId:path", *resultResponse.Scope) + assert.Equal(t, "scope#"+aefId+":"+path, *resultResponse.Scope) assert.Equal(t, securityapi.AccessTokenRspTokenTypeBearer, resultResponse.TokenType) assert.Equal(t, common29122.DurationSec(0), resultResponse.ExpiresIn) - invokerRegisterMock.AssertCalled(t, "IsInvokerRegistered", "id") - invokerRegisterMock.AssertCalled(t, "VerifyInvokerSecret", "id", "secret") - serviceRegisterMock.AssertCalled(t, "IsFunctionRegistered", "aefId") - publishRegisterMock.AssertCalled(t, "IsAPIPublished", "aefId", "path") + invokerRegisterMock.AssertCalled(t, "IsInvokerRegistered", clientId) + invokerRegisterMock.AssertCalled(t, "VerifyInvokerSecret", clientId, clientSecret) + serviceRegisterMock.AssertCalled(t, "IsFunctionRegistered", aefId) + publishRegisterMock.AssertCalled(t, "IsAPIPublished", aefId, path) } func TestPostSecurityIdTokenInvokerNotRegistered(t *testing.T) {