blob: 578469d882127d6bde4590277a7433e358525b49 [file] [log] [blame]
Ash Wilsonc25ae602014-09-02 14:41:12 -04001// +build acceptance
2
Ash Wilson33c85f42014-09-02 14:09:14 -04003package openstack
4
5import (
6 "testing"
7
8 "github.com/rackspace/gophercloud/openstack"
9 "github.com/rackspace/gophercloud/openstack/utils"
10)
11
12func TestAuthenticatedClient(t *testing.T) {
13 // Obtain credentials from the environment.
14 ao, err := utils.AuthOptions()
15 if err != nil {
16 t.Fatalf("Unable to acquire credentials: %v", err)
17 }
18
Ash Wilson9d9fb102014-09-03 11:26:31 -040019 // Trim out unused fields.
20 ao.TenantID, ao.TenantName = "", ""
21
Ash Wilson33c85f42014-09-02 14:09:14 -040022 client, err := openstack.AuthenticatedClient(ao)
23 if err != nil {
24 t.Fatalf("Unable to authenticate: %v", err)
25 }
26
27 if client.TokenID == "" {
28 t.Errorf("No token ID assigned to the client")
29 }
30
31 t.Logf("Client successfully acquired a token: %v", client.TokenID)
32}