github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/blockstorage/noauth/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk"
     7  	"github.com/huaweicloud/golangsdk/openstack/blockstorage/noauth"
     8  	th "github.com/huaweicloud/golangsdk/testhelper"
     9  )
    10  
    11  func TestNoAuth(t *testing.T) {
    12  	ao := golangsdk.AuthOptions{
    13  		Username:   "user",
    14  		TenantName: "test",
    15  	}
    16  	provider, err := noauth.NewClient(ao)
    17  	th.AssertNoErr(t, err)
    18  	noauthClient, err := noauth.NewBlockStorageNoAuth(provider, noauth.EndpointOpts{
    19  		CinderEndpoint: "http://cinder:8776/v2",
    20  	})
    21  	th.AssertNoErr(t, err)
    22  	th.AssertEquals(t, naTestResult.Endpoint, noauthClient.Endpoint)
    23  	th.AssertEquals(t, naTestResult.TokenID, noauthClient.TokenID)
    24  
    25  	ao2 := golangsdk.AuthOptions{}
    26  	provider2, err := noauth.NewClient(ao2)
    27  	th.AssertNoErr(t, err)
    28  	noauthClient2, err := noauth.NewBlockStorageNoAuth(provider2, noauth.EndpointOpts{
    29  		CinderEndpoint: "http://cinder:8776/v2/",
    30  	})
    31  	th.AssertNoErr(t, err)
    32  	th.AssertEquals(t, naResult.Endpoint, noauthClient2.Endpoint)
    33  	th.AssertEquals(t, naResult.TokenID, noauthClient2.TokenID)
    34  
    35  	errTest, err := noauth.NewBlockStorageNoAuth(provider2, noauth.EndpointOpts{})
    36  	_ = errTest
    37  	th.AssertEquals(t, errorResult, err.Error())
    38  }