Ash Wilson | 6425a41 | 2014-08-29 12:30:35 -0400 | [diff] [blame^] | 1 | package v3 |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/rackspace/gophercloud" |
| 9 | "github.com/rackspace/gophercloud/testhelper" |
| 10 | ) |
| 11 | |
| 12 | func TestAuthentication(t *testing.T) { |
| 13 | testhelper.SetupHTTP() |
| 14 | defer testhelper.TeardownHTTP() |
| 15 | |
| 16 | testhelper.Mux.HandleFunc("/v3/auth/tokens", func(w http.ResponseWriter, r *http.Request) { |
| 17 | w.Header().Add("X-Subject-Token", "aaaa1111") |
| 18 | |
| 19 | w.WriteHeader(http.StatusCreated) |
| 20 | fmt.Fprintf(w, `{ "token": { "expires_at": "2013-02-02T18:30:59.000000Z" } }`) |
| 21 | }) |
| 22 | |
| 23 | provider := &gophercloud.ProviderClient{ |
| 24 | IdentityEndpoint: testhelper.Endpoint(), |
| 25 | } |
| 26 | client := NewClient(provider) |
| 27 | |
| 28 | expected := testhelper.Endpoint() + "v3/" |
| 29 | if client.Endpoint != expected { |
| 30 | t.Errorf("Expected endpoint to be %s, but was %s", expected, client.Endpoint) |
| 31 | } |
| 32 | } |