Ash Wilson | dd7188d | 2014-09-05 14:02:42 -0400 | [diff] [blame^] | 1 | package v3 |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/rackspace/gophercloud" |
| 7 | "github.com/rackspace/gophercloud/openstack" |
| 8 | "github.com/rackspace/gophercloud/openstack/utils" |
| 9 | ) |
| 10 | |
| 11 | func createAuthenticatedClient(t *testing.T) *gophercloud.ServiceClient { |
| 12 | // Obtain credentials from the environment. |
| 13 | ao, err := utils.AuthOptions() |
| 14 | if err != nil { |
| 15 | t.Fatalf("Unable to acquire credentials: %v", err) |
| 16 | } |
| 17 | |
| 18 | // Trim out unused fields. |
| 19 | ao.Username, ao.TenantID, ao.TenantName = "", "", "" |
| 20 | |
| 21 | // Create an authenticated client. |
| 22 | providerClient, err := openstack.AuthenticatedClient(ao) |
| 23 | if err != nil { |
| 24 | t.Fatalf("Unable to instantiate client: %v", err) |
| 25 | } |
| 26 | |
| 27 | // Create a service client. |
| 28 | return openstack.NewIdentityV3(providerClient) |
| 29 | } |