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