func TestDefSecRulesGet(t *testing.T) {
	client, err := clients.NewComputeV2Client()
	if err != nil {
		t.Fatalf("Unable to create a compute client: %v", err)
	}

	defaultRule, err := CreateDefaultRule(t, client)
	if err != nil {
		t.Fatalf("Unable to create default rule: %v", err)
	}
	defer DeleteDefaultRule(t, client, defaultRule)

	newDefaultRule, err := dsr.Get(client, defaultRule.ID).Extract()
	if err != nil {
		t.Fatalf("Unable to get default rule %s: %v", defaultRule.ID, err)
	}

	PrintDefaultRule(t, newDefaultRule)
}
Example #2
0
func TestGet(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	mockGetRuleResponse(t, ruleID)

	group, err := defsecrules.Get(client.ServiceClient(), ruleID).Extract()
	th.AssertNoErr(t, err)

	expected := &defsecrules.DefaultRule{
		ID:         ruleID,
		FromPort:   80,
		ToPort:     80,
		IPProtocol: "TCP",
		IPRange:    secgroups.IPRange{CIDR: "10.10.12.0/24"},
	}

	th.AssertDeepEquals(t, expected, group)
}