X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fprovidermanagementapi%2Ftypevalidation_test.go;h=7698aab4b1367499a80932f8891e63f949a4aa3a;hb=refs%2Fchanges%2F17%2F10317%2F1;hp=fb5ad81a0e5707e00c895d97e8655af415dad377;hpb=829338e085a03b58b6bb8a54b8c67bfffbf84952;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/providermanagementapi/typevalidation_test.go b/capifcore/internal/providermanagementapi/typevalidation_test.go index fb5ad81..7698aab 100644 --- a/capifcore/internal/providermanagementapi/typevalidation_test.go +++ b/capifcore/internal/providermanagementapi/typevalidation_test.go @@ -59,6 +59,14 @@ func TestValidateAPIProviderFunctionDetails(t *testing.T) { assert.Contains(t, err.Error(), "apiProvFuncRole") } + var invalidFuncRole ApiProviderFuncRole = "invalid" + funcDetailsUnderTest.ApiProvFuncRole = invalidFuncRole + err = funcDetailsUnderTest.Validate() + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "invalid") + assert.Contains(t, err.Error(), "apiProvFuncRole") + } + funcDetailsUnderTest.ApiProvFuncRole = ApiProviderFuncRoleAEF err = funcDetailsUnderTest.Validate() if assert.Error(t, err) { @@ -88,55 +96,14 @@ func TestValidateAPIProviderEnrolmentDetails(t *testing.T) { assert.Contains(t, err.Error(), "apiProvFuncs") assert.Contains(t, err.Error(), "contains invalid") } -} -func TestUpdateFuncs_addNewFunction(t *testing.T) { - providerUnderTest := getProvider() - - newFuncInfoAEF := "new func as AEF" - newFuncs := append(*providerUnderTest.ApiProvFuncs, APIProviderFunctionDetails{ - ApiProvFuncInfo: &newFuncInfoAEF, + (*providerDetailsUnderTest.ApiProvFuncs)[0] = APIProviderFunctionDetails{ ApiProvFuncRole: ApiProviderFuncRoleAEF, - }) - providerUnderTest.ApiProvFuncs = &newFuncs - - err := providerUnderTest.UpdateFuncs(getProvider()) - - assert.Nil(t, err) - assert.Len(t, *providerUnderTest.ApiProvFuncs, 4) - assert.True(t, providerUnderTest.IsFunctionRegistered("AEF_id_new_func_as_AEF")) -} - -func TestUpdateFuncs_deleteFunction(t *testing.T) { - providerUnderTest := getProvider() - - modFuncs := []APIProviderFunctionDetails{(*providerUnderTest.ApiProvFuncs)[0], (*providerUnderTest.ApiProvFuncs)[1]} - providerUnderTest.ApiProvFuncs = &modFuncs - - err := providerUnderTest.UpdateFuncs(getProvider()) - - assert.Nil(t, err) - assert.Len(t, *providerUnderTest.ApiProvFuncs, 2) - assert.True(t, providerUnderTest.IsFunctionRegistered(funcIdAPF)) - assert.True(t, providerUnderTest.IsFunctionRegistered(funcIdAMF)) -} - -func TestUpdateFuncs_unregisteredFunction(t *testing.T) { - providerUnderTest := getProvider() - - unRegId := "unRegId" - modFuncs := []APIProviderFunctionDetails{ - { - ApiProvFuncId: &unRegId, + RegInfo: RegistrationInformation{ + ApiProvPubKey: "key", }, } - providerUnderTest.ApiProvFuncs = &modFuncs - - err := providerUnderTest.UpdateFuncs(getProvider()) - if assert.Error(t, err) { - assert.Contains(t, err.Error(), unRegId) - assert.Contains(t, err.Error(), "not registered") - } + assert.Nil(t, providerDetailsUnderTest.Validate()) } func getProvider() APIProviderEnrolmentDetails {