blob: 6678ff4a7c23982f2556aa73de6d72e687189ab2 [file] [log] [blame]
Ash Wilson54b03822014-10-07 14:18:41 -04001package tokens
2
3import (
Ash Wilson54b03822014-10-07 14:18:41 -04004 "testing"
Ash Wilson54b03822014-10-07 14:18:41 -04005
6 "github.com/rackspace/gophercloud"
Ash Wilson54b03822014-10-07 14:18:41 -04007 os "github.com/rackspace/gophercloud/openstack/identity/v2/tokens"
8 th "github.com/rackspace/gophercloud/testhelper"
Ash Wilsonc72e3622014-10-10 14:44:19 -04009 "github.com/rackspace/gophercloud/testhelper/client"
Ash Wilson54b03822014-10-07 14:18:41 -040010)
11
Ash Wilson54b03822014-10-07 14:18:41 -040012func tokenPost(t *testing.T, options gophercloud.AuthOptions, requestJSON string) os.CreateResult {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
Ash Wilsonc72e3622014-10-10 14:44:19 -040015 os.HandleTokenPost(t, requestJSON)
Ash Wilson54b03822014-10-07 14:18:41 -040016
Ash Wilsonc72e3622014-10-10 14:44:19 -040017 return Create(client.ServiceClient(), WrapOptions(options))
Ash Wilson54b03822014-10-07 14:18:41 -040018}
19
20func TestCreateTokenWithAPIKey(t *testing.T) {
21 options := gophercloud.AuthOptions{
22 Username: "me",
23 APIKey: "1234567890abcdef",
24 }
25
Ash Wilsonc72e3622014-10-10 14:44:19 -040026 os.IsSuccessful(t, tokenPost(t, options, `
Ash Wilson54b03822014-10-07 14:18:41 -040027 {
28 "auth": {
29 "RAX-KSKEY:apiKeyCredentials": {
30 "username": "me",
31 "apiKey": "1234567890abcdef"
32 }
33 }
34 }
35 `))
36}