X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fprovidermanagement%2Fprovidermanagement_test.go;h=cbcf43899021976071ee9a887d46d5574087417e;hb=d17ee019461493f52df06074ce95a6cb951ffdc4;hp=010e7c548346a2356452732149c0371e1d151510;hpb=f62685e5a2187fb58c7f27cdd1f14dd2c152880d;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/providermanagement/providermanagement_test.go b/capifcore/internal/providermanagement/providermanagement_test.go index 010e7c5..cbcf438 100644 --- a/capifcore/internal/providermanagement/providermanagement_test.go +++ b/capifcore/internal/providermanagement/providermanagement_test.go @@ -49,6 +49,49 @@ var ( funcIdAEF = "AEF_id_rApp_as_AEF" ) +func TestFailedUpdateValidProviderWithNewFunction(t *testing.T) { + managerUnderTest, requestHandler := getEcho() + + provider := getProvider() + provider.ApiProvDomId = &domainID + (*provider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF + (*provider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF + (*provider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF + managerUnderTest.registeredProviders[domainID] = provider + + // Modify the provider + updatedProvider := getProvider() + + // For this test case, we do not set updatedProvider.ApiProvDomId, so that we can test for a 400 error below. + (*updatedProvider.ApiProvFuncs)[0].ApiProvFuncId = &funcIdAPF + (*updatedProvider.ApiProvFuncs)[1].ApiProvFuncId = &funcIdAMF + (*updatedProvider.ApiProvFuncs)[2].ApiProvFuncId = &funcIdAEF + newDomainInfo := "New domain info" + updatedProvider.ApiProvDomInfo = &newDomainInfo + newFunctionInfo := "New function info" + (*updatedProvider.ApiProvFuncs)[0].ApiProvFuncInfo = &newFunctionInfo + newFuncInfoAEF := "new func as AEF" + testFuncs := *updatedProvider.ApiProvFuncs + testFuncs = append(testFuncs, provapi.APIProviderFunctionDetails{ + ApiProvFuncInfo: &newFuncInfoAEF, + ApiProvFuncRole: provapi.ApiProviderFuncRoleAEF, + RegInfo: provapi.RegistrationInformation{ + ApiProvPubKey: "key", + }, + }) + updatedProvider.ApiProvFuncs = &testFuncs + + result := testutil.NewRequest().Put("/registrations/"+domainID).WithJsonBody(updatedProvider).Go(t, requestHandler) + assert.Equal(t, http.StatusBadRequest, result.Code()) + + var resultError common29122.ProblemDetails + err := result.UnmarshalJsonToObject(&resultError) + assert.NoError(t, err, "error unmarshaling response") + + assert.Contains(t, *resultError.Cause, "APIProviderEnrolmentDetails ApiProvDomId doesn't match path parameter") + assert.False(t, managerUnderTest.IsFunctionRegistered("AEF_id_new_func_as_AEF")) +} + func TestRegisterValidProvider(t *testing.T) { managerUnderTest, requestHandler := getEcho()