forked from gophercloud/gophercloud
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fixtures.go
111 lines (97 loc) · 3.73 KB
/
fixtures.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package testing
import (
"fmt"
"net/http"
"testing"
"github.com/bizflycloud/gophercloud"
"github.com/bizflycloud/gophercloud/openstack/containerinfra/v1/certificates"
th "github.com/bizflycloud/gophercloud/testhelper"
fake "github.com/bizflycloud/gophercloud/testhelper/client"
)
const CertificateResponse = `
{
"cluster_uuid": "d564b18a-2890-4152-be3d-e05d784ff727",
"bay_uuid": "d564b18a-2890-4152-be3d-e05d784ff727",
"pem": "FAKE_CERTIFICATE",
"links": [
{
"href": "http://10.63.176.154:9511/v1/certificates/d564b18a-2890-4152-be3d-e05d784ff727",
"rel": "self"
},
{
"href": "http://10.63.176.154:9511/certificates/d564b18a-2890-4152-be3d-e05d784ff727",
"rel": "bookmark"
}
]
}`
const CreateCertificateResponse = `
{
"cluster_uuid": "d564b18a-2890-4152-be3d-e05d784ff727",
"bay_uuid": "d564b18a-2890-4152-be3d-e05d784ff727",
"pem": "FAKE_CERTIFICATE_PEM",
"csr": "FAKE_CERTIFICATE_CSR",
"links": [
{
"href": "http://10.63.176.154:9511/v1/certificates/d564b18a-2890-4152-be3d-e05d784ff727",
"rel": "self"
},
{
"href": "http://10.63.176.154:9511/certificates/d564b18a-2890-4152-be3d-e05d784ff727",
"rel": "bookmark"
}
]
}`
var ExpectedCertificate = certificates.Certificate{
ClusterUUID: "d564b18a-2890-4152-be3d-e05d784ff727",
BayUUID: "d564b18a-2890-4152-be3d-e05d784ff727",
PEM: "FAKE_CERTIFICATE",
Links: []gophercloud.Link{
{Href: "http://10.63.176.154:9511/v1/certificates/d564b18a-2890-4152-be3d-e05d784ff727", Rel: "self"},
{Href: "http://10.63.176.154:9511/certificates/d564b18a-2890-4152-be3d-e05d784ff727", Rel: "bookmark"},
},
}
var ExpectedCreateCertificateResponse = certificates.Certificate{
ClusterUUID: "d564b18a-2890-4152-be3d-e05d784ff727",
BayUUID: "d564b18a-2890-4152-be3d-e05d784ff727",
PEM: "FAKE_CERTIFICATE_PEM",
CSR: "FAKE_CERTIFICATE_CSR",
Links: []gophercloud.Link{
{Href: "http://10.63.176.154:9511/v1/certificates/d564b18a-2890-4152-be3d-e05d784ff727", Rel: "self"},
{Href: "http://10.63.176.154:9511/certificates/d564b18a-2890-4152-be3d-e05d784ff727", Rel: "bookmark"},
},
}
func HandleGetCertificateSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/v1/certificates/d564b18a-2890-4152-be3d-e05d784ff72", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.Header().Add("OpenStack-API-Minimum-Version", "container-infra 1.1")
w.Header().Add("OpenStack-API-Maximum-Version", "container-infra 1.6")
w.Header().Add("OpenStack-API-Version", "container-infra 1.1")
w.Header().Add("X-OpenStack-Request-Id", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
w.WriteHeader(http.StatusOK)
fmt.Fprint(w, CertificateResponse)
})
}
func HandleCreateCertificateSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/v1/certificates/", func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "GET")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.Header().Add("Content-Type", "application/json")
w.Header().Add("OpenStack-API-Minimum-Version", "container-infra 1.1")
w.Header().Add("OpenStack-API-Maximum-Version", "container-infra 1.6")
w.Header().Add("OpenStack-API-Version", "container-infra 1.1")
w.Header().Add("X-OpenStack-Request-Id", "req-781e9bdc-4163-46eb-91c9-786c53188bbb")
w.WriteHeader(http.StatusCreated)
fmt.Fprint(w, CreateCertificateResponse)
})
}
func HandleUpdateCertificateSuccessfully(t *testing.T) {
th.Mux.HandleFunc("/v1/certificates/d564b18a-2890-4152-be3d-e05d784ff72",
func(w http.ResponseWriter, r *http.Request) {
th.TestMethod(t, r, "PATCH")
th.TestHeader(t, r, "X-Auth-Token", fake.TokenID)
w.WriteHeader(http.StatusAccepted)
fmt.Fprintf(w, `{}`)
})
}