Skip to content

Commit

Permalink
add list rule with service_group_id test
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-d12 committed Oct 3, 2022
1 parent fd86fba commit 52e480a
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 3 deletions.
14 changes: 13 additions & 1 deletion contextbasedrestrictionsv1/context_based_restrictions_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.53.0-9710cac3-20220713-193508
* IBM OpenAPI SDK Code Generator Version: 3.57.1-4c556507-20220928-143422
*/

// Package contextbasedrestrictionsv1 : Operations and models for the ContextBasedRestrictionsV1 service
Expand Down Expand Up @@ -727,6 +727,9 @@ func (contextBasedRestrictions *ContextBasedRestrictionsV1) ListRulesWithContext
if listRulesOptions.ServiceType != nil {
builder.AddQuery("service_type", fmt.Sprint(*listRulesOptions.ServiceType))
}
if listRulesOptions.ServiceGroupID != nil {
builder.AddQuery("service_group_id", fmt.Sprint(*listRulesOptions.ServiceGroupID))
}
if listRulesOptions.ZoneID != nil {
builder.AddQuery("zone_id", fmt.Sprint(*listRulesOptions.ZoneID))
}
Expand Down Expand Up @@ -1885,6 +1888,9 @@ type ListRulesOptions struct {
// The rule's `serviceType` resource attribute.
ServiceType *string `json:"service_type,omitempty"`

// The rule's `service_group_id` resource attribute.
ServiceGroupID *string `json:"service_group_id,omitempty"`

// The globally unique ID of the zone.
ZoneID *string `json:"zone_id,omitempty"`

Expand Down Expand Up @@ -1968,6 +1974,12 @@ func (_options *ListRulesOptions) SetServiceType(serviceType string) *ListRulesO
return _options
}

// SetServiceGroupID : Allow user to set ServiceGroupID
func (_options *ListRulesOptions) SetServiceGroupID(serviceGroupID string) *ListRulesOptions {
_options.ServiceGroupID = core.StringPtr(serviceGroupID)
return _options
}

// SetZoneID : Allow user to set ZoneID
func (_options *ListRulesOptions) SetZoneID(zoneID string) *ListRulesOptions {
_options.ZoneID = core.StringPtr(zoneID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,6 @@ var _ = Describe(`ContextBasedRestrictionsV1 Examples Tests`, func() {

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(204))

})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() {
})
})

Describe(`CreateZone - Create a zone`, func() {
Describe(`CreateZone - Create a network zone`, func() {
BeforeEach(func() {
shouldSkipTest()
})
Expand Down Expand Up @@ -646,6 +646,75 @@ var _ = Describe(`ContextBasedRestrictionsV1 Integration Tests`, func() {
})
})

Describe(`ListRule - List a rule with a valid service_group_id`, func() {
BeforeEach(func() {
shouldSkipTest()
})
//create rule with service_group_id
It(`CreateRule(createRuleOptions *CreateRuleOptions) with a valid service_group_id (201)`, func() {
ruleContextAttributeModel := &contextbasedrestrictionsv1.RuleContextAttribute{
Name: core.StringPtr("networkZoneId"),
Value: core.StringPtr(zoneID),
}

ruleContextModel := &contextbasedrestrictionsv1.RuleContext{
Attributes: []contextbasedrestrictionsv1.RuleContextAttribute{*ruleContextAttributeModel},
}

resourceModel := &contextbasedrestrictionsv1.Resource{
Attributes: []contextbasedrestrictionsv1.ResourceAttribute{
{
Name: core.StringPtr("accountId"),
Value: core.StringPtr(testAccountID),
},
{
Name: core.StringPtr("service_group_id"),
Value: core.StringPtr("IAM"),
},
},
}

createRuleOptions := &contextbasedrestrictionsv1.CreateRuleOptions{
Description: core.StringPtr("this is an example of rule"),
Contexts: []contextbasedrestrictionsv1.RuleContext{*ruleContextModel},
Resources: []contextbasedrestrictionsv1.Resource{*resourceModel},
EnforcementMode: core.StringPtr(contextbasedrestrictionsv1.CreateRuleOptionsEnforcementModeEnabledConst),
TransactionID: getTransactionID(),
}

rule, response, err := contextBasedRestrictionsService.CreateRule(createRuleOptions)

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(201))
Expect(rule).ToNot(BeNil())

//list rule with service_group_id
It(`ListRules(listRulesOptions *ListRulesOptions) with service_group_id (201)`, func() {
listRulesOptions := &contextbasedrestrictionsv1.ListRulesOptions{
AccountID: core.StringPtr(InvalidID),
TransactionID: getTransactionID(),
}

ruleList, response, err := contextBasedRestrictionsService.ListRules(listRulesOptions)

Expect(err).To(Not(BeNil()))
Expect(response.StatusCode).To(Equal(201))
Expect(ruleList).To(BeNil())
})

// cleanup
deleteRuleOptions := &contextbasedrestrictionsv1.DeleteRuleOptions{
RuleID: rule.ID,
TransactionID: getTransactionID(),
}

response, err = contextBasedRestrictionsService.DeleteRule(deleteRuleOptions)

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(204))
})
})

Describe(`ListRules - List rules with 'missing required AccountID parameter' error`, func() {
BeforeEach(func() {
shouldSkipTest()
Expand Down
10 changes: 10 additions & 0 deletions contextbasedrestrictionsv1/context_based_restrictions_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,6 +2054,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
Expect(req.URL.Query()["service_instance"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_type"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_group_id"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["zone_id"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["enforcement_mode"]).To(Equal([]string{"enabled"}))
Expand Down Expand Up @@ -2081,6 +2082,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
listRulesOptionsModel.ServiceInstance = core.StringPtr("testString")
listRulesOptionsModel.ServiceName = core.StringPtr("testString")
listRulesOptionsModel.ServiceType = core.StringPtr("testString")
listRulesOptionsModel.ServiceGroupID = core.StringPtr("testString")
listRulesOptionsModel.ZoneID = core.StringPtr("testString")
listRulesOptionsModel.Sort = core.StringPtr("testString")
listRulesOptionsModel.EnforcementMode = core.StringPtr("enabled")
Expand Down Expand Up @@ -2125,6 +2127,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
Expect(req.URL.Query()["service_instance"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_type"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_group_id"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["zone_id"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["enforcement_mode"]).To(Equal([]string{"enabled"}))
Expand Down Expand Up @@ -2157,6 +2160,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
listRulesOptionsModel.ServiceInstance = core.StringPtr("testString")
listRulesOptionsModel.ServiceName = core.StringPtr("testString")
listRulesOptionsModel.ServiceType = core.StringPtr("testString")
listRulesOptionsModel.ServiceGroupID = core.StringPtr("testString")
listRulesOptionsModel.ZoneID = core.StringPtr("testString")
listRulesOptionsModel.Sort = core.StringPtr("testString")
listRulesOptionsModel.EnforcementMode = core.StringPtr("enabled")
Expand Down Expand Up @@ -2207,6 +2211,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
Expect(req.URL.Query()["service_instance"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_name"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_type"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["service_group_id"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["zone_id"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["sort"]).To(Equal([]string{"testString"}))
Expect(req.URL.Query()["enforcement_mode"]).To(Equal([]string{"enabled"}))
Expand Down Expand Up @@ -2241,6 +2246,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
listRulesOptionsModel.ServiceInstance = core.StringPtr("testString")
listRulesOptionsModel.ServiceName = core.StringPtr("testString")
listRulesOptionsModel.ServiceType = core.StringPtr("testString")
listRulesOptionsModel.ServiceGroupID = core.StringPtr("testString")
listRulesOptionsModel.ZoneID = core.StringPtr("testString")
listRulesOptionsModel.Sort = core.StringPtr("testString")
listRulesOptionsModel.EnforcementMode = core.StringPtr("enabled")
Expand Down Expand Up @@ -2272,6 +2278,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
listRulesOptionsModel.ServiceInstance = core.StringPtr("testString")
listRulesOptionsModel.ServiceName = core.StringPtr("testString")
listRulesOptionsModel.ServiceType = core.StringPtr("testString")
listRulesOptionsModel.ServiceGroupID = core.StringPtr("testString")
listRulesOptionsModel.ZoneID = core.StringPtr("testString")
listRulesOptionsModel.Sort = core.StringPtr("testString")
listRulesOptionsModel.EnforcementMode = core.StringPtr("enabled")
Expand Down Expand Up @@ -2324,6 +2331,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
listRulesOptionsModel.ServiceInstance = core.StringPtr("testString")
listRulesOptionsModel.ServiceName = core.StringPtr("testString")
listRulesOptionsModel.ServiceType = core.StringPtr("testString")
listRulesOptionsModel.ServiceGroupID = core.StringPtr("testString")
listRulesOptionsModel.ZoneID = core.StringPtr("testString")
listRulesOptionsModel.Sort = core.StringPtr("testString")
listRulesOptionsModel.EnforcementMode = core.StringPtr("enabled")
Expand Down Expand Up @@ -3815,6 +3823,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
listRulesOptionsModel.SetServiceInstance("testString")
listRulesOptionsModel.SetServiceName("testString")
listRulesOptionsModel.SetServiceType("testString")
listRulesOptionsModel.SetServiceGroupID("testString")
listRulesOptionsModel.SetZoneID("testString")
listRulesOptionsModel.SetSort("testString")
listRulesOptionsModel.SetEnforcementMode("enabled")
Expand All @@ -3829,6 +3838,7 @@ var _ = Describe(`ContextBasedRestrictionsV1`, func() {
Expect(listRulesOptionsModel.ServiceInstance).To(Equal(core.StringPtr("testString")))
Expect(listRulesOptionsModel.ServiceName).To(Equal(core.StringPtr("testString")))
Expect(listRulesOptionsModel.ServiceType).To(Equal(core.StringPtr("testString")))
Expect(listRulesOptionsModel.ServiceGroupID).To(Equal(core.StringPtr("testString")))
Expect(listRulesOptionsModel.ZoneID).To(Equal(core.StringPtr("testString")))
Expect(listRulesOptionsModel.Sort).To(Equal(core.StringPtr("testString")))
Expect(listRulesOptionsModel.EnforcementMode).To(Equal(core.StringPtr("enabled")))
Expand Down

0 comments on commit 52e480a

Please sign in to comment.