Backpedal in the acceptance tests.
diff --git a/acceptance/rackspace/client_test.go b/acceptance/rackspace/client_test.go
index 825e3ac..2874531 100644
--- a/acceptance/rackspace/client_test.go
+++ b/acceptance/rackspace/client_test.go
@@ -6,16 +6,15 @@
"testing"
"github.com/rackspace/gophercloud/rackspace"
+ th "github.com/rackspace/gophercloud/testhelper"
)
func TestAuthenticatedClient(t *testing.T) {
// Obtain credentials from the environment.
ao, err := rackspace.AuthOptionsFromEnv()
- if err != nil {
- t.Fatalf("Unable to acquire credentials: %v", err)
- }
+ th.AssertNoErr(t, err)
- client, err := rackspace.AuthenticatedClient(ao)
+ client, err := rackspace.AuthenticatedClient(tools.OnlyRS(ao))
if err != nil {
t.Fatalf("Unable to authenticate: %v", err)
}
diff --git a/acceptance/rackspace/compute/v2/compute_test.go b/acceptance/rackspace/compute/v2/compute_test.go
index 3419c10..3d628f2 100644
--- a/acceptance/rackspace/compute/v2/compute_test.go
+++ b/acceptance/rackspace/compute/v2/compute_test.go
@@ -12,17 +12,18 @@
func newClient() (*gophercloud.ServiceClient, error) {
// Obtain credentials from the environment.
- options := gophercloud.AuthOptions{
- Username: os.Getenv("RS_USERNAME"),
- APIKey: os.Getenv("RS_APIKEY"),
+ options, err := rackspace.AuthOptionsFromEnv()
+ if err != nil {
+ return err
}
+ options = tools.OnlyRS(options)
region := os.Getenv("RS_REGION")
if options.Username == "" {
return nil, errors.New("Please provide a Rackspace username as RS_USERNAME.")
}
if options.APIKey == "" {
- return nil, errors.New("Please provide a Rackspace API key as RS_APIKEY.")
+ return nil, errors.New("Please provide a Rackspace API key as RS_API_KEY.")
}
if region == "" {
return nil, errors.New("Please provide a Rackspace region as RS_REGION.")
diff --git a/acceptance/rackspace/identity/v2/identity_test.go b/acceptance/rackspace/identity/v2/identity_test.go
index 019a9e6..576e40f 100644
--- a/acceptance/rackspace/identity/v2/identity_test.go
+++ b/acceptance/rackspace/identity/v2/identity_test.go
@@ -3,7 +3,6 @@
package v2
import (
- "os"
"testing"
"github.com/rackspace/gophercloud"
@@ -13,16 +12,15 @@
func rackspaceAuthOptions(t *testing.T) gophercloud.AuthOptions {
// Obtain credentials from the environment.
- options := gophercloud.AuthOptions{
- Username: os.Getenv("RS_USERNAME"),
- APIKey: os.Getenv("RS_APIKEY"),
- }
+ options, err := rackspace.AuthOptionsFromEnv()
+ th.AssertNoErr(t, err)
+ options = tools.OnlyRS(options)
if options.Username == "" {
t.Fatal("Please provide a Rackspace username as RS_USERNAME.")
}
if options.APIKey == "" {
- t.Fatal("Please provide a Rackspace API key as RS_APIKEY.")
+ t.Fatal("Please provide a Rackspace API key as RS_API_KEY.")
}
return options
diff --git a/acceptance/rackspace/objectstorage/v1/common.go b/acceptance/rackspace/objectstorage/v1/common.go
index 6422203..59457c1 100644
--- a/acceptance/rackspace/objectstorage/v1/common.go
+++ b/acceptance/rackspace/objectstorage/v1/common.go
@@ -13,16 +13,15 @@
func rackspaceAuthOptions(t *testing.T) gophercloud.AuthOptions {
// Obtain credentials from the environment.
- options := gophercloud.AuthOptions{
- Username: os.Getenv("RS_USERNAME"),
- APIKey: os.Getenv("RS_APIKEY"),
- }
+ options, err := rackspace.AuthOptionsFromEnv()
+ th.AssertNoErr(t, err)
+ options = tools.OnlyRS(options)
if options.Username == "" {
t.Fatal("Please provide a Rackspace username as RS_USERNAME.")
}
if options.APIKey == "" {
- t.Fatal("Please provide a Rackspace API key as RS_APIKEY.")
+ t.Fatal("Please provide a Rackspace API key as RS_API_KEY.")
}
return options
diff --git a/acceptance/tools/tools.go b/acceptance/tools/tools.go
index ffade12..b3f3ea7 100644
--- a/acceptance/tools/tools.go
+++ b/acceptance/tools/tools.go
@@ -5,12 +5,34 @@
import (
"crypto/rand"
"errors"
+ "os"
"time"
+
+ "github.com/rackspace/gophercloud"
)
// ErrTimeout is returned if WaitFor takes longer than 300 second to happen.
var ErrTimeout = errors.New("Timed out")
+// OnlyRS overrides the default Gophercloud behavior of using OS_-prefixed environment variables
+// if RS_ variables aren't present. Otherwise, they'll stomp over each other here in the acceptance
+// tests, where you need to have both defined.
+func OnlyRS(original gophercloud.AuthOptions) gophercloud.AuthOptions {
+ if os.Getenv("RS_AUTH_URL") == "" {
+ original.IdentityEndpoint = ""
+ }
+ if os.Getenv("RS_USERNAME") == "" {
+ original.Username = ""
+ }
+ if os.Getenv("RS_PASSWORD") == "" {
+ original.Password = ""
+ }
+ if os.Getenv("RS_API_KEY") == "" {
+ original.APIKey = ""
+ }
+ return original
+}
+
// WaitFor polls a predicate function once per second to wait for a certain state to arrive.
func WaitFor(predicate func() (bool, error)) error {
for i := 0; i < 300; i++ {