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 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 8 | "github.com/gophercloud/gophercloud/acceptance/tools" |
| 9 | "github.com/gophercloud/gophercloud/rackspace" |
| 10 | th "github.com/gophercloud/gophercloud/testhelper" |
Ash Wilson | 54ce2f4 | 2014-10-09 09:26:29 -0400 | [diff] [blame] | 11 | ) |
| 12 | |
| 13 | func TestAuthenticatedClient(t *testing.T) { |
| 14 | // Obtain credentials from the environment. |
Jamie Hannaford | 390555a | 2014-10-22 17:04:03 +0200 | [diff] [blame] | 15 | ao, err := rackspace.AuthOptionsFromEnv() |
Ash Wilson | a6ddde7 | 2014-10-22 15:26:42 -0400 | [diff] [blame] | 16 | th.AssertNoErr(t, err) |
Ash Wilson | 54ce2f4 | 2014-10-09 09:26:29 -0400 | [diff] [blame] | 17 | |
Ash Wilson | a6ddde7 | 2014-10-22 15:26:42 -0400 | [diff] [blame] | 18 | client, err := rackspace.AuthenticatedClient(tools.OnlyRS(ao)) |
Ash Wilson | 54ce2f4 | 2014-10-09 09:26:29 -0400 | [diff] [blame] | 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 | } |