Always set error on response in token create (#109) (#92)
If there was a network error, http response will be nil
but error needs to be propogated out.
diff --git a/openstack/testing/client_test.go b/openstack/testing/client_test.go
index 570b3a0..3fe768f 100644
--- a/openstack/testing/client_test.go
+++ b/openstack/testing/client_test.go
@@ -52,7 +52,7 @@
Username: "me",
Password: "secret",
DomainName: "default",
- TenantName: "project",
+ TenantName: "project",
IdentityEndpoint: th.Endpoint(),
}
client, err := openstack.AuthenticatedClient(options)
@@ -291,3 +291,25 @@
th.AssertNoErr(t, err)
th.CheckEquals(t, "http://localhost:35357/", sc.Endpoint)
}
+
+func testAuthenticatedClientFails(t *testing.T, endpoint string) {
+ options := gophercloud.AuthOptions{
+ Username: "me",
+ Password: "secret",
+ DomainName: "default",
+ TenantName: "project",
+ IdentityEndpoint: endpoint,
+ }
+ _, err := openstack.AuthenticatedClient(options)
+ if err == nil {
+ t.Fatal("expected error but call succeeded")
+ }
+}
+
+func TestAuthenticatedClientV3Fails(t *testing.T) {
+ testAuthenticatedClientFails(t, "http://bad-address.example.com/v3")
+}
+
+func TestAuthenticatedClientV2Fails(t *testing.T) {
+ testAuthenticatedClientFails(t, "http://bad-address.example.com/v2.0")
+}