aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--statuscake/resource_statuscaketest.go263
-rw-r--r--statuscake/resource_statuscaketest_test.go94
-rw-r--r--vendor/github.com/DreamItGetIT/statuscake/responses.go54
-rw-r--r--vendor/github.com/DreamItGetIT/statuscake/tests.go31
-rw-r--r--vendor/vendor.json6
-rw-r--r--website/docs/r/test.html.markdown21
6 files changed, 421 insertions, 48 deletions
diff --git a/statuscake/resource_statuscaketest.go b/statuscake/resource_statuscaketest.go
index 101ee83..d7d3f36 100644
--- a/statuscake/resource_statuscaketest.go
+++ b/statuscake/resource_statuscaketest.go
@@ -10,6 +10,24 @@ import (
10 "github.com/hashicorp/terraform/helper/schema" 10 "github.com/hashicorp/terraform/helper/schema"
11) 11)
12 12
13func castSetToSliceStrings(configured []interface{}) []string {
14 res := make([]string, len(configured))
15
16 for i, element := range configured {
17 res[i] = element.(string)
18 }
19 return res
20}
21
22// Special handling for node_locations since statuscake will return `[""]` for the empty case
23func considerEmptyStringAsEmptyArray(in []string) []string {
24 if len(in) == 1 && in[0] == "" {
25 return []string{}
26 } else {
27 return in
28 }
29}
30
13func resourceStatusCakeTest() *schema.Resource { 31func resourceStatusCakeTest() *schema.Resource {
14 return &schema.Resource{ 32 return &schema.Resource{
15 Create: CreateTest, 33 Create: CreateTest,
@@ -76,6 +94,118 @@ func resourceStatusCakeTest() *schema.Resource {
76 Optional: true, 94 Optional: true,
77 Default: 5, 95 Default: 5,
78 }, 96 },
97 "custom_header": {
98 Type: schema.TypeString,
99 Optional: true,
100 },
101
102 "user_agent": {
103 Type: schema.TypeString,
104 Optional: true,
105 },
106
107 "status": {
108 Type: schema.TypeString,
109 Computed: true,
110 },
111
112 "uptime": {
113 Type: schema.TypeFloat,
114 Computed: true,
115 },
116
117 "node_locations": {
118 Type: schema.TypeSet,
119 Elem: &schema.Schema{Type: schema.TypeString},
120 Optional: true,
121 Set: schema.HashString,
122 },
123
124 "ping_url": {
125 Type: schema.TypeString,
126 Optional: true,
127 },
128
129 "basic_user": {
130 Type: schema.TypeString,
131 Optional: true,
132 },
133
134 "basic_pass": {
135 Type: schema.TypeString,
136 Optional: true,
137 Sensitive: true,
138 },
139
140 "public": {
141 Type: schema.TypeInt,
142 Optional: true,
143 },
144
145 "logo_image": {
146 Type: schema.TypeString,
147 Optional: true,
148 },
149
150 "branding": {
151 Type: schema.TypeInt,
152 Optional: true,
153 },
154
155 "website_host": {
156 Type: schema.TypeString,
157 Optional: true,
158 },
159
160 "virus": {
161 Type: schema.TypeInt,
162 Optional: true,
163 },
164
165 "find_string": {
166 Type: schema.TypeString,
167 Optional: true,
168 },
169
170 "do_not_find": {
171 Type: schema.TypeBool,
172 Optional: true,
173 },
174
175 "real_browser": {
176 Type: schema.TypeInt,
177 Optional: true,
178 },
179
180 "test_tags": {
181 Type: schema.TypeString,
182 Optional: true,
183 },
184
185 "status_codes": {
186 Type: schema.TypeString,
187 Optional: true,
188 },
189
190 "use_jar": {
191 Type: schema.TypeInt,
192 Optional: true,
193 },
194
195 "post_raw": {
196 Type: schema.TypeString,
197 Optional: true,
198 },
199
200 "final_endpoint": {
201 Type: schema.TypeString,
202 Optional: true,
203 },
204
205 "follow_redirect": {
206 Type: schema.TypeBool,
207 Optional: true,
208 },
79 }, 209 },
80 } 210 }
81} 211}
@@ -84,16 +214,38 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
84 client := meta.(*statuscake.Client) 214 client := meta.(*statuscake.Client)
85 215
86 newTest := &statuscake.Test{ 216 newTest := &statuscake.Test{
87 WebsiteName: d.Get("website_name").(string), 217 WebsiteName: d.Get("website_name").(string),
88 WebsiteURL: d.Get("website_url").(string), 218 WebsiteURL: d.Get("website_url").(string),
89 CheckRate: d.Get("check_rate").(int), 219 CheckRate: d.Get("check_rate").(int),
90 TestType: d.Get("test_type").(string), 220 TestType: d.Get("test_type").(string),
91 Paused: d.Get("paused").(bool), 221 Paused: d.Get("paused").(bool),
92 Timeout: d.Get("timeout").(int), 222 Timeout: d.Get("timeout").(int),
93 ContactID: d.Get("contact_id").(int), 223 ContactID: d.Get("contact_id").(int),
94 Confirmation: d.Get("confirmations").(int), 224 Confirmation: d.Get("confirmations").(int),
95 Port: d.Get("port").(int), 225 Port: d.Get("port").(int),
96 TriggerRate: d.Get("trigger_rate").(int), 226 TriggerRate: d.Get("trigger_rate").(int),
227 CustomHeader: d.Get("custom_header").(string),
228 UserAgent: d.Get("user_agent").(string),
229 Status: d.Get("status").(string),
230 Uptime: d.Get("uptime").(float64),
231 NodeLocations: castSetToSliceStrings(d.Get("node_locations").(*schema.Set).List()),
232 PingURL: d.Get("ping_url").(string),
233 BasicUser: d.Get("basic_user").(string),
234 BasicPass: d.Get("basic_pass").(string),
235 Public: d.Get("public").(int),
236 LogoImage: d.Get("logo_image").(string),
237 Branding: d.Get("branding").(int),
238 WebsiteHost: d.Get("website_host").(string),
239 Virus: d.Get("virus").(int),
240 FindString: d.Get("find_string").(string),
241 DoNotFind: d.Get("do_not_find").(bool),
242 RealBrowser: d.Get("real_browser").(int),
243 TestTags: d.Get("test_tags").(string),
244 StatusCodes: d.Get("status_codes").(string),
245 UseJar: d.Get("use_jar").(int),
246 PostRaw: d.Get("post_raw").(string),
247 FinalEndpoint: d.Get("final_endpoint").(string),
248 FollowRedirect: d.Get("follow_redirect").(bool),
97 } 249 }
98 250
99 log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string)) 251 log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@@ -104,6 +256,8 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
104 } 256 }
105 257
106 d.Set("test_id", fmt.Sprintf("%d", response.TestID)) 258 d.Set("test_id", fmt.Sprintf("%d", response.TestID))
259 d.Set("status", response.Status)
260 d.Set("uptime", fmt.Sprintf("%.3f", response.Uptime))
107 d.SetId(fmt.Sprintf("%d", response.TestID)) 261 d.SetId(fmt.Sprintf("%d", response.TestID))
108 262
109 return ReadTest(d, meta) 263 return ReadTest(d, meta)
@@ -159,6 +313,25 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
159 d.Set("confirmations", testResp.Confirmation) 313 d.Set("confirmations", testResp.Confirmation)
160 d.Set("port", testResp.Port) 314 d.Set("port", testResp.Port)
161 d.Set("trigger_rate", testResp.TriggerRate) 315 d.Set("trigger_rate", testResp.TriggerRate)
316 d.Set("custom_header", testResp.CustomHeader)
317 d.Set("status", testResp.Status)
318 d.Set("uptime", testResp.Uptime)
319 if err := d.Set("node_locations", considerEmptyStringAsEmptyArray(testResp.NodeLocations)); err != nil {
320 return fmt.Errorf("[WARN] Error setting node locations: %s", err)
321 }
322 d.Set("logo_image", testResp.LogoImage)
323 // Even after WebsiteHost is set, the API returns ""
324 // API docs aren't clear on usage will only override state if we get a non-empty value back
325 if testResp.WebsiteHost != "" {
326 d.Set("website_host", testResp.WebsiteHost)
327 }
328 d.Set("find_string", testResp.FindString)
329 d.Set("do_not_find", testResp.DoNotFind)
330 d.Set("status_codes", testResp.StatusCodes)
331 d.Set("use_jar", testResp.UseJar)
332 d.Set("post_raw", testResp.PostRaw)
333 d.Set("final_endpoint", testResp.FinalEndpoint)
334 d.Set("follow_redirect", testResp.FollowRedirect)
162 335
163 return nil 336 return nil
164} 337}
@@ -192,9 +365,6 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
192 if v, ok := d.GetOk("timeout"); ok { 365 if v, ok := d.GetOk("timeout"); ok {
193 test.Timeout = v.(int) 366 test.Timeout = v.(int)
194 } 367 }
195 if v, ok := d.GetOk("contact_id"); ok {
196 test.ContactID = v.(int)
197 }
198 if v, ok := d.GetOk("confirmations"); ok { 368 if v, ok := d.GetOk("confirmations"); ok {
199 test.Confirmation = v.(int) 369 test.Confirmation = v.(int)
200 } 370 }
@@ -204,13 +374,66 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
204 if v, ok := d.GetOk("trigger_rate"); ok { 374 if v, ok := d.GetOk("trigger_rate"); ok {
205 test.TriggerRate = v.(int) 375 test.TriggerRate = v.(int)
206 } 376 }
207 377 if v, ok := d.GetOk("custom_header"); ok {
208 defaultStatusCodes := "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, " + 378 test.CustomHeader = v.(string)
209 "408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, " + 379 }
210 "504, 505, 506, 507, 508, 509, 510, 511, 521, 522, 523, 524, 520, " + 380 if v, ok := d.GetOk("user_agent"); ok {
211 "598, 599" 381 test.UserAgent = v.(string)
212 382 }
213 test.StatusCodes = defaultStatusCodes 383 if v, ok := d.GetOk("node_locations"); ok {
384 test.NodeLocations = castSetToSliceStrings(v.(*schema.Set).List())
385 }
386 if v, ok := d.GetOk("ping_url"); ok {
387 test.PingURL = v.(string)
388 }
389 if v, ok := d.GetOk("basic_user"); ok {
390 test.BasicUser = v.(string)
391 }
392 if v, ok := d.GetOk("basic_pass"); ok {
393 test.BasicPass = v.(string)
394 }
395 if v, ok := d.GetOk("public"); ok {
396 test.Public = v.(int)
397 }
398 if v, ok := d.GetOk("logo_image"); ok {
399 test.LogoImage = v.(string)
400 }
401 if v, ok := d.GetOk("branding"); ok {
402 test.Branding = v.(int)
403 }
404 if v, ok := d.GetOk("website_host"); ok {
405 test.WebsiteHost = v.(string)
406 }
407 if v, ok := d.GetOk("virus"); ok {
408 test.Virus = v.(int)
409 }
410 if v, ok := d.GetOk("find_string"); ok {
411 test.FindString = v.(string)
412 }
413 if v, ok := d.GetOk("do_not_find"); ok {
414 test.DoNotFind = v.(bool)
415 }
416 if v, ok := d.GetOk("real_browser"); ok {
417 test.RealBrowser = v.(int)
418 }
419 if v, ok := d.GetOk("test_tags"); ok {
420 test.TestTags = v.(string)
421 }
422 if v, ok := d.GetOk("status_codes"); ok {
423 test.StatusCodes = v.(string)
424 }
425 if v, ok := d.GetOk("use_jar"); ok {
426 test.UseJar = v.(int)
427 }
428 if v, ok := d.GetOk("post_raw"); ok {
429 test.PostRaw = v.(string)
430 }
431 if v, ok := d.GetOk("final_endpoint"); ok {
432 test.FinalEndpoint = v.(string)
433 }
434 if v, ok := d.GetOk("follow_redirect"); ok {
435 test.FollowRedirect = v.(bool)
436 }
214 437
215 return test 438 return test
216} 439}
diff --git a/statuscake/resource_statuscaketest_test.go b/statuscake/resource_statuscaketest_test.go
index f07fcc5..8bcbb36 100644
--- a/statuscake/resource_statuscaketest_test.go
+++ b/statuscake/resource_statuscaketest_test.go
@@ -2,6 +2,7 @@ package statuscake
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "os"
5 "strconv" 6 "strconv"
6 "testing" 7 "testing"
7 8
@@ -19,7 +20,7 @@ func TestAccStatusCake_basic(t *testing.T) {
19 CheckDestroy: testAccTestCheckDestroy(&test), 20 CheckDestroy: testAccTestCheckDestroy(&test),
20 Steps: []resource.TestStep{ 21 Steps: []resource.TestStep{
21 { 22 {
22 Config: testAccTestConfig_basic, 23 Config: interpolateTerraformTemplate(testAccTestConfig_basic),
23 Check: resource.ComposeTestCheckFunc( 24 Check: resource.ComposeTestCheckFunc(
24 testAccTestCheckExists("statuscake_test.google", &test), 25 testAccTestCheckExists("statuscake_test.google", &test),
25 testAccTestCheckAttributes("statuscake_test.google", &test), 26 testAccTestCheckAttributes("statuscake_test.google", &test),
@@ -38,7 +39,7 @@ func TestAccStatusCake_tcp(t *testing.T) {
38 CheckDestroy: testAccTestCheckDestroy(&test), 39 CheckDestroy: testAccTestCheckDestroy(&test),
39 Steps: []resource.TestStep{ 40 Steps: []resource.TestStep{
40 { 41 {
41 Config: testAccTestConfig_tcp, 42 Config: interpolateTerraformTemplate(testAccTestConfig_tcp),
42 Check: resource.ComposeTestCheckFunc( 43 Check: resource.ComposeTestCheckFunc(
43 testAccTestCheckExists("statuscake_test.google", &test), 44 testAccTestCheckExists("statuscake_test.google", &test),
44 testAccTestCheckAttributes("statuscake_test.google", &test), 45 testAccTestCheckAttributes("statuscake_test.google", &test),
@@ -57,7 +58,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
57 CheckDestroy: testAccTestCheckDestroy(&test), 58 CheckDestroy: testAccTestCheckDestroy(&test),
58 Steps: []resource.TestStep{ 59 Steps: []resource.TestStep{
59 { 60 {
60 Config: testAccTestConfig_basic, 61 Config: interpolateTerraformTemplate(testAccTestConfig_basic),
61 Check: resource.ComposeTestCheckFunc( 62 Check: resource.ComposeTestCheckFunc(
62 testAccTestCheckExists("statuscake_test.google", &test), 63 testAccTestCheckExists("statuscake_test.google", &test),
63 ), 64 ),
@@ -74,6 +75,28 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
74 resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"), 75 resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"),
75 resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"), 76 resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"),
76 resource.TestCheckResourceAttr("statuscake_test.google", "trigger_rate", "20"), 77 resource.TestCheckResourceAttr("statuscake_test.google", "trigger_rate", "20"),
78 resource.TestCheckResourceAttr("statuscake_test.google", "custom_header", "{ \"Content-Type\": \"application/x-www-form-urlencoded\" }"),
79 resource.TestCheckResourceAttr("statuscake_test.google", "user_agent", "string9988"),
80 resource.TestCheckResourceAttr("statuscake_test.google", "status", "Up"),
81 resource.TestCheckResourceAttr("statuscake_test.google", "uptime", "0"),
82 resource.TestCheckResourceAttr("statuscake_test.google", "node_locations.#", "3"),
83 resource.TestCheckResourceAttr("statuscake_test.google", "ping_url", "string8410"),
84 resource.TestCheckResourceAttr("statuscake_test.google", "basic_user", "string27052"),
85 resource.TestCheckResourceAttr("statuscake_test.google", "basic_pass", "string5659"),
86 resource.TestCheckResourceAttr("statuscake_test.google", "public", "0"),
87 resource.TestCheckResourceAttr("statuscake_test.google", "logo_image", "string21087"),
88 resource.TestCheckResourceAttr("statuscake_test.google", "branding", "25875"),
89 resource.TestCheckResourceAttr("statuscake_test.google", "website_host", "string32368"),
90 resource.TestCheckResourceAttr("statuscake_test.google", "virus", "1"),
91 resource.TestCheckResourceAttr("statuscake_test.google", "find_string", "string15212"),
92 resource.TestCheckResourceAttr("statuscake_test.google", "do_not_find", "false"),
93 resource.TestCheckResourceAttr("statuscake_test.google", "real_browser", "1"),
94 resource.TestCheckResourceAttr("statuscake_test.google", "test_tags", "string8191"),
95 resource.TestCheckResourceAttr("statuscake_test.google", "status_codes", "string23065"),
96 resource.TestCheckResourceAttr("statuscake_test.google", "use_jar", "1"),
97 resource.TestCheckResourceAttr("statuscake_test.google", "post_raw", "string32096"),
98 resource.TestCheckResourceAttr("statuscake_test.google", "final_endpoint", "string10781"),
99 resource.TestCheckResourceAttr("statuscake_test.google", "follow_redirect", "true"),
77 ), 100 ),
78 }, 101 },
79 }, 102 },
@@ -142,8 +165,34 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
142 err = check(key, value, strconv.Itoa(test.Confirmation)) 165 err = check(key, value, strconv.Itoa(test.Confirmation))
143 case "trigger_rate": 166 case "trigger_rate":
144 err = check(key, value, strconv.Itoa(test.TriggerRate)) 167 err = check(key, value, strconv.Itoa(test.TriggerRate))
168 case "custom_header":
169 err = check(key, value, test.CustomHeader)
170 case "node_locations":
171 for _, tv := range test.NodeLocations {
172 err = check(key, value, tv)
173 if err != nil {
174 return err
175 }
176 }
177 case "public":
178 err = check(key, value, strconv.Itoa(test.Public))
179 case "logo_image":
180 err = check(key, value, test.LogoImage)
181 case "find_string":
182 err = check(key, value, test.FindString)
183 case "do_not_find":
184 err = check(key, value, strconv.FormatBool(test.DoNotFind))
185 case "status_codes":
186 err = check(key, value, test.StatusCodes)
187 case "use_jar":
188 err = check(key, value, strconv.Itoa(test.UseJar))
189 case "post_raw":
190 err = check(key, value, test.PostRaw)
191 case "final_endpoint":
192 err = check(key, value, test.FinalEndpoint)
193 case "follow_redirect":
194 err = check(key, value, strconv.FormatBool(test.FollowRedirect))
145 } 195 }
146
147 if err != nil { 196 if err != nil {
148 return err 197 return err
149 } 198 }
@@ -164,6 +213,19 @@ func testAccTestCheckDestroy(test *statuscake.Test) resource.TestCheckFunc {
164 } 213 }
165} 214}
166 215
216func interpolateTerraformTemplate(template string) string {
217 testContactGroupId := 43402
218
219 if v := os.Getenv("STATUSCAKE_TEST_CONTACT_GROUP_ID"); v != "" {
220 id, err := strconv.Atoi(v)
221 if err == nil {
222 testContactGroupId = id
223 }
224 }
225
226 return fmt.Sprintf(template, testContactGroupId)
227}
228
167const testAccTestConfig_basic = ` 229const testAccTestConfig_basic = `
168resource "statuscake_test" "google" { 230resource "statuscake_test" "google" {
169 website_name = "google.com" 231 website_name = "google.com"
@@ -171,7 +233,7 @@ resource "statuscake_test" "google" {
171 test_type = "HTTP" 233 test_type = "HTTP"
172 check_rate = 300 234 check_rate = 300
173 timeout = 10 235 timeout = 10
174 contact_id = 43402 236 contact_id = %d
175 confirmations = 1 237 confirmations = 1
176 trigger_rate = 10 238 trigger_rate = 10
177} 239}
@@ -185,6 +247,26 @@ resource "statuscake_test" "google" {
185 check_rate = 500 247 check_rate = 500
186 paused = true 248 paused = true
187 trigger_rate = 20 249 trigger_rate = 20
250 custom_header = "{ \"Content-Type\": \"application/x-www-form-urlencoded\" }"
251 user_agent = "string9988"
252 node_locations = [ "string16045", "string19741", "string12122" ]
253 ping_url = "string8410"
254 basic_user = "string27052"
255 basic_pass = "string5659"
256 public = 0
257 logo_image = "string21087"
258 branding = 25875
259 website_host = "string32368"
260 virus = 1
261 find_string = "string15212"
262 do_not_find = false
263 real_browser = 1
264 test_tags = "string8191"
265 status_codes = "string23065"
266 use_jar = 1
267 post_raw = "string32096"
268 final_endpoint = "string10781"
269 follow_redirect = true
188} 270}
189` 271`
190 272
@@ -195,7 +277,7 @@ resource "statuscake_test" "google" {
195 test_type = "TCP" 277 test_type = "TCP"
196 check_rate = 300 278 check_rate = 300
197 timeout = 10 279 timeout = 10
198 contact_id = 43402 280 contact_id = %d
199 confirmations = 1 281 confirmations = 1
200 port = 80 282 port = 80
201} 283}
diff --git a/vendor/github.com/DreamItGetIT/statuscake/responses.go b/vendor/github.com/DreamItGetIT/statuscake/responses.go
index b9216b7..3cbf36d 100644
--- a/vendor/github.com/DreamItGetIT/statuscake/responses.go
+++ b/vendor/github.com/DreamItGetIT/statuscake/responses.go
@@ -1,5 +1,9 @@
1package statuscake 1package statuscake
2 2
3import (
4 "strings"
5)
6
3type autheticationErrorResponse struct { 7type autheticationErrorResponse struct {
4 ErrNo int 8 ErrNo int
5 Error string 9 Error string
@@ -27,6 +31,8 @@ type detailResponse struct {
27 ContactID int `json:"ContactID"` 31 ContactID int `json:"ContactID"`
28 Status string `json:"Status"` 32 Status string `json:"Status"`
29 Uptime float64 `json:"Uptime"` 33 Uptime float64 `json:"Uptime"`
34 CustomHeader string `json:"CustomHeader"`
35 UserAgent string `json:"UserAgent"`
30 CheckRate int `json:"CheckRate"` 36 CheckRate int `json:"CheckRate"`
31 Timeout int `json:"Timeout"` 37 Timeout int `json:"Timeout"`
32 LogoImage string `json:"LogoImage"` 38 LogoImage string `json:"LogoImage"`
@@ -44,27 +50,39 @@ type detailResponse struct {
44 DownTimes int `json:"DownTimes,string"` 50 DownTimes int `json:"DownTimes,string"`
45 Sensitive bool `json:"Sensitive"` 51 Sensitive bool `json:"Sensitive"`
46 TriggerRate int `json:"TriggerRate,string"` 52 TriggerRate int `json:"TriggerRate,string"`
53 UseJar int `json:"UseJar"`
54 PostRaw string `json:"PostRaw"`
55 FinalEndpoint string `json:"FinalEndpoint"`
56 FollowRedirect bool `json:"FollowRedirect"`
57 StatusCodes []string `json:"StatusCodes"`
47} 58}
48 59
49func (d *detailResponse) test() *Test { 60func (d *detailResponse) test() *Test {
50 return &Test{ 61 return &Test{
51 TestID: d.TestID, 62 TestID: d.TestID,
52 TestType: d.TestType, 63 TestType: d.TestType,
53 Paused: d.Paused, 64 Paused: d.Paused,
54 WebsiteName: d.WebsiteName, 65 WebsiteName: d.WebsiteName,
55 WebsiteURL: d.URI, 66 WebsiteURL: d.URI,
56 ContactID: d.ContactID, 67 CustomHeader: d.CustomHeader,
57 Status: d.Status, 68 UserAgent: d.UserAgent,
58 Uptime: d.Uptime, 69 ContactID: d.ContactID,
59 CheckRate: d.CheckRate, 70 Status: d.Status,
60 Timeout: d.Timeout, 71 Uptime: d.Uptime,
61 LogoImage: d.LogoImage, 72 CheckRate: d.CheckRate,
62 Confirmation: d.Confirmation, 73 Timeout: d.Timeout,
63 WebsiteHost: d.WebsiteHost, 74 LogoImage: d.LogoImage,
64 NodeLocations: d.NodeLocations, 75 Confirmation: d.Confirmation,
65 FindString: d.FindString, 76 WebsiteHost: d.WebsiteHost,
66 DoNotFind: d.DoNotFind, 77 NodeLocations: d.NodeLocations,
67 Port: d.Port, 78 FindString: d.FindString,
68 TriggerRate: d.TriggerRate, 79 DoNotFind: d.DoNotFind,
80 Port: d.Port,
81 TriggerRate: d.TriggerRate,
82 UseJar: d.UseJar,
83 PostRaw: d.PostRaw,
84 FinalEndpoint: d.FinalEndpoint,
85 FollowRedirect: d.FollowRedirect,
86 StatusCodes: strings.Join(d.StatusCodes[:], ","),
69 } 87 }
70} 88}
diff --git a/vendor/github.com/DreamItGetIT/statuscake/tests.go b/vendor/github.com/DreamItGetIT/statuscake/tests.go
index 4053e53..a41b0bd 100644
--- a/vendor/github.com/DreamItGetIT/statuscake/tests.go
+++ b/vendor/github.com/DreamItGetIT/statuscake/tests.go
@@ -21,6 +21,12 @@ type Test struct {
21 // Website name. Tags are stripped out 21 // Website name. Tags are stripped out
22 WebsiteName string `json:"WebsiteName" querystring:"WebsiteName"` 22 WebsiteName string `json:"WebsiteName" querystring:"WebsiteName"`
23 23
24 // CustomHeader. A special header that will be sent along with the HTTP tests.
25 CustomHeader string `json:"CustomHeader" querystring:"CustomHeader"`
26
27 // Use to populate the test with a custom user agent
28 UserAgent string `json:"UserAgent" queryString:"UserAgent"`
29
24 // Test location, either an IP (for TCP and Ping) or a fully qualified URL for other TestTypes 30 // Test location, either an IP (for TCP and Ping) or a fully qualified URL for other TestTypes
25 WebsiteURL string `json:"WebsiteURL" querystring:"WebsiteURL"` 31 WebsiteURL string `json:"WebsiteURL" querystring:"WebsiteURL"`
26 32
@@ -91,6 +97,18 @@ type Test struct {
91 97
92 // Comma Seperated List of StatusCodes to Trigger Error on (on Update will replace, so send full list each time) 98 // Comma Seperated List of StatusCodes to Trigger Error on (on Update will replace, so send full list each time)
93 StatusCodes string `json:"StatusCodes" querystring:"StatusCodes"` 99 StatusCodes string `json:"StatusCodes" querystring:"StatusCodes"`
100
101 // Set to 1 to enable the Cookie Jar. Required for some redirects.
102 UseJar int `json:"UseJar" querystring:"UseJar"`
103
104 // Raw POST data seperated by an ampersand
105 PostRaw string `json:"PostRaw" querystring:"PostRaw"`
106
107 // Use to specify the expected Final URL in the testing process
108 FinalEndpoint string `json:"FinalEndpoint" querystring:"FinalEndpoint"`
109
110 // Use to specify whether redirects should be followed
111 FollowRedirect bool `json:"FollowRedirect" querystring:"FollowRedirect"`
94} 112}
95 113
96// Validate checks if the Test is valid. If it's invalid, it returns a ValidationError with all invalid fields. It returns nil otherwise. 114// Validate checks if the Test is valid. If it's invalid, it returns a ValidationError with all invalid fields. It returns nil otherwise.
@@ -137,6 +155,19 @@ func (t *Test) Validate() error {
137 e["TriggerRate"] = "must be between 0 and 59" 155 e["TriggerRate"] = "must be between 0 and 59"
138 } 156 }
139 157
158 if t.PostRaw != "" && t.TestType != "HTTP" {
159 e["PostRaw"] = "must be HTTP to submit a POST request"
160 }
161
162 if t.FinalEndpoint != "" && t.TestType != "HTTP" {
163 e["FinalEndpoint"] = "must be a Valid URL"
164 }
165
166 var jsonVerifiable map[string]interface{}
167 if json.Unmarshal([]byte(t.CustomHeader), &jsonVerifiable) != nil {
168 e["CustomHeader"] = "must be provided as json string"
169 }
170
140 if len(e) > 0 { 171 if len(e) > 0 {
141 return e 172 return e
142 } 173 }
diff --git a/vendor/vendor.json b/vendor/vendor.json
index 8b44fbd..61dd8f3 100644
--- a/vendor/vendor.json
+++ b/vendor/vendor.json
@@ -3,10 +3,10 @@
3 "ignore": "appengine test github.com/hashicorp/nomad/ github.com/hashicorp/terraform/backend", 3 "ignore": "appengine test github.com/hashicorp/nomad/ github.com/hashicorp/terraform/backend",
4 "package": [ 4 "package": [
5 { 5 {
6 "checksumSHA1": "MV5JueYPwNkLZ+KNqmDcNDhsKi4=", 6 "checksumSHA1": "6Fo7YzTT+MDviHOsqg6dNw8WrV4=",
7 "path": "github.com/DreamItGetIT/statuscake", 7 "path": "github.com/DreamItGetIT/statuscake",
8 "revision": "acc13ec021cd1e8a6ebb1d9035f513217f5c4562", 8 "revision": "f69198f958d7326f3c110dd9be1c21abbd8a87a7",
9 "revisionTime": "2017-04-10T11:34:45Z" 9 "revisionTime": "2018-01-30T22:14:43Z"
10 }, 10 },
11 { 11 {
12 "checksumSHA1": "FIL83loX9V9APvGQIjJpbxq53F0=", 12 "checksumSHA1": "FIL83loX9V9APvGQIjJpbxq53F0=",
diff --git a/website/docs/r/test.html.markdown b/website/docs/r/test.html.markdown
index 0a1df9f..a385b00 100644
--- a/website/docs/r/test.html.markdown
+++ b/website/docs/r/test.html.markdown
@@ -36,7 +36,26 @@ The following arguments are supported:
36* `confirmations` - (Optional) The number of confirmation servers to use in order to detect downtime. Defaults to 0. 36* `confirmations` - (Optional) The number of confirmation servers to use in order to detect downtime. Defaults to 0.
37* `port` - (Optional) The port to use when specifying a TCP test. 37* `port` - (Optional) The port to use when specifying a TCP test.
38* `trigger_rate` - (Optional) The number of minutes to wait before sending an alert. Default is `5`. 38* `trigger_rate` - (Optional) The number of minutes to wait before sending an alert. Default is `5`.
39 39* `custom_header` - (Optional) Custom HTTP header, must be supplied as JSON.
40* `user_agent` - (Optional) Test with a custom user agent set.
41* `node_locations` - (Optional) Set test node locations, must be array of strings.
42* `ping_url` - (Optional) A URL to ping if a site goes down.
43* `basic_user` - (Optional) A Basic Auth User account to use to login
44* `basic_pass` - (Optional) If BasicUser is set then this should be the password for the BasicUser.
45* `public` - (Optional) Set 1 to enable public reporting, 0 to disable.
46* `logo_image` - (Optional) A URL to a image to use for public reporting.
47* `branding` - (Optional) Set to 0 to use branding (default) or 1 to disable public reporting branding).
48* `website_host` - (Optional) Used internally, when possible please add.
49* `virus` - (Optional) Enable virus checking or not. 1 to enable
50* `find_string` - (Optional) A string that should either be found or not found.
51* `do_not_find` - (Optional) If the above string should be found to trigger a alert. 1 = will trigger if find_string found.
52* `real_browser` - (Optional) Use 1 to TURN OFF real browser testing.
53* `test_tags` - (Optional) Tags should be seperated by a comma - no spacing between tags (this,is,a set,of,tags).
54* `status_codes` - (Optional) Comma Seperated List of StatusCodes to Trigger Error on. Defaults are "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, 408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 521, 522, 523, 524, 520, 598, 599".
55* `use_jar` - (Optional) Set to true to enable the Cookie Jar. Required for some redirects. Default is false.
56* `post_raw` - (Optional) Use to populate the RAW POST data field on the test.
57* `final_endpoint` - (Optional) Use to specify the expected Final URL in the testing process.
58* `follow_redirect` - (Optional) Use to specify whether redirects should be followed, set to true to enable. Default is false.
40 59
41## Attributes Reference 60## Attributes Reference
42 61