Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
| 3 | package v3 |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | |
Krzysztof Szukiełojć | 24a29ce | 2017-05-07 14:24:02 +0200 | [diff] [blame] | 8 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/clients" |
| 9 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/acceptance/tools" |
| 10 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack" |
| 11 | "gerrit.mcp.mirantis.net/debian/gophercloud.git/openstack/identity/v3/tokens" |
Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 12 | ) |
| 13 | |
| 14 | func TestGetToken(t *testing.T) { |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 15 | client, err := clients.NewIdentityV3UnauthenticatedClient() |
| 16 | if err != nil { |
| 17 | t.Fatalf("Unable to obtain an identity client: %v") |
| 18 | } |
| 19 | |
Jamie Hannaford | 390555a | 2014-10-22 17:04:03 +0200 | [diff] [blame] | 20 | ao, err := openstack.AuthOptionsFromEnv() |
Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 21 | if err != nil { |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 22 | t.Fatalf("Unable to obtain environment auth options: %v", err) |
Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 23 | } |
| 24 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 25 | authOptions := tokens.AuthOptions{ |
| 26 | Username: ao.Username, |
| 27 | Password: ao.Password, |
| 28 | DomainName: "default", |
Ash Wilson | 7083d02 | 2014-09-09 14:10:43 -0400 | [diff] [blame] | 29 | } |
Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 30 | |
Joe Topjian | 918f573 | 2016-08-15 08:47:08 -0600 | [diff] [blame] | 31 | token, err := tokens.Create(client, &authOptions).Extract() |
Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 32 | if err != nil { |
| 33 | t.Fatalf("Unable to get token: %v", err) |
| 34 | } |
| 35 | |
Joe Topjian | 66a046c | 2017-01-19 22:07:26 -0700 | [diff] [blame] | 36 | tools.PrintResource(t, token) |
Ash Wilson | 4215691 | 2014-09-02 14:08:22 -0400 | [diff] [blame] | 37 | } |