X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fprovidermanagement%2Fprovidermanagement_test.go;h=de647faed1ee2684a21757de43e33cd6122db0c2;hb=30931ba398fc7a3b9269af7120dce7bad027c79e;hp=a3bb7aa6304ff6ea7a22fff36dc7e1e91eee7cf0;hpb=3ff31a181cad84bc2f5554f8440390bedb42711c;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/providermanagement/providermanagement_test.go b/capifcore/internal/providermanagement/providermanagement_test.go index a3bb7aa..de647fa 100644 --- a/capifcore/internal/providermanagement/providermanagement_test.go +++ b/capifcore/internal/providermanagement/providermanagement_test.go @@ -78,7 +78,7 @@ func TestUpdateValidProviderWithNewFunction(t *testing.T) { (*provider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF (*provider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF (*provider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF - managerUnderTest.onboardedProviders[domainID] = provider + managerUnderTest.registeredProviders[domainID] = provider // Modify the provider updatedProvider := getProvider() @@ -95,6 +95,9 @@ func TestUpdateValidProviderWithNewFunction(t *testing.T) { testFuncs = append(testFuncs, provapi.APIProviderFunctionDetails{ ApiProvFuncInfo: &newFuncInfoAEF, ApiProvFuncRole: provapi.ApiProviderFuncRoleAEF, + RegInfo: provapi.RegistrationInformation{ + ApiProvPubKey: "key", + }, }) updatedProvider.ApiProvFuncs = &testFuncs @@ -119,7 +122,7 @@ func TestUpdateValidProviderWithDeletedFunction(t *testing.T) { (*provider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF (*provider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF (*provider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF - managerUnderTest.onboardedProviders[domainID] = provider + managerUnderTest.registeredProviders[domainID] = provider // Modify the provider updatedProvider := getProvider() @@ -152,7 +155,7 @@ func TestUpdateMissingFunction(t *testing.T) { (*provider.ApiProvFuncs)[0].ApiProvFuncId = &otherId (*provider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF (*provider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF - managerUnderTest.onboardedProviders[domainID] = provider + managerUnderTest.registeredProviders[domainID] = provider // Modify the provider updatedProvider := getProvider() @@ -177,7 +180,7 @@ func TestDeleteProvider(t *testing.T) { provider := getProvider() provider.ApiProvDomId = &domainID (*provider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF - managerUnderTest.onboardedProviders[domainID] = provider + managerUnderTest.registeredProviders[domainID] = provider assert.True(t, managerUnderTest.IsFunctionRegistered(funcIdAPF)) result := testutil.NewRequest().Delete("/registrations/"+domainID).Go(t, requestHandler) @@ -190,7 +193,7 @@ func TestProviderHandlingValidation(t *testing.T) { newProvider := provapi.APIProviderEnrolmentDetails{} - // Register a valid provider + // Register an invalid provider result := testutil.NewRequest().Post("/registrations").WithJsonBody(newProvider).Go(t, requestHandler) assert.Equal(t, http.StatusBadRequest, result.Code()) @@ -199,8 +202,8 @@ func TestProviderHandlingValidation(t *testing.T) { assert.NoError(t, err, "error unmarshaling response") badRequest := http.StatusBadRequest assert.Equal(t, &badRequest, problemDetails.Status) - errMsg := "Provider missing required ApiProvDomInfo" - assert.Equal(t, &errMsg, problemDetails.Cause) + assert.Contains(t, *problemDetails.Cause, "Provider not valid") + assert.Contains(t, *problemDetails.Cause, "regSec") } func TestGetExposedFunctionsForPublishingFunction(t *testing.T) { @@ -211,8 +214,8 @@ func TestGetExposedFunctionsForPublishingFunction(t *testing.T) { (*provider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF (*provider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF (*provider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF - managerUnderTest.onboardedProviders[domainID] = provider - managerUnderTest.onboardedProviders[otherDomainID] = getOtherProvider() + managerUnderTest.registeredProviders[domainID] = provider + managerUnderTest.registeredProviders[otherDomainID] = getOtherProvider() exposedFuncs := managerUnderTest.GetAefsForPublisher(funcIdAPF) assert.Equal(t, 1, len(exposedFuncs)) @@ -224,17 +227,27 @@ func getProvider() provapi.APIProviderEnrolmentDetails { { ApiProvFuncInfo: &funcInfoAPF, ApiProvFuncRole: provapi.ApiProviderFuncRoleAPF, + RegInfo: provapi.RegistrationInformation{ + ApiProvPubKey: "key", + }, }, { ApiProvFuncInfo: &funcInfoAMF, ApiProvFuncRole: provapi.ApiProviderFuncRoleAMF, + RegInfo: provapi.RegistrationInformation{ + ApiProvPubKey: "key", + }, }, { ApiProvFuncInfo: &funcInfoAEF, ApiProvFuncRole: provapi.ApiProviderFuncRoleAEF, + RegInfo: provapi.RegistrationInformation{ + ApiProvPubKey: "key", + }, }, } return provapi.APIProviderEnrolmentDetails{ + RegSec: "sec", ApiProvDomInfo: &domainInfo, ApiProvFuncs: &testFuncs, }