Exemplo n.º 1
0
func TestList(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()

	mockListRulesResponse(t)

	count := 0

	err := defsecrules.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
		count++
		actual, err := defsecrules.ExtractDefaultRules(page)
		th.AssertNoErr(t, err)

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

		th.CheckDeepEquals(t, expected, actual)

		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, count)
}
Exemplo n.º 2
0
func TestDefSecRulesList(t *testing.T) {
	client, err := clients.NewComputeV2Client()
	if err != nil {
		t.Fatalf("Unable to create a compute client: %v", err)
	}

	allPages, err := dsr.List(client).AllPages()
	if err != nil {
		t.Fatalf("Unable to list default rules: %v", err)
	}

	allDefaultRules, err := dsr.ExtractDefaultRules(allPages)
	if err != nil {
		t.Fatalf("Unable to extract default rules: %v", err)
	}

	for _, defaultRule := range allDefaultRules {
		PrintDefaultRule(t, &defaultRule)
	}
}