Ash Wilson | c25ae60 | 2014-09-02 14:41:12 -0400 | [diff] [blame] | 1 | // +build acceptance |
| 2 | |
Ash Wilson | 33c85f4 | 2014-09-02 14:09:14 -0400 | [diff] [blame] | 3 | package openstack |
| 4 | |
| 5 | import ( |
Ash Wilson | 1cd3e69 | 2014-09-09 11:01:47 -0400 | [diff] [blame] | 6 | "os" |
Ash Wilson | 33c85f4 | 2014-09-02 14:09:14 -0400 | [diff] [blame] | 7 | "testing" |
| 8 | |
Jon Perritt | 509fbb6 | 2014-09-10 13:29:56 -0500 | [diff] [blame] | 9 | "github.com/rackspace/gophercloud" |
Ash Wilson | 33c85f4 | 2014-09-02 14:09:14 -0400 | [diff] [blame] | 10 | "github.com/rackspace/gophercloud/openstack" |
| 11 | "github.com/rackspace/gophercloud/openstack/utils" |
| 12 | ) |
| 13 | |
| 14 | func 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 | |
Ash Wilson | 33c85f4 | 2014-09-02 14:09:14 -0400 | [diff] [blame] | 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) |
Ash Wilson | 1cd3e69 | 2014-09-09 11:01:47 -0400 | [diff] [blame] | 31 | |
| 32 | // Find the storage service in the service catalog. |
Jon Perritt | 2a7797d | 2014-10-21 15:08:43 -0500 | [diff] [blame] | 33 | storage, err := openstack.NewObjectStorageV1(client, gophercloud.EndpointOpts{ |
Jon Perritt | 509fbb6 | 2014-09-10 13:29:56 -0500 | [diff] [blame] | 34 | Region: os.Getenv("OS_REGION_NAME"), |
| 35 | }) |
Ash Wilson | 1cd3e69 | 2014-09-09 11:01:47 -0400 | [diff] [blame] | 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 | } |
Ash Wilson | 33c85f4 | 2014-09-02 14:09:14 -0400 | [diff] [blame] | 41 | } |