Ash Wilson | fddb98a | 2014-10-08 14:21:37 -0400 | [diff] [blame] | 1 | package rackspace |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/rackspace/gophercloud" |
| 9 | th "github.com/rackspace/gophercloud/testhelper" |
| 10 | ) |
| 11 | |
| 12 | func TestAuthenticatedClientV2(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
| 15 | |
| 16 | th.Mux.HandleFunc("/v2.0/tokens", func(w http.ResponseWriter, r *http.Request) { |
| 17 | fmt.Fprintf(w, ` |
| 18 | { |
| 19 | "access": { |
| 20 | "token": { |
| 21 | "id": "01234567890", |
| 22 | "expires": "2014-10-01T10:00:00.000000Z" |
| 23 | }, |
| 24 | "serviceCatalog": [] |
| 25 | } |
| 26 | } |
| 27 | `) |
| 28 | }) |
| 29 | |
| 30 | options := gophercloud.AuthOptions{ |
| 31 | Username: "me", |
| 32 | APIKey: "09876543210", |
| 33 | IdentityEndpoint: th.Endpoint() + "v2.0/", |
| 34 | } |
| 35 | client, err := AuthenticatedClient(options) |
| 36 | th.AssertNoErr(t, err) |
| 37 | th.CheckEquals(t, "01234567890", client.TokenID) |
| 38 | } |