blob: 28745315a6281286518eb5d0fde0abab681461d9 [file] [log] [blame]
Ash Wilson54ce2f42014-10-09 09:26:29 -04001// +build acceptance
2
3package rackspace
4
5import (
6 "testing"
7
Ash Wilson54ce2f42014-10-09 09:26:29 -04008 "github.com/rackspace/gophercloud/rackspace"
Ash Wilsona6ddde72014-10-22 15:26:42 -04009 th "github.com/rackspace/gophercloud/testhelper"
Ash Wilson54ce2f42014-10-09 09:26:29 -040010)
11
12func TestAuthenticatedClient(t *testing.T) {
13 // Obtain credentials from the environment.
Jamie Hannaford390555a2014-10-22 17:04:03 +020014 ao, err := rackspace.AuthOptionsFromEnv()
Ash Wilsona6ddde72014-10-22 15:26:42 -040015 th.AssertNoErr(t, err)
Ash Wilson54ce2f42014-10-09 09:26:29 -040016
Ash Wilsona6ddde72014-10-22 15:26:42 -040017 client, err := rackspace.AuthenticatedClient(tools.OnlyRS(ao))
Ash Wilson54ce2f42014-10-09 09:26:29 -040018 if err != nil {
19 t.Fatalf("Unable to authenticate: %v", err)
20 }
21
22 if client.TokenID == "" {
23 t.Errorf("No token ID assigned to the client")
24 }
25
26 t.Logf("Client successfully acquired a token: %v", client.TokenID)
27}