blob: 47381a2c6a98877155b07a90c05c78db6a4dbb33 [file] [log] [blame]
Ash Wilson8018c392014-10-03 14:35:56 -04001// +build acceptance
2
3package v2
4
5import (
6 "testing"
7
Ash Wilson8018c392014-10-03 14:35:56 -04008 tokens2 "github.com/rackspace/gophercloud/openstack/identity/v2/tokens"
Ash Wilson8018c392014-10-03 14:35:56 -04009 th "github.com/rackspace/gophercloud/testhelper"
10)
11
12func TestAuthenticate(t *testing.T) {
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040013 ao := v2AuthOptions(t)
14 service := unauthenticatedClient(t)
Ash Wilson8018c392014-10-03 14:35:56 -040015
16 // Authenticated!
17 result := tokens2.Create(service, ao)
18
19 // Extract and print the token.
20 token, err := result.ExtractToken()
21 th.AssertNoErr(t, err)
22
23 t.Logf("Acquired token: [%s]", token.ID)
24 t.Logf("The token will expire at: [%s]", token.ExpiresAt.String())
25 t.Logf("The token is valid for tenant: [%#v]", token.Tenant)
26
27 // Extract and print the service catalog.
28 catalog, err := result.ExtractServiceCatalog()
29 th.AssertNoErr(t, err)
30
31 t.Logf("Acquired service catalog listing [%d] services", len(catalog.Entries))
32 for i, entry := range catalog.Entries {
Ash Wilsonf4aee1e2014-10-03 15:25:13 -040033 t.Logf("[%02d]: name=[%s], type=[%s]", i, entry.Name, entry.Type)
Ash Wilson8018c392014-10-03 14:35:56 -040034 for _, endpoint := range entry.Endpoints {
35 t.Logf(" - region=[%s] publicURL=[%s]", endpoint.Region, endpoint.PublicURL)
36 }
37 }
38}