github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/keymanager/v1/acls/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/keymanager/v1/acls"
     8  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
     9  	"github.com/vnpaycloud-console/gophercloud/v2/testhelper/client"
    10  )
    11  
    12  func TestGetSecretACL(t *testing.T) {
    13  	th.SetupHTTP()
    14  	defer th.TeardownHTTP()
    15  	HandleGetSecretACLSuccessfully(t)
    16  
    17  	actual, err := acls.GetSecretACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c").Extract()
    18  	th.AssertNoErr(t, err)
    19  	th.AssertDeepEquals(t, ExpectedACL, *actual)
    20  }
    21  
    22  func TestGetContainerACL(t *testing.T) {
    23  	th.SetupHTTP()
    24  	defer th.TeardownHTTP()
    25  	HandleGetContainerACLSuccessfully(t)
    26  
    27  	actual, err := acls.GetContainerACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c").Extract()
    28  	th.AssertNoErr(t, err)
    29  	th.AssertDeepEquals(t, ExpectedACL, *actual)
    30  }
    31  
    32  func TestSetSecretACL(t *testing.T) {
    33  	th.SetupHTTP()
    34  	defer th.TeardownHTTP()
    35  	HandleSetSecretACLSuccessfully(t)
    36  
    37  	users := []string{"GG27dVwR9gBMnsOaRoJ1DFJmZfdVjIdW"}
    38  	iFalse := false
    39  	setOpts := acls.SetOpts{
    40  		acls.SetOpt{
    41  			Type:          "read",
    42  			Users:         &users,
    43  			ProjectAccess: &iFalse,
    44  		},
    45  	}
    46  
    47  	actual, err := acls.SetSecretACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c", setOpts).Extract()
    48  	th.AssertNoErr(t, err)
    49  	th.AssertDeepEquals(t, ExpectedSecretACLRef, *actual)
    50  }
    51  
    52  func TestSetContainerACL(t *testing.T) {
    53  	th.SetupHTTP()
    54  	defer th.TeardownHTTP()
    55  	HandleSetContainerACLSuccessfully(t)
    56  
    57  	users := []string{"GG27dVwR9gBMnsOaRoJ1DFJmZfdVjIdW"}
    58  	iFalse := false
    59  	setOpts := acls.SetOpts{
    60  		acls.SetOpt{
    61  			Type:          "read",
    62  			Users:         &users,
    63  			ProjectAccess: &iFalse,
    64  		},
    65  	}
    66  
    67  	actual, err := acls.SetContainerACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c", setOpts).Extract()
    68  	th.AssertNoErr(t, err)
    69  	th.AssertDeepEquals(t, ExpectedContainerACLRef, *actual)
    70  }
    71  
    72  func TestDeleteSecretACL(t *testing.T) {
    73  	th.SetupHTTP()
    74  	defer th.TeardownHTTP()
    75  	HandleDeleteSecretACLSuccessfully(t)
    76  
    77  	res := acls.DeleteSecretACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c")
    78  	th.AssertNoErr(t, res.Err)
    79  }
    80  
    81  func TestDeleteContainerACL(t *testing.T) {
    82  	th.SetupHTTP()
    83  	defer th.TeardownHTTP()
    84  	HandleDeleteContainerACLSuccessfully(t)
    85  
    86  	res := acls.DeleteContainerACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c")
    87  	th.AssertNoErr(t, res.Err)
    88  }
    89  
    90  func TestUpdateSecretACL(t *testing.T) {
    91  	th.SetupHTTP()
    92  	defer th.TeardownHTTP()
    93  	HandleUpdateSecretACLSuccessfully(t)
    94  
    95  	newUsers := []string{}
    96  	updateOpts := acls.SetOpts{
    97  		acls.SetOpt{
    98  			Type:  "read",
    99  			Users: &newUsers,
   100  		},
   101  	}
   102  
   103  	actual, err := acls.UpdateSecretACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c", updateOpts).Extract()
   104  	th.AssertNoErr(t, err)
   105  	th.AssertDeepEquals(t, ExpectedSecretACLRef, *actual)
   106  }
   107  
   108  func TestUpdateContainerACL(t *testing.T) {
   109  	th.SetupHTTP()
   110  	defer th.TeardownHTTP()
   111  	HandleUpdateContainerACLSuccessfully(t)
   112  
   113  	newUsers := []string{}
   114  	updateOpts := acls.SetOpts{
   115  		acls.SetOpt{
   116  			Type:  "read",
   117  			Users: &newUsers,
   118  		},
   119  	}
   120  
   121  	actual, err := acls.UpdateContainerACL(context.TODO(), client.ServiceClient(), "1b8068c4-3bb6-4be6-8f1e-da0d1ea0b67c", updateOpts).Extract()
   122  	th.AssertNoErr(t, err)
   123  	th.AssertDeepEquals(t, ExpectedContainerACLRef, *actual)
   124  }