diff options
author | Mat Schaffer <mat@schaffer.me> | 2018-07-20 16:14:02 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-20 16:14:02 +0900 |
commit | addc53da4250e2407c8f65b904d04aa10f123c99 (patch) | |
tree | 38ead3dd988345f6cc7c16b71d1fab3978c6c45f /vendor/github.com/DreamItGetIT/statuscake/tests.go | |
parent | 6fe72cf79fd995909fbaf2e3576bf75a0165c258 (diff) | |
parent | fa9f5996cdc877adb77e0e63fe3c0cda9999a227 (diff) | |
download | terraform-provider-statuscake-addc53da4250e2407c8f65b904d04aa10f123c99.tar.gz terraform-provider-statuscake-addc53da4250e2407c8f65b904d04aa10f123c99.tar.zst terraform-provider-statuscake-addc53da4250e2407c8f65b904d04aa10f123c99.zip |
Merge pull request #11 from callstats-io/master
Update statuscake library to latest version and use all the features from there.
Diffstat (limited to 'vendor/github.com/DreamItGetIT/statuscake/tests.go')
-rw-r--r-- | vendor/github.com/DreamItGetIT/statuscake/tests.go | 31 |
1 files changed, 31 insertions, 0 deletions
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 | } |