Merge pull request #166 from maxlinc/flexible_auth

Allow acceptance tests to run with an API key or alternate authentication endpoint.  
diff --git a/acceptance/00-authentication.go b/acceptance/00-authentication.go
index 2374efb..6467203 100644
--- a/acceptance/00-authentication.go
+++ b/acceptance/00-authentication.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/01-authentication.go b/acceptance/01-authentication.go
index bcd3545..5cc9d38 100644
--- a/acceptance/01-authentication.go
+++ b/acceptance/01-authentication.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/02-list-servers.go b/acceptance/02-list-servers.go
index db33203..772852e 100644
--- a/acceptance/02-list-servers.go
+++ b/acceptance/02-list-servers.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/03-get-server-details.go b/acceptance/03-get-server-details.go
index ca00e5e..01140a9 100644
--- a/acceptance/03-get-server-details.go
+++ b/acceptance/03-get-server-details.go
@@ -1,9 +1,13 @@
+// +build acceptance,old
+
 package main
 
 import (
 	"flag"
 	"fmt"
 	"github.com/rackspace/gophercloud"
+	"os"
+	"github.com/racker/perigee"
 )
 
 var id = flag.String("i", "", "Server ID to get info on.  Defaults to first server in your account if unspecified.")
@@ -13,6 +17,7 @@
 func main() {
 	flag.Parse()
 
+	resultCode := 0
 	withIdentity(false, func(auth gophercloud.AccessProvider) {
 		withServerApi(auth, func(servers gophercloud.CloudServersProvider) {
 			var (
@@ -79,7 +84,26 @@
 				}
 			}
 		})
+
+		// Negative test -- We should absolutely never panic for a server that doesn't exist.
+		withServerApi(auth, func(servers gophercloud.CloudServersProvider) {
+			_, err := servers.ServerById(randomString("garbage", 32))
+			if err == nil {
+				fmt.Printf("Expected a 404 response when looking for a server known not to exist\n")
+				resultCode = 1
+			}
+			perigeeError, ok := err.(*perigee.UnexpectedResponseCodeError)
+			if !ok {
+				fmt.Printf("Unexpected error type\n")
+				resultCode = 1
+			} else {
+				if perigeeError.Actual != 404 {
+					fmt.Printf("Expected a 404 error code\n")
+				}
+			}
+		})
 	})
+	os.Exit(resultCode)
 }
 
 // locateAServer queries the set of servers owned by the user.  If at least one
diff --git a/acceptance/04-create-server.go b/acceptance/04-create-server.go
index ff2174e..03fd606 100644
--- a/acceptance/04-create-server.go
+++ b/acceptance/04-create-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/05-list-images.go b/acceptance/05-list-images.go
index 8cdd6c4..5ead18b 100644
--- a/acceptance/05-list-images.go
+++ b/acceptance/05-list-images.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/06-list-flavors.go b/acceptance/06-list-flavors.go
index 109d018..65db7da 100644
--- a/acceptance/06-list-flavors.go
+++ b/acceptance/06-list-flavors.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/07-change-admin-password.go b/acceptance/07-change-admin-password.go
index 6f078ee..880fbe8 100644
--- a/acceptance/07-change-admin-password.go
+++ b/acceptance/07-change-admin-password.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/08-reauthentication.go b/acceptance/08-reauthentication.go
index 1bcf4fc..c46f5bb 100644
--- a/acceptance/08-reauthentication.go
+++ b/acceptance/08-reauthentication.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/09-resize-server.go b/acceptance/09-resize-server.go
index 8582ad3..a2ef3c8 100644
--- a/acceptance/09-resize-server.go
+++ b/acceptance/09-resize-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/10-reboot-server.go b/acceptance/10-reboot-server.go
index eff9963..ba6215a 100644
--- a/acceptance/10-reboot-server.go
+++ b/acceptance/10-reboot-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/11-rescue-unrescue-server.go b/acceptance/11-rescue-unrescue-server.go
index 657c7c8..008ad9d 100644
--- a/acceptance/11-rescue-unrescue-server.go
+++ b/acceptance/11-rescue-unrescue-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/12-update-server.go b/acceptance/12-update-server.go
index 8b9e73f..c0191f1 100644
--- a/acceptance/12-update-server.go
+++ b/acceptance/12-update-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/13-rebuild-server.go b/acceptance/13-rebuild-server.go
index 48745a6..ae7e19f 100644
--- a/acceptance/13-rebuild-server.go
+++ b/acceptance/13-rebuild-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/14-list-addresses.go b/acceptance/14-list-addresses.go
index 705d72d..1d7d26b 100644
--- a/acceptance/14-list-addresses.go
+++ b/acceptance/14-list-addresses.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/15-list-keypairs.go b/acceptance/15-list-keypairs.go
index da526e2..1a617ed 100644
--- a/acceptance/15-list-keypairs.go
+++ b/acceptance/15-list-keypairs.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/16-create-delete-keypair.go b/acceptance/16-create-delete-keypair.go
index e292473..f59e51c 100644
--- a/acceptance/16-create-delete-keypair.go
+++ b/acceptance/16-create-delete-keypair.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/17-create-delete-image.go b/acceptance/17-create-delete-image.go
index 25d8c72..b3d80a3 100644
--- a/acceptance/17-create-delete-image.go
+++ b/acceptance/17-create-delete-image.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/18-osutil-authentication.go b/acceptance/18-osutil-authentication.go
index 936f376..01ff4e9 100644
--- a/acceptance/18-osutil-authentication.go
+++ b/acceptance/18-osutil-authentication.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/19-list-addresses-0.1.go b/acceptance/19-list-addresses-0.1.go
index 7df2ad5..d60557b 100644
--- a/acceptance/19-list-addresses-0.1.go
+++ b/acceptance/19-list-addresses-0.1.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/99-delete-server.go b/acceptance/99-delete-server.go
index 55b8798..3e38ba4 100644
--- a/acceptance/99-delete-server.go
+++ b/acceptance/99-delete-server.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/acceptance/libargs.go b/acceptance/libargs.go
index f30c9c9..cf234e7 100644
--- a/acceptance/libargs.go
+++ b/acceptance/libargs.go
@@ -1,3 +1,5 @@
+// +build acceptance,old
+
 package main
 
 import (
diff --git a/servers.go b/servers.go
index a00577e..425853b 100644
--- a/servers.go
+++ b/servers.go
@@ -86,6 +86,7 @@
 			MoreHeaders: map[string]string{
 				"X-Auth-Token": gsp.access.AuthToken(),
 			},
+			OkCodes: []int{200},
 		})
 	})