github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v3/extensions/trusts/testing/fixtures.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  
     8  	"github.com/huaweicloud/golangsdk/openstack/identity/v3/tokens"
     9  	"github.com/huaweicloud/golangsdk/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) {
    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, `{
    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  }`)
    66  	})
    67  }