Skip to content

Commit

Permalink
fix(Context-Based Restrictions): fix output to Operations (#278)
Browse files Browse the repository at this point in the history
Signed-off-by: Dylan <Dylan.Yu@ibm.com>
  • Loading branch information
JonahFarc committed Sep 15, 2023
1 parent 35d8ec2 commit 424b6b5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 19 deletions.
11 changes: 9 additions & 2 deletions contextbasedrestrictionsv1/context_based_restrictions_v1.go
Expand Up @@ -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"`
}
Expand All @@ -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
Expand Down Expand Up @@ -3074,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.
Expand Down Expand Up @@ -3119,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.
Expand Down
Expand Up @@ -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() {
Expand All @@ -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()
})
Expand All @@ -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())
})
})

Expand Down
32 changes: 16 additions & 16 deletions contextbasedrestrictionsv1/context_based_restrictions_v1_test.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 424b6b5

Please sign in to comment.