github.com/gophercloud/gophercloud@v1.11.0/openstack/objectstorage/v1/swauth/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/gophercloud/gophercloud/openstack" 7 "github.com/gophercloud/gophercloud/openstack/objectstorage/v1/swauth" 8 th "github.com/gophercloud/gophercloud/testhelper" 9 ) 10 11 func TestAuth(t *testing.T) { 12 authOpts := swauth.AuthOpts{ 13 User: "test:tester", 14 Key: "testing", 15 } 16 17 th.SetupHTTP() 18 defer th.TeardownHTTP() 19 HandleAuthSuccessfully(t, authOpts) 20 21 providerClient, err := openstack.NewClient(th.Endpoint()) 22 th.AssertNoErr(t, err) 23 24 swiftClient, err := swauth.NewObjectStorageV1(providerClient, authOpts) 25 th.AssertNoErr(t, err) 26 th.AssertEquals(t, AuthResult.Token, swiftClient.TokenID) 27 } 28 29 func TestBadAuth(t *testing.T) { 30 authOpts := swauth.AuthOpts{} 31 _, err := authOpts.ToAuthOptsMap() 32 if err == nil { 33 t.Fatalf("Expected an error due to missing auth options") 34 } 35 }