github.com/gophercloud/gophercloud@v1.11.0/openstack/containerinfra/v1/certificates/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gophercloud/gophercloud/openstack/containerinfra/v1/certificates"
     7  	th "github.com/gophercloud/gophercloud/testhelper"
     8  	fake "github.com/gophercloud/gophercloud/testhelper/client"
     9  )
    10  
    11  func TestGetCertificates(t *testing.T) {
    12  	th.SetupHTTP()
    13  	defer th.TeardownHTTP()
    14  
    15  	HandleGetCertificateSuccessfully(t)
    16  
    17  	sc := fake.ServiceClient()
    18  	sc.Endpoint = sc.Endpoint + "v1/"
    19  
    20  	actual, err := certificates.Get(sc, "d564b18a-2890-4152-be3d-e05d784ff72").Extract()
    21  	th.AssertNoErr(t, err)
    22  	th.AssertDeepEquals(t, ExpectedCertificate, *actual)
    23  }
    24  
    25  func TestCreateCertificates(t *testing.T) {
    26  	th.SetupHTTP()
    27  	defer th.TeardownHTTP()
    28  
    29  	HandleCreateCertificateSuccessfully(t)
    30  
    31  	sc := fake.ServiceClient()
    32  	sc.Endpoint = sc.Endpoint + "v1/"
    33  
    34  	opts := certificates.CreateOpts{
    35  		BayUUID: "d564b18a-2890-4152-be3d-e05d784ff727",
    36  		CSR:     "FAKE_CERTIFICATE_CSR",
    37  	}
    38  
    39  	actual, err := certificates.Create(sc, opts).Extract()
    40  	th.AssertNoErr(t, err)
    41  	th.AssertDeepEquals(t, ExpectedCreateCertificateResponse, *actual)
    42  }
    43  
    44  func TestUpdateCertificates(t *testing.T) {
    45  	th.SetupHTTP()
    46  	defer th.TeardownHTTP()
    47  
    48  	HandleUpdateCertificateSuccessfully(t)
    49  
    50  	sc := fake.ServiceClient()
    51  	sc.Endpoint = sc.Endpoint + "v1/"
    52  
    53  	err := certificates.Update(sc, "d564b18a-2890-4152-be3d-e05d784ff72").ExtractErr()
    54  	th.AssertNoErr(t, err)
    55  }