github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/cbr/v3/vaults/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/cbr/v3/vaults"
     7  	th "github.com/huaweicloud/golangsdk/testhelper"
     8  	"github.com/huaweicloud/golangsdk/testhelper/client"
     9  )
    10  
    11  func TestCreateV3VaultsMarshall(t *testing.T) {
    12  	res, err := createOpts.ToVaultCreateMap()
    13  	th.AssertNoErr(t, err)
    14  	th.AssertJSONEquals(t, expectedCreateRequest, res)
    15  }
    16  
    17  func TestCreateV3Vault(t *testing.T) {
    18  	th.SetupHTTP()
    19  	defer th.TeardownHTTP()
    20  	handleVaultCreate(t)
    21  
    22  	actual, err := vaults.Create(client.ServiceClient(), createOpts).Extract()
    23  	th.AssertNoErr(t, err)
    24  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    25  }
    26  
    27  func TestGetV3Vault(t *testing.T) {
    28  	th.SetupHTTP()
    29  	defer th.TeardownHTTP()
    30  	handleVaultGet(t)
    31  
    32  	actual, err := vaults.Get(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197").Extract()
    33  	th.AssertNoErr(t, err)
    34  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    35  }
    36  
    37  func TestUpdateV3Vault(t *testing.T) {
    38  	th.SetupHTTP()
    39  	defer th.TeardownHTTP()
    40  	handleVaultUpdate(t)
    41  
    42  	actual, err := vaults.Update(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197", updateOpts).Extract()
    43  	th.AssertNoErr(t, err)
    44  	th.AssertDeepEquals(t, expectedCreateResponseData, actual)
    45  }
    46  
    47  func TestDeleteV3Vault(t *testing.T) {
    48  	th.SetupHTTP()
    49  	defer th.TeardownHTTP()
    50  	handleVaultDelete(t)
    51  
    52  	err := vaults.Delete(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197").ExtractErr()
    53  	th.AssertNoErr(t, err)
    54  }
    55  
    56  func TestListV3Vault(t *testing.T) {
    57  	th.SetupHTTP()
    58  	defer th.TeardownHTTP()
    59  	handleVaultList(t)
    60  
    61  	allPages, err := vaults.List(client.ServiceClient(), vaults.ListOpts{}).AllPages()
    62  	th.AssertNoErr(t, err)
    63  	actual, err := vaults.ExtractVaults(allPages)
    64  	th.AssertNoErr(t, err)
    65  	th.AssertDeepEquals(t, expectedListResponseData, actual)
    66  }
    67  
    68  func TestPolicyBindingV3Vault(t *testing.T) {
    69  	th.SetupHTTP()
    70  	defer th.TeardownHTTP()
    71  	handleVaultBindPolicy(t)
    72  
    73  	actual, err := vaults.BindPolicy(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197",
    74  		bindPolicyOpts).Extract()
    75  	th.AssertNoErr(t, err)
    76  	th.AssertDeepEquals(t, expectedPolicyBindingResponseData, actual)
    77  }
    78  
    79  func TestPolicyUnbindingV3Vault(t *testing.T) {
    80  	th.SetupHTTP()
    81  	defer th.TeardownHTTP()
    82  	handleVaultUnbindPolicy(t)
    83  
    84  	actual, err := vaults.UnbindPolicy(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197",
    85  		bindPolicyOpts).Extract()
    86  	th.AssertNoErr(t, err)
    87  	th.AssertDeepEquals(t, expectedPolicyBindingResponseData, actual)
    88  }
    89  
    90  func TestAssociateResourcesV3Vault(t *testing.T) {
    91  	th.SetupHTTP()
    92  	defer th.TeardownHTTP()
    93  	handleVaultAssociateResources(t)
    94  
    95  	actual, err := vaults.AssociateResources(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197",
    96  		associateResourcesOpts).Extract()
    97  	th.AssertNoErr(t, err)
    98  	th.AssertDeepEquals(t, expectedAssociateResourcesResponseData, actual)
    99  }
   100  
   101  func TestDissociateResourcesV3Vault(t *testing.T) {
   102  	th.SetupHTTP()
   103  	defer th.TeardownHTTP()
   104  	handleVaultDissociateResources(t)
   105  
   106  	_, err := vaults.DissociateResources(client.ServiceClient(), "ad7627ae-5b0b-492e-b6bd-cd809b745197",
   107  		dissociateResourcesOpts).Extract()
   108  	th.AssertNoErr(t, err)
   109  }