blob: 73b1c886ffa8c1ab13c9e043f69d0c84089eb8c4 [file] [log] [blame]
Ash Wilsonfddb98a2014-10-08 14:21:37 -04001package rackspace
2
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
8 "github.com/rackspace/gophercloud"
9 th "github.com/rackspace/gophercloud/testhelper"
10)
11
12func 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}