@@ -1,51 +0,0 @@
|
||||
package bootfromvolume
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
)
|
||||
|
||||
func TestCreateOpts(t *testing.T) {
|
||||
base := servers.CreateOpts{
|
||||
Name: "createdserver",
|
||||
ImageRef: "asdfasdfasdf",
|
||||
FlavorRef: "performance1-1",
|
||||
}
|
||||
|
||||
ext := CreateOptsExt{
|
||||
CreateOptsBuilder: base,
|
||||
BlockDevice: []BlockDevice{
|
||||
BlockDevice{
|
||||
UUID: "123456",
|
||||
SourceType: Image,
|
||||
DestinationType: "volume",
|
||||
VolumeSize: 10,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expected := `
|
||||
{
|
||||
"server": {
|
||||
"name": "createdserver",
|
||||
"imageRef": "asdfasdfasdf",
|
||||
"flavorRef": "performance1-1",
|
||||
"block_device_mapping_v2":[
|
||||
{
|
||||
"uuid":"123456",
|
||||
"source_type":"image",
|
||||
"destination_type":"volume",
|
||||
"boot_index": "0",
|
||||
"delete_on_termination": "false",
|
||||
"volume_size": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
`
|
||||
actual, err := ext.ToServerCreateMap()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckJSONEquals(t, expected, actual)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package bootfromvolume
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestCreateURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-volumes_boot", createURL(c))
|
||||
}
|
||||
@@ -1,100 +0,0 @@
|
||||
package defsecrules
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/secgroups"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
const ruleID = "{ruleID}"
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockListRulesResponse(t)
|
||||
|
||||
count := 0
|
||||
|
||||
err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractDefaultRules(page)
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := []DefaultRule{
|
||||
DefaultRule{
|
||||
FromPort: 80,
|
||||
ID: ruleID,
|
||||
IPProtocol: "TCP",
|
||||
IPRange: secgroups.IPRange{CIDR: "10.10.10.0/24"},
|
||||
ToPort: 80,
|
||||
},
|
||||
}
|
||||
|
||||
th.CheckDeepEquals(t, expected, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
|
||||
th.AssertNoErr(t, err)
|
||||
th.AssertEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockCreateRuleResponse(t)
|
||||
|
||||
opts := CreateOpts{
|
||||
IPProtocol: "TCP",
|
||||
FromPort: 80,
|
||||
ToPort: 80,
|
||||
CIDR: "10.10.12.0/24",
|
||||
}
|
||||
|
||||
group, err := Create(client.ServiceClient(), opts).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &DefaultRule{
|
||||
ID: ruleID,
|
||||
FromPort: 80,
|
||||
ToPort: 80,
|
||||
IPProtocol: "TCP",
|
||||
IPRange: secgroups.IPRange{CIDR: "10.10.12.0/24"},
|
||||
}
|
||||
th.AssertDeepEquals(t, expected, group)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockGetRuleResponse(t, ruleID)
|
||||
|
||||
group, err := Get(client.ServiceClient(), ruleID).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &DefaultRule{
|
||||
ID: ruleID,
|
||||
FromPort: 80,
|
||||
ToPort: 80,
|
||||
IPProtocol: "TCP",
|
||||
IPRange: secgroups.IPRange{CIDR: "10.10.12.0/24"},
|
||||
}
|
||||
|
||||
th.AssertDeepEquals(t, expected, group)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockDeleteRuleResponse(t, ruleID)
|
||||
|
||||
err := Delete(client.ServiceClient(), ruleID).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
96
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/delegate_test.go
generated
vendored
96
vendor/github.com/rackspace/gophercloud/openstack/compute/v2/extensions/delegate_test.go
generated
vendored
@@ -1,96 +0,0 @@
|
||||
package extensions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
common "github.com/rackspace/gophercloud/openstack/common/extensions"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
th.Mux.HandleFunc("/extensions", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"extensions": [
|
||||
{
|
||||
"updated": "2013-01-20T00:00:00-00:00",
|
||||
"name": "Neutron Service Type Management",
|
||||
"links": [],
|
||||
"namespace": "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
|
||||
"alias": "service-type",
|
||||
"description": "API for retrieving service providers for Neutron advanced services"
|
||||
}
|
||||
]
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
count := 0
|
||||
List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractExtensions(page)
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := []common.Extension{
|
||||
common.Extension{
|
||||
Updated: "2013-01-20T00:00:00-00:00",
|
||||
Name: "Neutron Service Type Management",
|
||||
Links: []interface{}{},
|
||||
Namespace: "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
|
||||
Alias: "service-type",
|
||||
Description: "API for retrieving service providers for Neutron advanced services",
|
||||
},
|
||||
}
|
||||
th.AssertDeepEquals(t, expected, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
th.CheckEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
th.Mux.HandleFunc("/extensions/agent", func(w http.ResponseWriter, r *http.Request) {
|
||||
th.TestMethod(t, r, "GET")
|
||||
th.TestHeader(t, r, "X-Auth-Token", client.TokenID)
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
fmt.Fprintf(w, `
|
||||
{
|
||||
"extension": {
|
||||
"updated": "2013-02-03T10:00:00-00:00",
|
||||
"name": "agent",
|
||||
"links": [],
|
||||
"namespace": "http://docs.openstack.org/ext/agent/api/v2.0",
|
||||
"alias": "agent",
|
||||
"description": "The agent management extension."
|
||||
}
|
||||
}
|
||||
`)
|
||||
})
|
||||
|
||||
ext, err := Get(client.ServiceClient(), "agent").Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
th.AssertEquals(t, ext.Updated, "2013-02-03T10:00:00-00:00")
|
||||
th.AssertEquals(t, ext.Name, "agent")
|
||||
th.AssertEquals(t, ext.Namespace, "http://docs.openstack.org/ext/agent/api/v2.0")
|
||||
th.AssertEquals(t, ext.Alias, "agent")
|
||||
th.AssertEquals(t, ext.Description, "The agent management extension.")
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package diskconfig
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
)
|
||||
|
||||
func TestCreateOpts(t *testing.T) {
|
||||
base := servers.CreateOpts{
|
||||
Name: "createdserver",
|
||||
ImageRef: "asdfasdfasdf",
|
||||
FlavorRef: "performance1-1",
|
||||
}
|
||||
|
||||
ext := CreateOptsExt{
|
||||
CreateOptsBuilder: base,
|
||||
DiskConfig: Manual,
|
||||
}
|
||||
|
||||
expected := `
|
||||
{
|
||||
"server": {
|
||||
"name": "createdserver",
|
||||
"imageRef": "asdfasdfasdf",
|
||||
"flavorRef": "performance1-1",
|
||||
"OS-DCF:diskConfig": "MANUAL"
|
||||
}
|
||||
}
|
||||
`
|
||||
actual, err := ext.ToServerCreateMap()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckJSONEquals(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestRebuildOpts(t *testing.T) {
|
||||
base := servers.RebuildOpts{
|
||||
Name: "rebuiltserver",
|
||||
AdminPass: "swordfish",
|
||||
ImageID: "asdfasdfasdf",
|
||||
}
|
||||
|
||||
ext := RebuildOptsExt{
|
||||
RebuildOptsBuilder: base,
|
||||
DiskConfig: Auto,
|
||||
}
|
||||
|
||||
actual, err := ext.ToServerRebuildMap()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := `
|
||||
{
|
||||
"rebuild": {
|
||||
"name": "rebuiltserver",
|
||||
"imageRef": "asdfasdfasdf",
|
||||
"adminPass": "swordfish",
|
||||
"OS-DCF:diskConfig": "AUTO"
|
||||
}
|
||||
}
|
||||
`
|
||||
th.CheckJSONEquals(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestResizeOpts(t *testing.T) {
|
||||
base := servers.ResizeOpts{
|
||||
FlavorRef: "performance1-8",
|
||||
}
|
||||
|
||||
ext := ResizeOptsExt{
|
||||
ResizeOptsBuilder: base,
|
||||
DiskConfig: Auto,
|
||||
}
|
||||
|
||||
actual, err := ext.ToServerResizeMap()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := `
|
||||
{
|
||||
"resize": {
|
||||
"flavorRef": "performance1-8",
|
||||
"OS-DCF:diskConfig": "AUTO"
|
||||
}
|
||||
}
|
||||
`
|
||||
th.CheckJSONEquals(t, expected, actual)
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package diskconfig
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/openstack/compute/v2/servers"
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestExtractGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
servers.HandleServerGetSuccessfully(t)
|
||||
|
||||
config, err := ExtractGet(servers.Get(client.ServiceClient(), "1234asdf"))
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, Manual, *config)
|
||||
}
|
||||
|
||||
func TestExtractUpdate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
servers.HandleServerUpdateSuccessfully(t)
|
||||
|
||||
r := servers.Update(client.ServiceClient(), "1234asdf", servers.UpdateOpts{
|
||||
Name: "new-name",
|
||||
})
|
||||
config, err := ExtractUpdate(r)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, Manual, *config)
|
||||
}
|
||||
|
||||
func TestExtractRebuild(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
servers.HandleRebuildSuccessfully(t, servers.SingleServerBody)
|
||||
|
||||
r := servers.Rebuild(client.ServiceClient(), "1234asdf", servers.RebuildOpts{
|
||||
Name: "new-name",
|
||||
AdminPass: "swordfish",
|
||||
ImageID: "http://104.130.131.164:8774/fcad67a6189847c4aecfa3c81a05783b/images/f90f6034-2570-4974-8351-6b49732ef2eb",
|
||||
AccessIPv4: "1.2.3.4",
|
||||
})
|
||||
config, err := ExtractRebuild(r)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, Manual, *config)
|
||||
}
|
||||
|
||||
func TestExtractList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
servers.HandleServerListSuccessfully(t)
|
||||
|
||||
pages := 0
|
||||
err := servers.List(client.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
|
||||
pages++
|
||||
|
||||
config, err := ExtractDiskConfig(page, 0)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, Manual, *config)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, pages, 1)
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package floatingip
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleListSuccessfully(t)
|
||||
|
||||
count := 0
|
||||
err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractFloatingIPs(page)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, ExpectedFloatingIPsSlice, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleCreateSuccessfully(t)
|
||||
|
||||
actual, err := Create(client.ServiceClient(), CreateOpts{
|
||||
Pool: "nova",
|
||||
}).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &CreatedFloatingIP, actual)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleGetSuccessfully(t)
|
||||
|
||||
actual, err := Get(client.ServiceClient(), "2").Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &SecondFloatingIP, actual)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleDeleteSuccessfully(t)
|
||||
|
||||
err := Delete(client.ServiceClient(), "1").ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
|
||||
func TestAssociate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleAssociateSuccessfully(t)
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
fip := "10.10.10.2"
|
||||
|
||||
err := Associate(client.ServiceClient(), serverId, fip).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
|
||||
func TestDisassociate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleDisassociateSuccessfully(t)
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
fip := "10.10.10.2"
|
||||
|
||||
err := Disassociate(client.ServiceClient(), serverId, fip).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package floatingip
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestListURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-floating-ips", listURL(c))
|
||||
}
|
||||
|
||||
func TestCreateURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-floating-ips", createURL(c))
|
||||
}
|
||||
|
||||
func TestGetURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
id := "1"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-floating-ips/"+id, getURL(c, id))
|
||||
}
|
||||
|
||||
func TestDeleteURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
id := "1"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-floating-ips/"+id, deleteURL(c, id))
|
||||
}
|
||||
|
||||
func TestAssociateURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/action", associateURL(c, serverId))
|
||||
}
|
||||
|
||||
func TestDisassociateURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/action", disassociateURL(c, serverId))
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
package keypairs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleListSuccessfully(t)
|
||||
|
||||
count := 0
|
||||
err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractKeyPairs(page)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, ExpectedKeyPairSlice, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleCreateSuccessfully(t)
|
||||
|
||||
actual, err := Create(client.ServiceClient(), CreateOpts{
|
||||
Name: "createdkey",
|
||||
}).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &CreatedKeyPair, actual)
|
||||
}
|
||||
|
||||
func TestImport(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleImportSuccessfully(t)
|
||||
|
||||
actual, err := Create(client.ServiceClient(), CreateOpts{
|
||||
Name: "importedkey",
|
||||
PublicKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGgB4rMYmIf+6A4l6Rr+o/6lHBQdW5aYd44bd8JttDCE/F/pNRr0lRE+PiqSPO8nDPHw0010JeMH9gYgnnFlyY3/OcJ02RhIPyyxYpv9FhY+2YiUkpwFOcLImyrxEsYXpD/0d3ac30bNH6Sw9JD9UZHYcpSxsIbECHw== Generated by Nova",
|
||||
}).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &ImportedKeyPair, actual)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleGetSuccessfully(t)
|
||||
|
||||
actual, err := Get(client.ServiceClient(), "firstkey").Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &FirstKeyPair, actual)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleDeleteSuccessfully(t)
|
||||
|
||||
err := Delete(client.ServiceClient(), "deletedkey").ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package keypairs
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestListURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-keypairs", listURL(c))
|
||||
}
|
||||
|
||||
func TestCreateURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-keypairs", createURL(c))
|
||||
}
|
||||
|
||||
func TestGetURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-keypairs/wat", getURL(c, "wat"))
|
||||
}
|
||||
|
||||
func TestDeleteURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-keypairs/wat", deleteURL(c, "wat"))
|
||||
}
|
||||
@@ -1,248 +0,0 @@
|
||||
package secgroups
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
const (
|
||||
serverID = "{serverID}"
|
||||
groupID = "{groupID}"
|
||||
ruleID = "{ruleID}"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockListGroupsResponse(t)
|
||||
|
||||
count := 0
|
||||
|
||||
err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractSecurityGroups(page)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to extract users: %v", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
expected := []SecurityGroup{
|
||||
SecurityGroup{
|
||||
ID: groupID,
|
||||
Description: "default",
|
||||
Name: "default",
|
||||
Rules: []Rule{},
|
||||
TenantID: "openstack",
|
||||
},
|
||||
}
|
||||
|
||||
th.CheckDeepEquals(t, expected, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
|
||||
th.AssertNoErr(t, err)
|
||||
th.AssertEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestListByServer(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockListGroupsByServerResponse(t, serverID)
|
||||
|
||||
count := 0
|
||||
|
||||
err := ListByServer(client.ServiceClient(), serverID).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractSecurityGroups(page)
|
||||
if err != nil {
|
||||
t.Errorf("Failed to extract users: %v", err)
|
||||
return false, err
|
||||
}
|
||||
|
||||
expected := []SecurityGroup{
|
||||
SecurityGroup{
|
||||
ID: groupID,
|
||||
Description: "default",
|
||||
Name: "default",
|
||||
Rules: []Rule{},
|
||||
TenantID: "openstack",
|
||||
},
|
||||
}
|
||||
|
||||
th.CheckDeepEquals(t, expected, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
|
||||
th.AssertNoErr(t, err)
|
||||
th.AssertEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockCreateGroupResponse(t)
|
||||
|
||||
opts := CreateOpts{
|
||||
Name: "test",
|
||||
Description: "something",
|
||||
}
|
||||
|
||||
group, err := Create(client.ServiceClient(), opts).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &SecurityGroup{
|
||||
ID: groupID,
|
||||
Name: "test",
|
||||
Description: "something",
|
||||
TenantID: "openstack",
|
||||
Rules: []Rule{},
|
||||
}
|
||||
th.AssertDeepEquals(t, expected, group)
|
||||
}
|
||||
|
||||
func TestUpdate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockUpdateGroupResponse(t, groupID)
|
||||
|
||||
opts := UpdateOpts{
|
||||
Name: "new_name",
|
||||
Description: "new_desc",
|
||||
}
|
||||
|
||||
group, err := Update(client.ServiceClient(), groupID, opts).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &SecurityGroup{
|
||||
ID: groupID,
|
||||
Name: "new_name",
|
||||
Description: "something",
|
||||
TenantID: "openstack",
|
||||
Rules: []Rule{},
|
||||
}
|
||||
th.AssertDeepEquals(t, expected, group)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockGetGroupsResponse(t, groupID)
|
||||
|
||||
group, err := Get(client.ServiceClient(), groupID).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &SecurityGroup{
|
||||
ID: groupID,
|
||||
Description: "default",
|
||||
Name: "default",
|
||||
TenantID: "openstack",
|
||||
Rules: []Rule{
|
||||
Rule{
|
||||
FromPort: 80,
|
||||
ToPort: 85,
|
||||
IPProtocol: "TCP",
|
||||
IPRange: IPRange{CIDR: "0.0.0.0"},
|
||||
Group: Group{TenantID: "openstack", Name: "default"},
|
||||
ParentGroupID: groupID,
|
||||
ID: ruleID,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
th.AssertDeepEquals(t, expected, group)
|
||||
}
|
||||
|
||||
func TestGetNumericID(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
numericGroupID := 12345
|
||||
|
||||
mockGetNumericIDGroupResponse(t, numericGroupID)
|
||||
|
||||
group, err := Get(client.ServiceClient(), "12345").Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &SecurityGroup{ID: "12345"}
|
||||
th.AssertDeepEquals(t, expected, group)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockDeleteGroupResponse(t, groupID)
|
||||
|
||||
err := Delete(client.ServiceClient(), groupID).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
|
||||
func TestAddRule(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockAddRuleResponse(t)
|
||||
|
||||
opts := CreateRuleOpts{
|
||||
ParentGroupID: groupID,
|
||||
FromPort: 22,
|
||||
ToPort: 22,
|
||||
IPProtocol: "TCP",
|
||||
CIDR: "0.0.0.0/0",
|
||||
}
|
||||
|
||||
rule, err := CreateRule(client.ServiceClient(), opts).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
|
||||
expected := &Rule{
|
||||
FromPort: 22,
|
||||
ToPort: 22,
|
||||
Group: Group{},
|
||||
IPProtocol: "TCP",
|
||||
ParentGroupID: groupID,
|
||||
IPRange: IPRange{CIDR: "0.0.0.0/0"},
|
||||
ID: ruleID,
|
||||
}
|
||||
|
||||
th.AssertDeepEquals(t, expected, rule)
|
||||
}
|
||||
|
||||
func TestDeleteRule(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockDeleteRuleResponse(t, ruleID)
|
||||
|
||||
err := DeleteRule(client.ServiceClient(), ruleID).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
|
||||
func TestAddServer(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockAddServerToGroupResponse(t, serverID)
|
||||
|
||||
err := AddServerToGroup(client.ServiceClient(), serverID, "test").ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
|
||||
func TestRemoveServer(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockRemoveServerFromGroupResponse(t, serverID)
|
||||
|
||||
err := RemoveServerFromGroup(client.ServiceClient(), serverID, "test").ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package startstop
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
const serverID = "{serverId}"
|
||||
|
||||
func TestStart(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockStartServerResponse(t, serverID)
|
||||
|
||||
err := Start(client.ServiceClient(), serverID).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
|
||||
func TestStop(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
|
||||
mockStopServerResponse(t, serverID)
|
||||
|
||||
err := Stop(client.ServiceClient(), serverID).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package tenantnetworks
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleListSuccessfully(t)
|
||||
|
||||
count := 0
|
||||
err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractNetworks(page)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, ExpectedNetworkSlice, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleGetSuccessfully(t)
|
||||
|
||||
actual, err := Get(client.ServiceClient(), "20c8acc0-f747-4d71-a389-46d078ebf000").Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &SecondNetwork, actual)
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package tenantnetworks
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestListURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-tenant-networks", listURL(c))
|
||||
}
|
||||
|
||||
func TestGetURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
id := "1"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"os-tenant-networks/"+id, getURL(c, id))
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package volumeattach
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rackspace/gophercloud/pagination"
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleListSuccessfully(t)
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
count := 0
|
||||
err := List(client.ServiceClient(), serverId).EachPage(func(page pagination.Page) (bool, error) {
|
||||
count++
|
||||
actual, err := ExtractVolumeAttachments(page)
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, ExpectedVolumeAttachmentSlice, actual)
|
||||
|
||||
return true, nil
|
||||
})
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckEquals(t, 1, count)
|
||||
}
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleCreateSuccessfully(t)
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
actual, err := Create(client.ServiceClient(), serverId, CreateOpts{
|
||||
Device: "/dev/vdc",
|
||||
VolumeID: "a26887c6-c47b-4654-abb5-dfadf7d3f804",
|
||||
}).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &CreatedVolumeAttachment, actual)
|
||||
}
|
||||
|
||||
func TestGet(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleGetSuccessfully(t)
|
||||
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
actual, err := Get(client.ServiceClient(), serverId, aId).Extract()
|
||||
th.AssertNoErr(t, err)
|
||||
th.CheckDeepEquals(t, &SecondVolumeAttachment, actual)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
HandleDeleteSuccessfully(t)
|
||||
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
err := Delete(client.ServiceClient(), serverId, aId).ExtractErr()
|
||||
th.AssertNoErr(t, err)
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package volumeattach
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
th "github.com/rackspace/gophercloud/testhelper"
|
||||
"github.com/rackspace/gophercloud/testhelper/client"
|
||||
)
|
||||
|
||||
func TestListURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/os-volume_attachments", listURL(c, serverId))
|
||||
}
|
||||
|
||||
func TestCreateURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/os-volume_attachments", createURL(c, serverId))
|
||||
}
|
||||
|
||||
func TestGetURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/os-volume_attachments/"+aId, getURL(c, serverId, aId))
|
||||
}
|
||||
|
||||
func TestDeleteURL(t *testing.T) {
|
||||
th.SetupHTTP()
|
||||
defer th.TeardownHTTP()
|
||||
c := client.ServiceClient()
|
||||
serverId := "4d8c3732-a248-40ed-bebc-539a6ffd25c0"
|
||||
aId := "a26887c6-c47b-4654-abb5-dfadf7d3f804"
|
||||
|
||||
th.CheckEquals(t, c.Endpoint+"servers/"+serverId+"/os-volume_attachments/"+aId, deleteURL(c, serverId, aId))
|
||||
}
|
||||
Reference in New Issue
Block a user