blob: 52c0cf57805de765b3d0c5d51f4458cbb481c610 [file] [log] [blame]
Jamie Hannaford2aaf1a62014-10-16 12:55:50 +02001// +build acceptance
2
3package openstack
4
5import (
6 "os"
7 "testing"
8
9 "github.com/rackspace/gophercloud"
10 "github.com/rackspace/gophercloud/openstack"
11 "github.com/rackspace/gophercloud/openstack/utils"
12)
13
14func TestAuthenticatedClient(t *testing.T) {
15 // Obtain credentials from the environment.
16 ao, err := utils.AuthOptions()
17 if err != nil {
18 t.Fatalf("Unable to acquire credentials: %v", err)
19 }
20
21 client, err := openstack.AuthenticatedClient(ao)
22 if err != nil {
23 t.Fatalf("Unable to authenticate: %v", err)
24 }
25
26 if client.TokenID == "" {
27 t.Errorf("No token ID assigned to the client")
28 }
29
30 t.Logf("Client successfully acquired a token: %v", client.TokenID)
31
32 // Find the storage service in the service catalog.
33 storage, err := openstack.NewStorageV1(client, gophercloud.EndpointOpts{
34 Region: os.Getenv("OS_REGION_NAME"),
35 })
36 if err != nil {
37 t.Errorf("Unable to locate a storage service: %v", err)
38 } else {
39 t.Logf("Located a storage service at endpoint: [%s]", storage.Endpoint)
40 }
41}