blob: c6a2bdef415ca8f8db1b3437852e59917f6a9d38 [file] [log] [blame]
Jamie Hannafordc21ffb92014-10-30 11:46:31 +01001// +build acceptance identity
Ash Wilsone9a00892014-10-03 16:40:22 -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/extensions"
Ash Wilsone9a00892014-10-03 16:40:22 -040011)
12
Joe Topjian918f5732016-08-15 08:47:08 -060013func 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 Wilsone9a00892014-10-03 16:40:22 -040018
Joe Topjian918f5732016-08-15 08:47:08 -060019 allPages, err := extensions.List(client).AllPages()
20 if err != nil {
21 t.Fatalf("Unable to list extensions: %v", err)
22 }
Ash Wilsone9a00892014-10-03 16:40:22 -040023
Joe Topjian918f5732016-08-15 08:47:08 -060024 allExtensions, err := extensions.ExtractExtensions(allPages)
25 if err != nil {
26 t.Fatalf("Unable to extract extensions: %v", err)
27 }
Ash Wilsone9a00892014-10-03 16:40:22 -040028
Joe Topjian918f5732016-08-15 08:47:08 -060029 for _, extension := range allExtensions {
Joe Topjian66a046c2017-01-19 22:07:26 -070030 tools.PrintResource(t, extension)
Joe Topjian918f5732016-08-15 08:47:08 -060031 }
Ash Wilsone9a00892014-10-03 16:40:22 -040032}
Ash Wilson5872fea2014-10-03 16:53:01 -040033
Joe Topjian918f5732016-08-15 08:47:08 -060034func 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 Wilson5872fea2014-10-03 16:53:01 -040039
Joe Topjian918f5732016-08-15 08:47:08 -060040 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 Wilson5872fea2014-10-03 16:53:01 -040044
Joe Topjian66a046c2017-01-19 22:07:26 -070045 tools.PrintResource(t, extension)
Ash Wilson5872fea2014-10-03 16:53:01 -040046}