aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/DreamItGetIT/statuscake/tests.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/DreamItGetIT/statuscake/tests.go')
-rw-r--r--vendor/github.com/DreamItGetIT/statuscake/tests.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/vendor/github.com/DreamItGetIT/statuscake/tests.go b/vendor/github.com/DreamItGetIT/statuscake/tests.go
index 4053e53..1b37fa1 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
@@ -28,7 +34,7 @@ type Test struct {
28 Port int `json:"Port" querystring:"Port"` 34 Port int `json:"Port" querystring:"Port"`
29 35
30 // Contact group ID - will return int of contact group used else 0 36 // Contact group ID - will return int of contact group used else 0
31 ContactID int `json:"ContactID" querystring:"ContactGroup"` 37 ContactID string `json:"ContactID" querystring:"ContactGroup"`
32 38
33 // Current status at last test 39 // Current status at last test
34 Status string `json:"Status"` 40 Status string `json:"Status"`
@@ -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 }