jrperritt | 0bc5578 | 2016-07-27 13:50:14 -0500 | [diff] [blame] | 1 | package testing |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | "testing" |
| 7 | |
jrperritt | 0bc5578 | 2016-07-27 13:50:14 -0500 | [diff] [blame] | 8 | "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens" |
| 9 | "github.com/gophercloud/gophercloud/testhelper" |
| 10 | ) |
| 11 | |
| 12 | // HandleCreateTokenWithTrustID verifies that providing certain AuthOptions and Scope results in an expected JSON structure. |
| 13 | func HandleCreateTokenWithTrustID(t *testing.T, options tokens.AuthOptionsBuilder, requestJSON string) { |
jrperritt | 0bc5578 | 2016-07-27 13:50:14 -0500 | [diff] [blame] | 14 | testhelper.Mux.HandleFunc("/auth/tokens", func(w http.ResponseWriter, r *http.Request) { |
| 15 | testhelper.TestMethod(t, r, "POST") |
| 16 | testhelper.TestHeader(t, r, "Content-Type", "application/json") |
| 17 | testhelper.TestHeader(t, r, "Accept", "application/json") |
| 18 | testhelper.TestJSONRequest(t, r, requestJSON) |
| 19 | |
| 20 | w.WriteHeader(http.StatusCreated) |
| 21 | fmt.Fprintf(w, `{ |
jrperritt | c8834c1 | 2016-08-03 16:06:16 -0500 | [diff] [blame] | 22 | "token": { |
| 23 | "expires_at": "2013-02-27T18:30:59.999999Z", |
| 24 | "issued_at": "2013-02-27T16:30:59.999999Z", |
| 25 | "methods": [ |
| 26 | "password" |
| 27 | ], |
| 28 | "OS-TRUST:trust": { |
| 29 | "id": "fe0aef", |
| 30 | "impersonation": false, |
| 31 | "redelegated_trust_id": "3ba234", |
| 32 | "redelegation_count": 2, |
| 33 | "links": { |
| 34 | "self": "http://example.com/identity/v3/trusts/fe0aef" |
| 35 | }, |
| 36 | "trustee_user": { |
| 37 | "id": "0ca8f6", |
| 38 | "links": { |
| 39 | "self": "http://example.com/identity/v3/users/0ca8f6" |
| 40 | } |
| 41 | }, |
| 42 | "trustor_user": { |
| 43 | "id": "bd263c", |
| 44 | "links": { |
| 45 | "self": "http://example.com/identity/v3/users/bd263c" |
| 46 | } |
| 47 | } |
| 48 | }, |
| 49 | "user": { |
| 50 | "domain": { |
| 51 | "id": "1789d1", |
| 52 | "links": { |
| 53 | "self": "http://example.com/identity/v3/domains/1789d1" |
| 54 | }, |
| 55 | "name": "example.com" |
| 56 | }, |
| 57 | "email": "joe@example.com", |
| 58 | "id": "0ca8f6", |
| 59 | "links": { |
| 60 | "self": "http://example.com/identity/v3/users/0ca8f6" |
| 61 | }, |
| 62 | "name": "Joe" |
| 63 | } |
| 64 | } |
| 65 | }`) |
jrperritt | 0bc5578 | 2016-07-27 13:50:14 -0500 | [diff] [blame] | 66 | }) |
jrperritt | 0bc5578 | 2016-07-27 13:50:14 -0500 | [diff] [blame] | 67 | } |