summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
b8e717a)
Issue-ID: NONRTRIC-814
Signed-off-by: elinuxhenrik <henrik.b.andersson@est.tech>
Change-Id: Ie0393d0139a0467be6a0eb242afba011c51b6052
// Onboard an invoker missing required OnboardingInformation.ApiInvokerPublicKey, should get 400 with problem details
invalidInvoker = invokermanagementapi.APIInvokerEnrolmentDetails{
// Onboard an invoker missing required OnboardingInformation.ApiInvokerPublicKey, should get 400 with problem details
invalidInvoker = invokermanagementapi.APIInvokerEnrolmentDetails{
- NotificationDestination: "url",
+ NotificationDestination: "http://golang.cafe/",
}
result = testutil.NewRequest().Post("/onboardedInvokers").WithJsonBody(invalidInvoker).Go(t, requestHandler)
}
result = testutil.NewRequest().Post("/onboardedInvokers").WithJsonBody(invalidInvoker).Go(t, requestHandler)
invokerId := "invokerId"
invoker := invokermanagementapi.APIInvokerEnrolmentDetails{
ApiInvokerId: &invokerId,
invokerId := "invokerId"
invoker := invokermanagementapi.APIInvokerEnrolmentDetails{
ApiInvokerId: &invokerId,
- NotificationDestination: "url",
+ NotificationDestination: "http://golang.cafe/",
OnboardingInformation: invokermanagementapi.OnboardingInformation{
ApiInvokerPublicKey: "key",
},
OnboardingInformation: invokermanagementapi.OnboardingInformation{
ApiInvokerPublicKey: "key",
},
serviceUnderTest.onboardedInvokers[invokerId] = invoker
// Update the invoker with valid invoker, should return 200 with updated invoker details
serviceUnderTest.onboardedInvokers[invokerId] = invoker
// Update the invoker with valid invoker, should return 200 with updated invoker details
- newNotifURL := "newUrl"
+ newNotifURL := "http://golang.org/"
invoker.NotificationDestination = common29122.Uri(newNotifURL)
newPublicKey := "newPublicKey"
invoker.OnboardingInformation.ApiInvokerPublicKey = newPublicKey
invoker.NotificationDestination = common29122.Uri(newNotifURL)
newPublicKey := "newPublicKey"
invoker.OnboardingInformation.ApiInvokerPublicKey = newPublicKey
assert.Contains(t, *problemDetails.Cause, "NotificationDestination")
// Update with an invoker missing required OnboardingInformation.ApiInvokerPublicKey, should get 400 with problem details
assert.Contains(t, *problemDetails.Cause, "NotificationDestination")
// Update with an invoker missing required OnboardingInformation.ApiInvokerPublicKey, should get 400 with problem details
- invalidInvoker.NotificationDestination = "url"
+ invalidInvoker.NotificationDestination = "http://golang.org/"
invalidInvoker.OnboardingInformation = invokermanagementapi.OnboardingInformation{}
result = testutil.NewRequest().Put("/onboardedInvokers/"+invokerId).WithJsonBody(invalidInvoker).Go(t, requestHandler)
invalidInvoker.OnboardingInformation = invokermanagementapi.OnboardingInformation{}
result = testutil.NewRequest().Put("/onboardedInvokers/"+invokerId).WithJsonBody(invalidInvoker).Go(t, requestHandler)
func getInvoker(invokerInfo string) invokermanagementapi.APIInvokerEnrolmentDetails {
newInvoker := invokermanagementapi.APIInvokerEnrolmentDetails{
ApiInvokerInformation: &invokerInfo,
func getInvoker(invokerInfo string) invokermanagementapi.APIInvokerEnrolmentDetails {
newInvoker := invokermanagementapi.APIInvokerEnrolmentDetails{
ApiInvokerInformation: &invokerInfo,
- NotificationDestination: "url",
+ NotificationDestination: "http://golang.cafe/",
OnboardingInformation: invokermanagementapi.OnboardingInformation{
ApiInvokerPublicKey: "key",
},
OnboardingInformation: invokermanagementapi.OnboardingInformation{
ApiInvokerPublicKey: "key",
},
)
func (ied *APIInvokerEnrolmentDetails) Validate() error {
)
func (ied *APIInvokerEnrolmentDetails) Validate() error {
return errors.New("APIInvokerEnrolmentDetails missing required NotificationDestination")
}
return errors.New("APIInvokerEnrolmentDetails missing required NotificationDestination")
}
+ if _, err := url.ParseRequestURI(string(ied.NotificationDestination)); err != nil {
+ return fmt.Errorf("APIInvokerEnrolmentDetails has invalid NotificationDestination, err=%s", err)
+ }
+
if ied.OnboardingInformation.ApiInvokerPublicKey == "" {
return errors.New("APIInvokerEnrolmentDetails missing required OnboardingInformation.ApiInvokerPublicKey")
}
if ied.OnboardingInformation.ApiInvokerPublicKey == "" {
return errors.New("APIInvokerEnrolmentDetails missing required OnboardingInformation.ApiInvokerPublicKey")
}
assert.Contains(t, err.Error(), "NotificationDestination")
}
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")
err = invokerUnderTest.Validate()
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "missing")