Jamie Hannaford | c21ffb9 | 2014-10-30 11:46:31 +0100 | [diff] [blame] | 1 | // +build acceptance identity |
Ash Wilson | e9a0089 | 2014-10-03 16:40:22 -0400 | [diff] [blame] | 2 | |
| 3 | package v2 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 8 | "github.com/gophercloud/gophercloud/acceptance/clients" |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 9 | "github.com/gophercloud/gophercloud/acceptance/tools" |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 10 | "github.com/gophercloud/gophercloud/openstack/identity/v2/extensions" |
Ash Wilson | e9a0089 | 2014-10-03 16:40:22 -0400 | [diff] [blame] | 11 | ) |
| 12 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 13 | func TestExtensionsList(t *testing.T) { |
| 14 | client, err := clients.NewIdentityV2Client() |
| 15 | if err != nil { |
| 16 | t.Fatalf("Unable to create an identity client: %v", err) |
| 17 | } |
Ash Wilson | e9a0089 | 2014-10-03 16:40:22 -0400 | [diff] [blame] | 18 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 19 | allPages, err := extensions.List(client).AllPages() |
| 20 | if err != nil { |
| 21 | t.Fatalf("Unable to list extensions: %v", err) |
| 22 | } |
Ash Wilson | e9a0089 | 2014-10-03 16:40:22 -0400 | [diff] [blame] | 23 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 24 | allExtensions, err := extensions.ExtractExtensions(allPages) |
| 25 | if err != nil { |
| 26 | t.Fatalf("Unable to extract extensions: %v", err) |
| 27 | } |
Ash Wilson | e9a0089 | 2014-10-03 16:40:22 -0400 | [diff] [blame] | 28 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 29 | for _, extension := range allExtensions { |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 30 | tools.PrintResource(t, extension) |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 31 | } |
Ash Wilson | e9a0089 | 2014-10-03 16:40:22 -0400 | [diff] [blame] | 32 | } |
Ash Wilson | 5872fea | 2014-10-03 16:53:01 -0400 | [diff] [blame] | 33 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 34 | func TestExtensionsGet(t *testing.T) { |
| 35 | client, err := clients.NewIdentityV2Client() |
| 36 | if err != nil { |
| 37 | t.Fatalf("Unable to create an identity client: %v", err) |
| 38 | } |
Ash Wilson | 5872fea | 2014-10-03 16:53:01 -0400 | [diff] [blame] | 39 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 40 | extension, err := extensions.Get(client, "OS-KSCRUD").Extract() |
| 41 | if err != nil { |
| 42 | t.Fatalf("Unable to get extension OS-KSCRUD: %v", err) |
| 43 | } |
Ash Wilson | 5872fea | 2014-10-03 16:53:01 -0400 | [diff] [blame] | 44 | |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 45 | tools.PrintResource(t, extension) |
Ash Wilson | 5872fea | 2014-10-03 16:53:01 -0400 | [diff] [blame] | 46 | } |