blob: 7a7f5e8fcde3334505d42c82be46a3f0f40099c5 [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
Krzysztof Szukiełojć24a29ce2017-05-07 14:24:02 +02008 "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/clients"
9 "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/tools"
10 "gerrit.mcp.mirantis.net/debian/gophercloud.git/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 {
Joe Topjian66a046c2017-01-19 22:07:26 -070030 tools.PrintResource(t, extension)
Joe Topjian7c8dd022016-09-01 12:02:04 -060031 }
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 Topjian66a046c2017-01-19 22:07:26 -070045 tools.PrintResource(t, extension)
Jamie Hannaford4721abc2014-09-16 16:29:04 +020046}