Example #1
0
func TestTokenValidate(t *testing.T) {
	client, err := clients.NewIdentityV2Client()
	if err != nil {
		t.Fatalf("Unable to obtain an identity client: %v", err)
	}

	authOptions, err := openstack.AuthOptionsFromEnv()
	if err != nil {
		t.Fatalf("Unable to obtain authentication options: %v", err)
	}

	result := tokens.Create(client, authOptions)
	token, err := result.ExtractToken()
	if err != nil {
		t.Fatalf("Unable to extract token: %v", err)
	}

	PrintToken(t, token)

	getResult := tokens.Get(client, token.ID)
	user, err := getResult.ExtractUser()
	if err != nil {
		t.Fatalf("Unable to extract user: %v", err)
	}

	PrintTokenUser(t, user)
}
func TestExtensionsGet(t *testing.T) {
	client, err := clients.NewIdentityV2Client()
	if err != nil {
		t.Fatalf("Unable to create an identity client: %v", err)
	}

	extension, err := extensions.Get(client, "OS-KSCRUD").Extract()
	if err != nil {
		t.Fatalf("Unable to get extension OS-KSCRUD: %v", err)
	}

	openstack.PrintExtension(t, extension)
}
func TestExtensionsList(t *testing.T) {
	client, err := clients.NewIdentityV2Client()
	if err != nil {
		t.Fatalf("Unable to create an identity client: %v", err)
	}

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

	allExtensions, err := extensions.ExtractExtensions(allPages)
	if err != nil {
		t.Fatalf("Unable to extract extensions: %v", err)
	}

	for _, extension := range allExtensions {
		openstack.PrintExtension(t, &extension)
	}
}
Example #4
0
func TestTenantsList(t *testing.T) {
	client, err := clients.NewIdentityV2Client()
	if err != nil {
		t.Fatalf("Unable to obtain an identity client: %v")
	}

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

	allTenants, err := tenants.ExtractTenants(allPages)
	if err != nil {
		t.Fatalf("Unable to extract tenants: %v", err)
	}

	for _, tenant := range allTenants {
		PrintTenant(t, &tenant)
	}
}
Example #5
0
func TestQuotasetGet(t *testing.T) {
	client, err := clients.NewComputeV2Client()
	if err != nil {
		t.Fatalf("Unable to create a compute client: %v", err)
	}

	identityClient, err := clients.NewIdentityV2Client()
	if err != nil {
		t.Fatalf("Unable to get a new identity client: %v", err)
	}

	tenantID, err := getTenantID(t, identityClient)
	if err != nil {
		t.Fatal(err)
	}

	quotaSet, err := quotasets.Get(client, tenantID).Extract()
	if err != nil {
		t.Fatal(err)
	}

	PrintQuotaSet(t, quotaSet)
}