Refactor check earlier registration
[nonrtric/plt/sme.git] / capifcore / internal / invokermanagementapi / typevalidation_test.go
index 60e4ee5..499b0a1 100644 (file)
@@ -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 TestIsOnboarded(t *testing.T) {
+       publicKey := "publicKey"
+       invokerUnderTest := APIInvokerEnrolmentDetails{
+               OnboardingInformation: OnboardingInformation{
+                       ApiInvokerPublicKey: publicKey,
+               },
+       }
+
+       otherInvoker := APIInvokerEnrolmentDetails{
+               OnboardingInformation: OnboardingInformation{
+                       ApiInvokerPublicKey: "otherPublicKey",
+               },
+       }
+       assert.False(t, invokerUnderTest.IsOnboarded(otherInvoker))
+
+       otherInvoker.OnboardingInformation.ApiInvokerPublicKey = publicKey
+       assert.True(t, invokerUnderTest.IsOnboarded(otherInvoker))
+}