github.com/gophercloud/gophercloud@v1.11.0/openstack/objectstorage/v1/swauth/testing/fixtures_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"fmt"
     5  	"net/http"
     6  	"testing"
     7  
     8  	"github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth"
     9  	th "github.com/gophercloud/gophercloud/testhelper"
    10  )
    11  
    12  // AuthResult is the expected result of AuthOutput
    13  var AuthResult = swauth.AuthResult{
    14  	Token:      "AUTH_tk6223e6071f8f4299aa334b48015484a1",
    15  	StorageURL: "http://127.0.0.1:8080/v1/AUTH_test/",
    16  }
    17  
    18  // HandleAuthSuccessfully configures the test server to respond to an Auth request.
    19  func HandleAuthSuccessfully(t *testing.T, authOpts swauth.AuthOpts) {
    20  	th.Mux.HandleFunc("/auth/v1.0", func(w http.ResponseWriter, r *http.Request) {
    21  		th.TestMethod(t, r, "GET")
    22  		th.TestHeader(t, r, "X-Auth-User", authOpts.User)
    23  		th.TestHeader(t, r, "X-Auth-Key", authOpts.Key)
    24  
    25  		w.Header().Add("X-Auth-Token", AuthResult.Token)
    26  		w.Header().Add("X-Storage-Url", AuthResult.StorageURL)
    27  		fmt.Fprintf(w, "")
    28  	})
    29  }