blob: 27d50a8062643b9732ed361d00cac2ca4049d908 [file] [log] [blame]
Ash Wilson54ce2f42014-10-09 09:26:29 -04001// +build acceptance
2
3package rackspace
4
5import (
6 "testing"
7
Jon Perritt27249f42016-02-18 10:35:59 -06008 "github.com/gophercloud/gophercloud/acceptance/tools"
9 "github.com/gophercloud/gophercloud/rackspace"
10 th "github.com/gophercloud/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}