Ash Wilson | cde6812 | 2014-08-28 16:15:43 -0400 | [diff] [blame^] | 1 | package tokens |
| 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 TestCreateUserIDAndPassword(t *testing.T) { |
| 13 | setup() |
| 14 | defer teardown() |
| 15 | |
| 16 | client := gophercloud.ServiceClient{ |
| 17 | Endpoint: endpoint(), |
| 18 | Options: gophercloud.AuthOptions{UserID: "me", Password: "squirrel!"}, |
| 19 | } |
| 20 | |
| 21 | mux.HandleFunc("/auth/tokens", func(w http.ResponseWriter, r *http.Request) { |
| 22 | testhelper.TestMethod(t, r, "POST") |
| 23 | testhelper.TestHeader(t, r, "Content-Type", "application/json") |
| 24 | testhelper.TestHeader(t, r, "Accept", "application/json") |
| 25 | |
| 26 | testhelper.TestJSONRequest(t, r, ` |
| 27 | { |
| 28 | "auth": { |
| 29 | "identity": { |
| 30 | "methods": ["password"], |
| 31 | "password": { |
| 32 | "user": { "id": "me", "password": "squirrel!" } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | `) |
| 38 | |
| 39 | fmt.Fprintf(w, `{}`) |
| 40 | }) |
| 41 | |
| 42 | _, err := Create(&client, nil) |
| 43 | if err != nil { |
| 44 | t.Errorf("Create returned an error: %v", err) |
| 45 | } |
| 46 | } |