Skip to content

Commit

Permalink
fix(User Management): re-gen service with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx committed Dec 11, 2020
1 parent 548ddbd commit eeda08a
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 14 deletions.
33 changes: 24 additions & 9 deletions usermanagementv1/user_management_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-60fd6b3d-20201128-071551
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-d753183b-20201209-163011
*/


Expand Down Expand Up @@ -108,6 +108,21 @@ func NewUserManagementV1(options *UserManagementV1Options) (service *UserManagem
return
}

// GetServiceURLForRegion returns the service URL to be used for the specified region
func GetServiceURLForRegion(region string) (string, error) {
return "", fmt.Errorf("service does not support regional URLs")
}

// Clone makes a copy of "userManagement" suitable for processing requests.
func (userManagement *UserManagementV1) Clone() *UserManagementV1 {
if core.IsNil(userManagement) {
return nil
}
clone := *userManagement
clone.Service = userManagement.Service.Clone()
return &clone
}

// SetServiceURL sets the service URL
func (userManagement *UserManagementV1) SetServiceURL(url string) error {
return userManagement.Service.SetServiceURL(url)
Expand Down Expand Up @@ -611,8 +626,8 @@ func (userManagement *UserManagementV1) UpdateUserSettingsWithContext(ctx contex
if updateUserSettingsOptions.NotificationLanguage != nil {
body["notification_language"] = updateUserSettingsOptions.NotificationLanguage
}
if updateUserSettingsOptions.AllowedIpAddresses != nil {
body["allowed_ip_addresses"] = updateUserSettingsOptions.AllowedIpAddresses
if updateUserSettingsOptions.AllowedIPAddresses != nil {
body["allowed_ip_addresses"] = updateUserSettingsOptions.AllowedIPAddresses
}
if updateUserSettingsOptions.SelfManage != nil {
body["self_manage"] = updateUserSettingsOptions.SelfManage
Expand Down Expand Up @@ -1024,7 +1039,7 @@ type UpdateUserSettingsOptions struct {
NotificationLanguage *string `json:"notification_language,omitempty"`

// A comma-separated list of IP addresses.
AllowedIpAddresses *string `json:"allowed_ip_addresses,omitempty"`
AllowedIPAddresses *string `json:"allowed_ip_addresses,omitempty"`

// Whether user managed login is enabled. The default value is `false`.
SelfManage *bool `json:"self_manage,omitempty"`
Expand Down Expand Up @@ -1065,9 +1080,9 @@ func (options *UpdateUserSettingsOptions) SetNotificationLanguage(notificationLa
return options
}

// SetAllowedIpAddresses : Allow user to set AllowedIpAddresses
func (options *UpdateUserSettingsOptions) SetAllowedIpAddresses(allowedIpAddresses string) *UpdateUserSettingsOptions {
options.AllowedIpAddresses = core.StringPtr(allowedIpAddresses)
// SetAllowedIPAddresses : Allow user to set AllowedIPAddresses
func (options *UpdateUserSettingsOptions) SetAllowedIPAddresses(allowedIPAddresses string) *UpdateUserSettingsOptions {
options.AllowedIPAddresses = core.StringPtr(allowedIPAddresses)
return options
}

Expand Down Expand Up @@ -1234,7 +1249,7 @@ type UserSettings struct {
NotificationLanguage *string `json:"notification_language,omitempty"`

// A comma-separated list of IP addresses.
AllowedIpAddresses *string `json:"allowed_ip_addresses,omitempty"`
AllowedIPAddresses *string `json:"allowed_ip_addresses,omitempty"`

// Whether user managed login is enabled. The default value is `false`.
SelfManage *bool `json:"self_manage,omitempty"`
Expand All @@ -1252,7 +1267,7 @@ func UnmarshalUserSettings(m map[string]json.RawMessage, result interface{}) (er
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "allowed_ip_addresses", &obj.AllowedIpAddresses)
err = core.UnmarshalPrimitive(m, "allowed_ip_addresses", &obj.AllowedIPAddresses)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion usermanagementv1/user_management_v1_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var _ = Describe(`UserManagementV1 Integration Tests`, func() {
updateUserSettingsOptions := &usermanagementv1.UpdateUserSettingsOptions{
AccountID: &accountID,
IamID: &userID,
AllowedIpAddresses: core.StringPtr("32.96.110.50,172.16.254.1"),
AllowedIPAddresses: core.StringPtr("32.96.110.50,172.16.254.1"),
SelfManage: core.BoolPtr(true),
}

Expand Down
64 changes: 60 additions & 4 deletions usermanagementv1/user_management_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ var _ = Describe(`UserManagementV1`, func() {
Expect(userManagementService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

clone := userManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != userManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(userManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(userManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url from constructor successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -87,6 +93,12 @@ var _ = Describe(`UserManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(userManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := userManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != userManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(userManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(userManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url programatically successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -98,6 +110,12 @@ var _ = Describe(`UserManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(userManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := userManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != userManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(userManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(userManagementService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -135,6 +153,16 @@ var _ = Describe(`UserManagementV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = usermanagementv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`ListUsers(listUsersOptions *ListUsersOptions) - Operation response error`, func() {
listUsersPath := "/v2/accounts/testString/users"
Context(`Using mock server endpoint`, func() {
Expand Down Expand Up @@ -940,6 +968,12 @@ var _ = Describe(`UserManagementV1`, func() {
Expect(userManagementService).ToNot(BeNil())
Expect(serviceErr).To(BeNil())
ClearTestEnvironment(testEnvironment)

clone := userManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != userManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(userManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(userManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url from constructor successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -950,6 +984,12 @@ var _ = Describe(`UserManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(userManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := userManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != userManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(userManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(userManagementService.Service.Options.Authenticator))
})
It(`Create service client using external config and set url programatically successfully`, func() {
SetTestEnvironment(testEnvironment)
Expand All @@ -961,6 +1001,12 @@ var _ = Describe(`UserManagementV1`, func() {
Expect(serviceErr).To(BeNil())
Expect(userManagementService.Service.GetServiceURL()).To(Equal("https://testService/api"))
ClearTestEnvironment(testEnvironment)

clone := userManagementService.Clone()
Expect(clone).ToNot(BeNil())
Expect(clone.Service != userManagementService.Service).To(BeTrue())
Expect(clone.GetServiceURL()).To(Equal(userManagementService.GetServiceURL()))
Expect(clone.Service.Options.Authenticator).To(Equal(userManagementService.Service.Options.Authenticator))
})
})
Context(`Using external config, construct service client instances with error: Invalid Auth`, func() {
Expand Down Expand Up @@ -998,6 +1044,16 @@ var _ = Describe(`UserManagementV1`, func() {
})
})
})
Describe(`Regional endpoint tests`, func() {
It(`GetServiceURLForRegion(region string)`, func() {
var url string
var err error
url, err = usermanagementv1.GetServiceURLForRegion("INVALID_REGION")
Expect(url).To(BeEmpty())
Expect(err).ToNot(BeNil())
fmt.Fprintf(GinkgoWriter, "Expected error: %s\n", err.Error())
})
})
Describe(`GetUserSettings(getUserSettingsOptions *GetUserSettingsOptions) - Operation response error`, func() {
getUserSettingsPath := "/v2/accounts/testString/users/testString/settings"
Context(`Using mock server endpoint`, func() {
Expand Down Expand Up @@ -1204,7 +1260,7 @@ var _ = Describe(`UserManagementV1`, func() {
updateUserSettingsOptionsModel.IamID = core.StringPtr("testString")
updateUserSettingsOptionsModel.Language = core.StringPtr("testString")
updateUserSettingsOptionsModel.NotificationLanguage = core.StringPtr("testString")
updateUserSettingsOptionsModel.AllowedIpAddresses = core.StringPtr("32.96.110.50,172.16.254.1")
updateUserSettingsOptionsModel.AllowedIPAddresses = core.StringPtr("32.96.110.50,172.16.254.1")
updateUserSettingsOptionsModel.SelfManage = core.BoolPtr(true)
updateUserSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}

Expand Down Expand Up @@ -1233,7 +1289,7 @@ var _ = Describe(`UserManagementV1`, func() {
updateUserSettingsOptionsModel.IamID = core.StringPtr("testString")
updateUserSettingsOptionsModel.Language = core.StringPtr("testString")
updateUserSettingsOptionsModel.NotificationLanguage = core.StringPtr("testString")
updateUserSettingsOptionsModel.AllowedIpAddresses = core.StringPtr("32.96.110.50,172.16.254.1")
updateUserSettingsOptionsModel.AllowedIPAddresses = core.StringPtr("32.96.110.50,172.16.254.1")
updateUserSettingsOptionsModel.SelfManage = core.BoolPtr(true)
updateUserSettingsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"}
// Invoke operation with empty URL (negative test)
Expand Down Expand Up @@ -1406,15 +1462,15 @@ var _ = Describe(`UserManagementV1`, func() {
updateUserSettingsOptionsModel.SetIamID("testString")
updateUserSettingsOptionsModel.SetLanguage("testString")
updateUserSettingsOptionsModel.SetNotificationLanguage("testString")
updateUserSettingsOptionsModel.SetAllowedIpAddresses("32.96.110.50,172.16.254.1")
updateUserSettingsOptionsModel.SetAllowedIPAddresses("32.96.110.50,172.16.254.1")
updateUserSettingsOptionsModel.SetSelfManage(true)
updateUserSettingsOptionsModel.SetHeaders(map[string]string{"foo": "bar"})
Expect(updateUserSettingsOptionsModel).ToNot(BeNil())
Expect(updateUserSettingsOptionsModel.AccountID).To(Equal(core.StringPtr("testString")))
Expect(updateUserSettingsOptionsModel.IamID).To(Equal(core.StringPtr("testString")))
Expect(updateUserSettingsOptionsModel.Language).To(Equal(core.StringPtr("testString")))
Expect(updateUserSettingsOptionsModel.NotificationLanguage).To(Equal(core.StringPtr("testString")))
Expect(updateUserSettingsOptionsModel.AllowedIpAddresses).To(Equal(core.StringPtr("32.96.110.50,172.16.254.1")))
Expect(updateUserSettingsOptionsModel.AllowedIPAddresses).To(Equal(core.StringPtr("32.96.110.50,172.16.254.1")))
Expect(updateUserSettingsOptionsModel.SelfManage).To(Equal(core.BoolPtr(true)))
Expect(updateUserSettingsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))
})
Expand Down

0 comments on commit eeda08a

Please sign in to comment.