X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Fprovidermanagementapi%2Ftypevalidation_test.go;h=a5a4e3c62e3a8981e1c3f75dc4db884328ceb8ce;hb=HEAD;hp=3980b19e88f78e8781c1b2276f11d7ed819b0b2c;hpb=9b3594da33e5e887dd960bd97d4f925f4f6b5c99;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/providermanagementapi/typevalidation_test.go b/capifcore/internal/providermanagementapi/typevalidation_test.go index 3980b19..a5a4e3c 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) { @@ -98,6 +106,21 @@ func TestValidateAPIProviderEnrolmentDetails(t *testing.T) { assert.Nil(t, providerDetailsUnderTest.Validate()) } +func TestValidateAlreadyRegistered(t *testing.T) { + regSec := "regSec" + providerUnderTest := APIProviderEnrolmentDetails{ + RegSec: regSec, + } + + otherProvider := APIProviderEnrolmentDetails{ + RegSec: "otherRegSec", + } + assert.Nil(t, providerUnderTest.ValidateAlreadyRegistered(otherProvider)) + + otherProvider.RegSec = regSec + assert.NotNil(t, providerUnderTest.ValidateAlreadyRegistered(otherProvider)) +} + func getProvider() APIProviderEnrolmentDetails { testFuncs := []APIProviderFunctionDetails{ {