From 7da2ad43705a88293d4416c2afedf799c3b0c967 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 13 Sep 2023 13:54:49 -0500 Subject: [PATCH 1/2] Fix to add new output format Signed-off-by: Dylan --- .../context_based_restrictions_v1.go | 7 +++++++ .../context_based_restrictions_v1_test.go | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1.go b/contextbasedrestrictionsv1/context_based_restrictions_v1.go index 1702a5e0..bd25a422 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1.go @@ -1118,6 +1118,9 @@ type APIType struct { // The description of the API type. Description *string `json:"description" validate:"required"` + // The type of the API type. + Type *string `json:"type" validate:"required"` + // The actions available for the API type. Actions []Action `json:"actions" validate:"required"` } @@ -1137,6 +1140,10 @@ func UnmarshalAPIType(m map[string]json.RawMessage, result interface{}) (err err if err != nil { return } + err = core.UnmarshalPrimitive(m, "type", &obj.Type) + if err != nil { + return + } err = core.UnmarshalModel(m, "actions", &obj.Actions, UnmarshalAction) if err != nil { return diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go index 6bf64c21..83cdc01a 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go @@ -3446,7 +3446,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"api_types": [{"api_type_id": "APITypeID", "display_name": "DisplayName", "description": "Description", "actions": [{"action_id": "ActionID", "description": "Description"}]}]}`) + fmt.Fprintf(res, "%s", `{"api_types": [{"api_type_id": "APITypeID", "display_name": "DisplayName", "description": "Description", "type": "Type", "actions": [{"action_id": "ActionID", "description": "Description"}]}]}`) })) }) It(`Invoke ListAvailableServiceOperations successfully with retries`, func() { @@ -3511,7 +3511,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) - fmt.Fprintf(res, "%s", `{"api_types": [{"api_type_id": "APITypeID", "display_name": "DisplayName", "description": "Description", "actions": [{"action_id": "ActionID", "description": "Description"}]}]}`) + fmt.Fprintf(res, "%s", `{"api_types": [{"api_type_id": "APITypeID", "display_name": "DisplayName", "description": "Description", "type": "Type", "actions": [{"action_id": "ActionID", "description": "Description"}]}]}`) })) }) It(`Invoke ListAvailableServiceOperations successfully`, func() { From 4c5d332b555cc09087083dc40045328e915f2647 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 14 Sep 2023 13:22:07 -0500 Subject: [PATCH 2/2] update tests for new output Signed-off-by: Dylan --- .../context_based_restrictions_v1.go | 4 +-- ..._based_restrictions_v1_integration_test.go | 28 ++++++++++++++++++- .../context_based_restrictions_v1_test.go | 28 +++++++++---------- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1.go b/contextbasedrestrictionsv1/context_based_restrictions_v1.go index bd25a422..aad549b5 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1.go @@ -3081,7 +3081,7 @@ func UnmarshalZoneSummary(m map[string]json.RawMessage, result interface{}) (err return } -// AddressIPAddress : A single IP address. +// AddressIPAddress : A single IP address. IPv4 and IPv6 are supported. // This model "extends" Address type AddressIPAddress struct { // The type of address. @@ -3126,7 +3126,7 @@ func UnmarshalAddressIPAddress(m map[string]json.RawMessage, result interface{}) return } -// AddressIPAddressRange : An IP address range. +// AddressIPAddressRange : An IP address range. IPv4 and IPv6 are supported. // This model "extends" Address type AddressIPAddressRange struct { // The type of address. diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go index 8b1de1a2..8cd88a56 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_integration_test.go @@ -1059,6 +1059,9 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) Expect(operationsList).ToNot(BeNil()) + for _, apiType := range operationsList.APITypes { + Expect(*apiType.Type).ToNot(BeEmpty()) + } }) }) Describe(`ListAvailableServiceOperations - List available service operations with Service Group ID`, func() { @@ -1075,9 +1078,12 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) Expect(operationsList).ToNot(BeNil()) + for _, apiType := range operationsList.APITypes { + Expect(*apiType.Type).ToNot(BeEmpty()) + } }) }) - Describe(`ListAvailableServiceOperations - List available service operations with Composite Parent`, func() { + Describe(`ListAvailableServiceOperations - List available service operations for subresource`, func() { BeforeEach(func() { shouldSkipTest() }) @@ -1092,6 +1098,26 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() { Expect(err).To(BeNil()) Expect(response.StatusCode).To(Equal(200)) Expect(operationsList).ToNot(BeNil()) + for _, apiType := range operationsList.APITypes { + Expect(*apiType.Type).ToNot(BeEmpty()) + } + }) + }) + Describe(`ListAvailableServiceOperations - List available service operations with 'mutually exclusive parameters' Error`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`ListAvailableServiceOperations(listAvailableServiceOperationsOptions *ListAvailableServiceOperationsOptions)`, func() { + listAvailableServiceOperationsOptions := &contextbasedrestrictionsv1.ListAvailableServiceOperationsOptions{ + ServiceName: core.StringPtr("iam-access-management"), + ServiceGroupID: core.StringPtr("IAM"), + TransactionID: getTransactionID(), + } + + operationsList, response, err := contextBasedRestrictionsService.ListAvailableServiceOperations(listAvailableServiceOperationsOptions) + Expect(err).ToNot(BeNil()) + Expect(response.StatusCode).To(Equal(400)) + Expect(operationsList).To(BeNil()) }) }) diff --git a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go index 83cdc01a..91199810 100644 --- a/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go +++ b/contextbasedrestrictionsv1/context_based_restrictions_v1_test.go @@ -190,7 +190,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -272,7 +272,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -362,7 +362,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -393,7 +393,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -438,7 +438,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := new(contextbasedrestrictionsv1.CreateZoneOptions) @@ -983,7 +983,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1069,7 +1069,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1163,7 +1163,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1196,7 +1196,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -1250,7 +1250,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { // Construct an instance of the AddressIPAddress model addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") // Construct an instance of the ReplaceZoneOptions model replaceZoneOptionsModel := new(contextbasedrestrictionsv1.ReplaceZoneOptions) @@ -3698,9 +3698,9 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) Expect(addressModel).ToNot(BeNil()) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") Expect(addressModel.Type).To(Equal(core.StringPtr("ipAddress"))) - Expect(addressModel.Value).To(Equal(core.StringPtr("169.23.56.234"))) + Expect(addressModel.Value).To(Equal(core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::"))) // Construct an instance of the CreateZoneOptions model createZoneOptionsModel := contextBasedRestrictionsService.NewCreateZoneOptions() @@ -3972,9 +3972,9 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() { addressModel := new(contextbasedrestrictionsv1.AddressIPAddress) Expect(addressModel).ToNot(BeNil()) addressModel.Type = core.StringPtr("ipAddress") - addressModel.Value = core.StringPtr("169.23.56.234") + addressModel.Value = core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::") Expect(addressModel.Type).To(Equal(core.StringPtr("ipAddress"))) - Expect(addressModel.Value).To(Equal(core.StringPtr("169.23.56.234"))) + Expect(addressModel.Value).To(Equal(core.StringPtr("169.23.56.234, 3ffe:1900:fe21:4545::"))) // Construct an instance of the ReplaceZoneOptions model zoneID := "testString"