Add authentication acceptance test.
Before coding on the Authentication functionality of gophercloud, we
needed the acceptance test to know when we were finished.
Since the authentication test is written in Go, I had to adjust the
scripts/test-all.sh file to invoke Go programs directly.
diff --git a/acceptance/01-authentication.go b/acceptance/01-authentication.go
new file mode 100644
index 0000000..643ad48
--- /dev/null
+++ b/acceptance/01-authentication.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+ "os"
+ "fmt"
+ "github.com/rackspace/gophercloud"
+)
+
+func main() {
+ provider := os.Getenv("SDK_PROVIDER")
+ username := os.Getenv("SDK_USERNAME")
+ password := os.Getenv("SDK_PASSWORD")
+
+ if (provider == "") || (username == "") || (password == "") {
+ fmt.Fprintf(os.Stderr, "One or more of the following environment variables aren't set:\n")
+ fmt.Fprintf(os.Stderr, " SDK_PROVIDER=\"%s\"\n", provider)
+ fmt.Fprintf(os.Stderr, " SDK_USERNAME=\"%s\"\n", username)
+ fmt.Fprintf(os.Stderr, " SDK_PASSWORD=\"%s\"\n", password)
+ os.Exit(1)
+ }
+
+ _, err := gophercloud.Authenticate(
+ provider,
+ gophercloud.AuthOptions{
+ Username: username,
+ Password: password,
+ },
+ )
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/authenticate.go b/authenticate.go
new file mode 100644
index 0000000..19fabf6
--- /dev/null
+++ b/authenticate.go
@@ -0,0 +1,13 @@
+package gophercloud
+
+import (
+ "fmt"
+)
+
+type AuthOptions struct {
+ Username, Password, TenantId string
+}
+
+func Authenticate(provider string, options AuthOptions) (*int, error) {
+ return nil, fmt.Errorf("Not implemented.")
+}
diff --git a/package.go b/package.go
new file mode 100644
index 0000000..3b1939b
--- /dev/null
+++ b/package.go
@@ -0,0 +1,2 @@
+package gophercloud
+
diff --git a/scripts/test-all.sh b/scripts/test-all.sh
index e4afbd2..b78e606 100755
--- a/scripts/test-all.sh
+++ b/scripts/test-all.sh
@@ -10,12 +10,23 @@
# Locate the acceptance test / examples directory.
ACCEPTANCE=$(cd $SCRIPTS/../acceptance; pwd)
+# Go workspace path
+WS=$(cd $SCRIPTS/..; pwd)
+
+# In order to run Go code interactively, we need the GOPATH environment
+# to be set.
+if [ "x$GOPATH" == "x" ]; then
+ export GOPATH=$WS
+ echo "WARNING: You didn't have your GOPATH environment variable set."
+ echo " I'm assuming $GOPATH as its value."
+fi
+
# Run all acceptance tests sequentially.
# If any test fails, we fail fast.
-for T in $(ls -1 $ACCEPTANCE); do
- if [ -x $ACCEPTANCE/$T ]; then
- echo "$ACCEPTANCE/$T -quiet ..."
- if ! $ACCEPTANCE/$T -quiet ; then
+for T in $(ls -1 $ACCEPTANCE/[0-9][0-9]*.go); do
+ if ! [ -x $T ]; then
+ echo "go run $T -quiet ..."
+ if ! go run $T -quiet ; then
echo "- FAILED. Try re-running w/out the -quiet option to see output."
exit 1
fi