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