Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 1 | package tokens |
| 2 | |
| 3 | import ( |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 4 | "testing" |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 5 | |
| 6 | "github.com/rackspace/gophercloud" |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 7 | os "github.com/rackspace/gophercloud/openstack/identity/v2/tokens" |
| 8 | th "github.com/rackspace/gophercloud/testhelper" |
Ash Wilson | c72e362 | 2014-10-10 14:44:19 -0400 | [diff] [blame] | 9 | "github.com/rackspace/gophercloud/testhelper/client" |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 10 | ) |
| 11 | |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 12 | func tokenPost(t *testing.T, options gophercloud.AuthOptions, requestJSON string) os.CreateResult { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
Ash Wilson | c72e362 | 2014-10-10 14:44:19 -0400 | [diff] [blame] | 15 | os.HandleTokenPost(t, requestJSON) |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 16 | |
Ash Wilson | c72e362 | 2014-10-10 14:44:19 -0400 | [diff] [blame] | 17 | return Create(client.ServiceClient(), WrapOptions(options)) |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | func TestCreateTokenWithAPIKey(t *testing.T) { |
| 21 | options := gophercloud.AuthOptions{ |
| 22 | Username: "me", |
| 23 | APIKey: "1234567890abcdef", |
| 24 | } |
| 25 | |
Ash Wilson | c72e362 | 2014-10-10 14:44:19 -0400 | [diff] [blame] | 26 | os.IsSuccessful(t, tokenPost(t, options, ` |
Ash Wilson | 54b0382 | 2014-10-07 14:18:41 -0400 | [diff] [blame] | 27 | { |
| 28 | "auth": { |
| 29 | "RAX-KSKEY:apiKeyCredentials": { |
| 30 | "username": "me", |
| 31 | "apiKey": "1234567890abcdef" |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | `)) |
| 36 | } |