blob: baade1e8e83ac092be1a1caa3d3e8069bf12a7e1 [file] [log] [blame]
Joe Topjian7c8dd022016-09-01 12:02:04 -06001// +build acceptance networking extensions
Jamie Hannaford4721abc2014-09-16 16:29:04 +02002
3package v2
4
5import (
6 "testing"
7
Joe Topjian7c8dd022016-09-01 12:02:04 -06008 "github.com/gophercloud/gophercloud/acceptance/clients"
9 "github.com/gophercloud/gophercloud/acceptance/openstack"
10 "github.com/gophercloud/gophercloud/openstack/common/extensions"
Jamie Hannaford4721abc2014-09-16 16:29:04 +020011)
12
Joe Topjian7c8dd022016-09-01 12:02:04 -060013func TestExtensionsList(t *testing.T) {
14 client, err := clients.NewNetworkV2Client()
15 if err != nil {
16 t.Fatalf("Unable to create a network client: %v", err)
17 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020018
Joe Topjian7c8dd022016-09-01 12:02:04 -060019 allPages, err := extensions.List(client).AllPages()
20 if err != nil {
21 t.Fatalf("Unable to list extensions: %v", err)
22 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020023
Joe Topjian7c8dd022016-09-01 12:02:04 -060024 allExtensions, err := extensions.ExtractExtensions(allPages)
25 if err != nil {
26 t.Fatalf("Unable to extract extensions: %v", err)
27 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020028
Joe Topjian7c8dd022016-09-01 12:02:04 -060029 for _, extension := range allExtensions {
30 openstack.PrintExtension(t, &extension)
31 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020032}
33
Joe Topjian7c8dd022016-09-01 12:02:04 -060034func TestExtensionGet(t *testing.T) {
35 client, err := clients.NewNetworkV2Client()
36 if err != nil {
37 t.Fatalf("Unable to create a network client: %v", err)
38 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020039
Joe Topjian7c8dd022016-09-01 12:02:04 -060040 extension, err := extensions.Get(client, "router").Extract()
41 if err != nil {
42 t.Fatalf("Unable to get extension port-security: %v", err)
43 }
Jamie Hannaford4721abc2014-09-16 16:29:04 +020044
Joe Topjian7c8dd022016-09-01 12:02:04 -060045 openstack.PrintExtension(t, extension)
Jamie Hannaford4721abc2014-09-16 16:29:04 +020046}