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 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
package lb_domains_test
import (
"encoding/json"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
api "github.com/mimuret/golang-iij-dpf/pkg/api"
"github.com/mimuret/golang-iij-dpf/pkg/apis/dpf/v1/lb_domains"
)
var _ = Describe("MonitoringPorpsHTTP", func() {
var (
bs []byte
c lb_domains.MonitoringPorpsHTTP
err error
s1, s2, s3 lb_domains.MonitoringPorpsHTTP
)
BeforeEach(func() {
s1 = lb_domains.MonitoringPorpsHTTP{
MonitoringPorpsCommon: lb_domains.MonitoringPorpsCommon{
Location: lb_domains.MonitoringPropsLocationAll,
Interval: 30,
Holdtime: 0,
Timeout: 1,
},
Port: 443,
TLSSNI: "example.jp",
ResponseMatch: "successful",
HTTPS: true,
Path: "/ready",
StatusCode: []string{"200"},
}
s2 = lb_domains.MonitoringPorpsHTTP{
MonitoringPorpsCommon: lb_domains.MonitoringPorpsCommon{
Location: lb_domains.MonitoringPropsLocationJP,
Interval: 600,
Holdtime: 3600,
Timeout: 30,
},
Port: 80,
TLSSNI: "",
ResponseMatch: "",
HTTPS: false,
Path: "",
StatusCode: []string{},
}
s3 = lb_domains.MonitoringPorpsHTTP{
Port: 53,
}
})
Context("Read", func() {
Context("s1", func() {
BeforeEach(func() {
err = api.UnmarshalRead(json.RawMessage(`{
"location": "all",
"interval": 30,
"holdtime": 0,
"timeout": 1,
"port": 443,
"https": true,
"tls_sni": "example.jp",
"response_match": "successful",
"path": "/ready",
"status_codes": ["200"]
}`), &c)
})
It("succeed", func() {
Expect(err).To(Succeed())
Expect(c).To(Equal(s1))
})
})
Context("s2", func() {
BeforeEach(func() {
err = api.UnmarshalRead(json.RawMessage(`{
"location": "jp",
"interval": 600,
"holdtime": 3600,
"timeout": 30,
"port": 80,
"https": false,
"tls_sni": "",
"response_match": "",
"path": "",
"status_codes": []
}`), &c)
})
It("succeed", func() {
Expect(err).To(Succeed())
Expect(c).To(Equal(s2))
})
})
})
Context("Update", func() {
Context("s1", func() {
BeforeEach(func() {
bs, err = api.MarshalUpdate(s1)
})
It("succeed", func() {
Expect(err).To(Succeed())
Expect(bs).To(MatchJSON(`{
"location": "all",
"interval": 30,
"holdtime": 0,
"timeout": 1,
"port": 443,
"https": true,
"tls_sni": "example.jp",
"response_match": "successful",
"path": "/ready",
"status_codes": ["200"]
}`))
})
})
Context("s3", func() {
BeforeEach(func() {
bs, err = api.MarshalUpdate(s3)
})
It("succeed", func() {
Expect(err).To(Succeed())
Expect(bs).To(MatchJSON(`{
"location": "",
"interval": 0,
"holdtime": 0,
"timeout": 0,
"port": 53,
"https": false,
"tls_sni": "",
"response_match": "",
"path": "",
"status_codes": null
}`))
})
})
})
Context("Create", func() {
Context("s1", func() {
BeforeEach(func() {
bs, err = api.MarshalCreate(s1)
})
It("succeed", func() {
Expect(err).To(Succeed())
Expect(bs).To(MatchJSON(`{
"location": "all",
"interval": 30,
"holdtime": 0,
"timeout": 1,
"port": 443,
"https": true,
"tls_sni": "example.jp",
"response_match": "successful",
"path": "/ready",
"status_codes": ["200"]
}`))
})
})
Context("s3", func() {
BeforeEach(func() {
bs, err = api.MarshalCreate(s3)
})
It("succeed", func() {
Expect(err).To(Succeed())
Expect(bs).To(MatchJSON(`{
"holdtime": 0,
"port": 53,
"https": false
}`))
})
})
})
})
|