Joe Topjian | 7a0f3e5 | 2016-08-22 20:26:34 -0600 | [diff] [blame] | 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", |
Joe Topjian | 176266d | 2016-11-07 14:45:46 -0700 | [diff] [blame] | 15 | StorageURL: "http://127.0.0.1:8080/v1/AUTH_test/", |
Joe Topjian | 7a0f3e5 | 2016-08-22 20:26:34 -0600 | [diff] [blame] | 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 | } |