blob: 205361424068ff34d58a352a67d0210507007fa2 [file] [log] [blame]
Jamie Hannafordc21ffb92014-10-30 11:46:31 +01001// +build acceptance identity
Ash Wilsonf4aee1e2014-10-03 15:25:13 -04002
3package v2
4
5import (
6 "testing"
7
Joe Topjian918f5732016-08-15 08:47:08 -06008 "github.com/gophercloud/gophercloud/acceptance/clients"
Joe Topjian66a046c2017-01-19 22:07:26 -07009 "github.com/gophercloud/gophercloud/acceptance/tools"
Joe Topjian918f5732016-08-15 08:47:08 -060010 "github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040011)
12
Joe Topjian918f5732016-08-15 08:47:08 -060013func TestTenantsList(t *testing.T) {
14 client, err := clients.NewIdentityV2Client()
15 if err != nil {
16 t.Fatalf("Unable to obtain an identity client: %v")
17 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040018
Joe Topjian918f5732016-08-15 08:47:08 -060019 allPages, err := tenants.List(client, nil).AllPages()
20 if err != nil {
21 t.Fatalf("Unable to list tenants: %v", err)
22 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040023
Joe Topjian918f5732016-08-15 08:47:08 -060024 allTenants, err := tenants.ExtractTenants(allPages)
25 if err != nil {
26 t.Fatalf("Unable to extract tenants: %v", err)
27 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040028
Joe Topjian918f5732016-08-15 08:47:08 -060029 for _, tenant := range allTenants {
Joe Topjian66a046c2017-01-19 22:07:26 -070030 tools.PrintResource(t, tenant)
Joe Topjian918f5732016-08-15 08:47:08 -060031 }
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040032}