Ash Wilson | 54ce2f4 | 2014-10-09 09:26:29 -0400 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
| 3 | package rackspace |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Ash Wilson | 54ce2f4 | 2014-10-09 09:26:29 -0400 | [diff] [blame] | 8 | "github.com/rackspace/gophercloud/rackspace" |
| 9 | ) |
| 10 | |
| 11 | func TestAuthenticatedClient(t *testing.T) { |
| 12 | // Obtain credentials from the environment. |
Jamie Hannaford | 390555a | 2014-10-22 17:04:03 +0200 | [diff] [blame] | 13 | ao, err := rackspace.AuthOptionsFromEnv() |
Ash Wilson | 54ce2f4 | 2014-10-09 09:26:29 -0400 | [diff] [blame] | 14 | if err != nil { |
| 15 | t.Fatalf("Unable to acquire credentials: %v", err) |
| 16 | } |
| 17 | |
| 18 | client, err := rackspace.AuthenticatedClient(ao) |
| 19 | if err != nil { |
| 20 | t.Fatalf("Unable to authenticate: %v", err) |
| 21 | } |
| 22 | |
| 23 | if client.TokenID == "" { |
| 24 | t.Errorf("No token ID assigned to the client") |
| 25 | } |
| 26 | |
| 27 | t.Logf("Client successfully acquired a token: %v", client.TokenID) |
| 28 | } |