blob: e3115264b0bc14f2a2e5eb4190211dbebb31d47e [file] [log] [blame]
jrperritt0bc55782016-07-27 13:50:14 -05001package testing
2
3import (
4 "fmt"
5 "net/http"
6 "testing"
7
jrperritt0bc55782016-07-27 13:50:14 -05008 "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.
13func HandleCreateTokenWithTrustID(t *testing.T, options tokens.AuthOptionsBuilder, requestJSON string) {
jrperritt0bc55782016-07-27 13:50:14 -050014 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, `{
jrperrittc8834c12016-08-03 16:06:16 -050022 "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}`)
jrperritt0bc55782016-07-27 13:50:14 -050066 })
jrperritt0bc55782016-07-27 13:50:14 -050067}