X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Finvokermanagementapi%2Ftypevalidation_test.go;h=b6b491d0e55066767ff4f6c7d90ab5f4d6c93d49;hb=8fa464fbe92fe7fa2107915accfe93cb932fb021;hp=60e4ee5c8e00f20e1843f61c9cbb7e645b4143f8;hpb=b8e717a8c264a8b3f73626fc28c81ae65283ae80;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/invokermanagementapi/typevalidation_test.go b/capifcore/internal/invokermanagementapi/typevalidation_test.go index 60e4ee5..b6b491d 100644 --- a/capifcore/internal/invokermanagementapi/typevalidation_test.go +++ b/capifcore/internal/invokermanagementapi/typevalidation_test.go @@ -35,7 +35,14 @@ func TestValidateInvoker(t *testing.T) { assert.Contains(t, err.Error(), "NotificationDestination") } - invokerUnderTest.NotificationDestination = "destination" + invokerUnderTest.NotificationDestination = "invalid dest" + err = invokerUnderTest.Validate() + if assert.Error(t, err) { + assert.Contains(t, err.Error(), "invalid") + assert.Contains(t, err.Error(), "NotificationDestination") + } + + invokerUnderTest.NotificationDestination = "http://golang.cafe/" err = invokerUnderTest.Validate() if assert.Error(t, err) { assert.Contains(t, err.Error(), "missing") @@ -46,3 +53,22 @@ func TestValidateInvoker(t *testing.T) { err = invokerUnderTest.Validate() assert.Nil(t, err) } + +func TestValidateAlreadyOnboarded(t *testing.T) { + publicKey := "publicKey" + invokerUnderTest := APIInvokerEnrolmentDetails{ + OnboardingInformation: OnboardingInformation{ + ApiInvokerPublicKey: publicKey, + }, + } + + otherInvoker := APIInvokerEnrolmentDetails{ + OnboardingInformation: OnboardingInformation{ + ApiInvokerPublicKey: "otherPublicKey", + }, + } + assert.Nil(t, invokerUnderTest.ValidateAlreadyOnboarded(otherInvoker)) + + otherInvoker.OnboardingInformation.ApiInvokerPublicKey = publicKey + assert.NotNil(t, invokerUnderTest.ValidateAlreadyOnboarded(otherInvoker)) +}