+maxlinc - Add ApiKey authentication
diff --git a/acceptance/00-authentication.go b/acceptance/00-authentication.go
new file mode 100644
index 0000000..10ed022
--- /dev/null
+++ b/acceptance/00-authentication.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+ "github.com/rackspace/gophercloud"
+ "strings"
+ "fmt"
+ "os"
+)
+
+func main() {
+ provider, username, _, apiKey := getCredentials()
+
+ if !strings.Contains(provider, "rackspace") {
+ fmt.Fprintf(os.Stdout, "Skipping test because provider doesn't support API_KEYs\n")
+ return
+ }
+
+ _, err := gophercloud.Authenticate(
+ provider,
+ gophercloud.AuthOptions{
+ Username: username,
+ ApiKey: apiKey,
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/acceptance/01-authentication.go b/acceptance/01-authentication.go
index 91fc814..bcd3545 100644
--- a/acceptance/01-authentication.go
+++ b/acceptance/01-authentication.go
@@ -5,7 +5,7 @@
)
func main() {
- provider, username, password := getCredentials()
+ provider, username, password, _ := getCredentials()
_, err := gophercloud.Authenticate(
provider,
diff --git a/acceptance/libargs.go b/acceptance/libargs.go
index 23c55f1..bc34d86 100644
--- a/acceptance/libargs.go
+++ b/acceptance/libargs.go
@@ -11,10 +11,11 @@
// getCredentials will verify existence of needed credential information
// provided through environment variables. This function will not return
// if at least one piece of required information is missing.
-func getCredentials() (provider, username, password string) {
+func getCredentials() (provider, username, password, apiKey string) {
provider = os.Getenv("SDK_PROVIDER")
username = os.Getenv("SDK_USERNAME")
password = os.Getenv("SDK_PASSWORD")
+ apiKey = os.Getenv("SDK_API_KEY")
if (provider == "") || (username == "") || (password == "") {
fmt.Fprintf(os.Stderr, "One or more of the following environment variables aren't set:\n")
@@ -139,7 +140,7 @@
// withIdentity authenticates the user against the provider's identity service, and provides an
// accessor for additional services.
func withIdentity(ar bool, f func(gophercloud.AccessProvider)) {
- provider, username, password := getCredentials()
+ provider, username, password, _ := getCredentials()
acc, err := gophercloud.Authenticate(
provider,
gophercloud.AuthOptions{