blob: 9b12337dcee1c822adbe246d3a0418477ff1636e [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 (
Ash Wilson1cd3e692014-09-09 11:01:47 -04006 "os"
Ash Wilson33c85f42014-09-02 14:09:14 -04007 "testing"
8
9 "github.com/rackspace/gophercloud/openstack"
10 "github.com/rackspace/gophercloud/openstack/utils"
11)
12
13func TestAuthenticatedClient(t *testing.T) {
14 // Obtain credentials from the environment.
15 ao, err := utils.AuthOptions()
16 if err != nil {
17 t.Fatalf("Unable to acquire credentials: %v", err)
18 }
19
Ash Wilson33c85f42014-09-02 14:09:14 -040020 client, err := openstack.AuthenticatedClient(ao)
21 if err != nil {
22 t.Fatalf("Unable to authenticate: %v", err)
23 }
24
25 if client.TokenID == "" {
26 t.Errorf("No token ID assigned to the client")
27 }
28
29 t.Logf("Client successfully acquired a token: %v", client.TokenID)
Ash Wilson1cd3e692014-09-09 11:01:47 -040030
31 // Find the storage service in the service catalog.
32 storage, err := openstack.NewStorageV1(client, os.Getenv("OS_REGION_NAME"))
33 if err != nil {
34 t.Errorf("Unable to locate a storage service: %v", err)
35 } else {
36 t.Logf("Located a storage service at endpoint: [%s]", storage.Endpoint)
37 }
Ash Wilson33c85f42014-09-02 14:09:14 -040038}