Skip to content

Commit 4a80394

Browse files
authored
SYN-4026: Add optional port field to http tests (#21)
* SYN-4026: Add optional port field to http test schema * SYN-4026: Use http test schema * SYN-4026: Add port assertions
1 parent ef1b21b commit 4a80394

4 files changed

+17
-3
lines changed

syntheticsclientv2/common_models.go

+2
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ type HttpCheckV2Response struct {
303303
Customproperties []CustomProperties `json:"customProperties"`
304304
Lastrunstatus string `json:"lastRunStatus"`
305305
Lastrunat time.Time `json:"lastRunAt"`
306+
Port int `json:"port"`
306307
} `json:"test"`
307308
}
308309

@@ -323,6 +324,7 @@ type HttpCheckV2Input struct {
323324
HttpHeaders []HttpHeaders `json:"headers,omitempty"`
324325
Validations []Validations `json:"validations"`
325326
Customproperties []CustomProperties `json:"customProperties"`
327+
Port int `json:"port"`
326328
} `json:"test"`
327329
}
328330

syntheticsclientv2/create_httpcheckv2_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
var (
29-
createHttpCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"morebeeps-test","type":"http","url":"https://www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true,"request_method":"GET","body":null,"headers":[{"name":"boop","value":"beep"}]}}`
29+
createHttpCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "port": 443, "name":"morebeeps-test","type":"http","url":"https://www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true,"request_method":"GET","body":null,"headers":[{"name":"boop","value":"beep"}]}}`
3030
inputHttpCheckV2Data = HttpCheckV2Input{}
3131
)
3232

@@ -86,4 +86,8 @@ func TestCreateHttpCheckV2(t *testing.T) {
8686
if !reflect.DeepEqual(resp.Test.Customproperties, inputHttpCheckV2Data.Test.Customproperties) {
8787
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputHttpCheckV2Data.Test.Customproperties)
8888
}
89+
90+
if !reflect.DeepEqual(resp.Test.Port, inputHttpCheckV2Data.Test.Port) {
91+
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Port, inputHttpCheckV2Data.Test.Port)
92+
}
8993
}

syntheticsclientv2/get_httpcheckv2_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
var (
28-
getHttpCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"advancedSettings":{"authentication":{"password":"password123","username":"myuser"},"cookies":[{"key":"qux","value":"qux","domain":"splunk.com","path":"/qux"}],"headers":[{"name":"Accept","value":"application/json","domain":"splunk.com"}],"verifyCertificates":true},"createdAt":"2022-09-14T14:35:37.801Z","device":{"id":1,"label":"iPhone","networkConnection":{"description":"Mobile LTE","downloadBandwidth":12000,"latency":70,"packetLoss":0,"uploadBandwidth":12000},"viewportHeight":844,"viewportWidth":375},"frequency":5,"id":1,"locationIds":["na-us-virginia"],"name":"My Test","schedulingStrategy":"round_robin","transactions":[{"name":"Example transaction","steps":[{"name":"element step","selector":".main","selectorType":"css","type":"click_element","waitForNav":true}]}],"type":"browser","updatedAt":"2022-09-14T14:35:38.099Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success"}}`
28+
getHttpCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"createdAt":"2022-09-14T14:35:37.801Z","frequency":5,"id":1,"locationIds":["na-us-virginia"],"name":"My Test","schedulingStrategy":"round_robin","type":"http","updatedAt":"2022-09-14T14:35:38.099Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","url":"https://splunk.com","requestMethod":"GET","body":null,"headers":[{"name":"Accept","value":"application/json","domain":"splunk.com"}],"userAgent":null,"validations":[],"verifyCertificates":false,"authentication":null,"port":null}}`
2929
inputGetHttpCheckV2 = verifyHttpCheckV2Input(string(getHttpCheckV2Body))
3030
)
3131

@@ -101,6 +101,10 @@ func TestGetHttpCheckV2(t *testing.T) {
101101
if !reflect.DeepEqual(resp.Test.Customproperties, inputGetHttpCheckV2.Test.Customproperties) {
102102
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputGetHttpCheckV2.Test.Customproperties)
103103
}
104+
105+
if !reflect.DeepEqual(resp.Test.Port, inputGetHttpCheckV2.Test.Port) {
106+
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Port, inputGetHttpCheckV2.Test.Port)
107+
}
104108
}
105109

106110
func verifyHttpCheckV2Input(stringInput string) *HttpCheckV2Response {

syntheticsclientv2/update_httpcheckv2_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
)
2727

2828
var (
29-
updateHttpCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"morebeeps-test","type":"http","url":"https://www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true,"request_method":"GET","body":null,"headers":[{"name":"boop","value":"beep"}]}}`
29+
updateHttpCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"morebeeps-test","type":"http","url":"https://www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true,"request_method":"GET","body":null,"port":443,"headers":[{"name":"boop","value":"beep"}]}}`
3030
inputHttpCheckV2Update = HttpCheckV2Input{}
3131
)
3232

@@ -61,4 +61,8 @@ func TestUpdateHttpCheckV2(t *testing.T) {
6161
if !reflect.DeepEqual(resp.Test.Customproperties, inputHttpCheckV2Update.Test.Customproperties) {
6262
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputHttpCheckV2Update.Test.Customproperties)
6363
}
64+
65+
if !reflect.DeepEqual(resp.Test.Port, inputHttpCheckV2Update.Test.Port) {
66+
t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Port, inputHttpCheckV2Update.Test.Port)
67+
}
6468
}

0 commit comments

Comments
 (0)