diff --git a/go.mod b/go.mod index 3e1e378..14f9ea1 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/splunk/syntheticsclient/v2 -go 1.14 +go 1.16 diff --git a/syntheticsclientv2/common_models.go b/syntheticsclientv2/common_models.go index 3f48221..299a6bf 100644 --- a/syntheticsclientv2/common_models.go +++ b/syntheticsclientv2/common_models.go @@ -87,24 +87,29 @@ type BusinessTransactions struct { StepsV2 []StepsV2 `json:"steps"` } +// Selector is a v2 browser step element locator (type + value). +type Selector struct { + Type string `json:"type"` + Value string `json:"value"` +} + type StepsV2 struct { - Name string `json:"name"` - Type string `json:"type"` - URL string `json:"url,omitempty"` - Action string `json:"action,omitempty"` - WaitForNav bool `json:"waitForNav"` - WaitForNavTimeout int `json:"waitForNavTimeout,omitempty"` - WaitForNavTimeoutDefault bool `json:"waitForNavTimeoutDefault,omitempty"` - MaxWaitTime int `json:"maxWaitTime,omitempty"` - MaxWaitTimeDefault bool `json:"maxWaitTimeDefault,omitempty"` - SelectorType string `json:"selectorType,omitempty"` - Selector string `json:"selector,omitempty"` - OptionSelectorType string `json:"optionSelectorType,omitempty"` - OptionSelector string `json:"optionSelector,omitempty"` - VariableName string `json:"variableName,omitempty"` - Value string `json:"value,omitempty"` - Options Options `json:"options,omitempty"` - Duration int `json:"duration,omitempty"` + Name string `json:"name"` + Type string `json:"type"` + URL string `json:"url,omitempty"` + Action string `json:"action,omitempty"` + WaitForNav bool `json:"waitForNav"` + WaitForNavTimeout int `json:"waitForNavTimeout,omitempty"` + WaitForNavTimeoutDefault bool `json:"waitForNavTimeoutDefault,omitempty"` + MaxWaitTime int `json:"maxWaitTime,omitempty"` + MaxWaitTimeDefault bool `json:"maxWaitTimeDefault,omitempty"` + Selectors []Selector `json:"selectors,omitempty"` + OptionSelectorType string `json:"optionSelectorType,omitempty"` + OptionSelector string `json:"optionSelector,omitempty"` + VariableName string `json:"variableName,omitempty"` + Value string `json:"value,omitempty"` + Options Options `json:"options,omitempty"` + Duration int `json:"duration,omitempty"` } type Options struct { @@ -416,9 +421,9 @@ type ApiCheckV2Input struct { type ApiCheckV2Response struct { Test struct { - Active bool `json:"active"` - Createdat time.Time `json:"createdAt"` - Device `json:"device,omitempty"` + Active bool `json:"active"` + Createdat time.Time `json:"createdAt"` + Deviceid int `json:"deviceId,omitempty"` Frequency int `json:"frequency,omitempty"` ID int `json:"id,omitempty"` Locationids []string `json:"locationIds,omitempty"` @@ -460,8 +465,8 @@ type BrowserCheckV2Response struct { type BrowserCheckV2ResponseTest struct { Active bool `json:"active"` Advancedsettings `json:"advancedSettings"` - Createdat time.Time `json:"createdAt"` - Device `json:"device"` + Createdat time.Time `json:"createdAt"` + Deviceid int `json:"deviceId"` Frequency int `json:"frequency"` ID int `json:"id"` Locationids []string `json:"locationIds"` diff --git a/syntheticsclientv2/create_apicheckv2.go b/syntheticsclientv2/create_apicheckv2.go index 7806b36..76b2dbd 100644 --- a/syntheticsclientv2/create_apicheckv2.go +++ b/syntheticsclientv2/create_apicheckv2.go @@ -47,7 +47,7 @@ func (c Client) CreateApiCheckV2(ApiCheckV2Details *ApiCheckV2Input) (*ApiCheckV return nil, nil, err } - details, err := c.makePublicAPICall("POST", "/tests/api", bytes.NewBuffer(body), nil) + details, err := c.makePublicAPICall("POST", "/v2/tests/api", bytes.NewBuffer(body), nil) if err != nil { return nil, details, err } diff --git a/syntheticsclientv2/create_apicheckv2_test.go b/syntheticsclientv2/create_apicheckv2_test.go index e25b234..5302646 100644 --- a/syntheticsclientv2/create_apicheckv2_test.go +++ b/syntheticsclientv2/create_apicheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - createApiV2Body = `{"test":{"automaticRetries": 1,"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"device_id":1,"frequency":5,"location_ids":["aws-us-east-1"],"name":"boop-test","scheduling_strategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/489","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells", "beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}` + createApiV2Body = `{"test":{"automaticRetries": 1,"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"deviceId":1,"frequency":5,"location_ids":["aws-us-east-1"],"name":"boop-test","scheduling_strategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/v2/tests/api/489","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells", "beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}` inputData = ApiCheckV2Input{} ) @@ -34,7 +34,7 @@ func TestCreateApiCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/api", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/api", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") _, err := w.Write([]byte(createApiV2Body)) if err != nil { diff --git a/syntheticsclientv2/create_browsercheckv2.go b/syntheticsclientv2/create_browsercheckv2.go index f6ebdd6..7a6caae 100644 --- a/syntheticsclientv2/create_browsercheckv2.go +++ b/syntheticsclientv2/create_browsercheckv2.go @@ -38,7 +38,7 @@ func (c Client) CreateBrowserCheckV2(browserCheckV2Details *BrowserCheckV2Input) return nil, nil, err } - details, err := c.makePublicAPICall("POST", "/tests/browser", bytes.NewBuffer(body), nil) + details, err := c.makePublicAPICall("POST", "/v2/tests/browser", bytes.NewBuffer(body), nil) if err != nil { return nil, details, err } diff --git a/syntheticsclientv2/create_browsercheckv2_test.go b/syntheticsclientv2/create_browsercheckv2_test.go index d954035..9fd52a3 100644 --- a/syntheticsclientv2/create_browsercheckv2_test.go +++ b/syntheticsclientv2/create_browsercheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - createBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"browser-beep-test","transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectorType":"id","selector":"selectionz","optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectorType":"link","selector":"beepval","variableName":"{{env.terraform-test-foo-301}}"},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":5,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"chromeFlags":[{"name":"--proxy-bypass-list","value":"127.0.0.1:8080"}],"cookies":[{"key":"super","value":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}],"excludedFiles":[{"type":"google_analytics"},{"type":"custom","regex":"some-domain.com"},{"type":"all_except","regex":"another-domain.com"}]}}}` + createBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"browser-beep-test","transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectors":[{"type":"id","value":"clicky"}],"waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectors":[{"type":"id","value":"beep"}],"value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectors":[{"type":"id","value":"selectionz"}],"optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectors":[{"type":"id","value":"textzz"}],"optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectors":[{"type":"id","value":"valz"}],"optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectors":[{"type":"link","value":"beepval"}],"variableName":"{{env.terraform-test-foo-301}}"},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":5,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"chromeFlags":[{"name":"--proxy-bypass-list","value":"127.0.0.1:8080"}],"cookies":[{"key":"super","value":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}],"excludedFiles":[{"type":"google_analytics"},{"type":"custom","regex":"some-domain.com"},{"type":"all_except","regex":"another-domain.com"}]}}}` inputBrowserCheckV2Data = BrowserCheckV2Input{} ) @@ -34,7 +34,7 @@ func TestCreateBrowserCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/browser", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/browser", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "POST") _, err := w.Write([]byte(createBrowserCheckV2Body)) if err != nil { diff --git a/syntheticsclientv2/delete_apicheckv2.go b/syntheticsclientv2/delete_apicheckv2.go index 0e17655..06e7496 100644 --- a/syntheticsclientv2/delete_apicheckv2.go +++ b/syntheticsclientv2/delete_apicheckv2.go @@ -22,7 +22,7 @@ import ( ) func (c Client) DeleteApiCheckV2(id int) (int, error) { - requestDetails, err := c.makePublicAPICall("DELETE", fmt.Sprintf("/tests/api/%d", id), bytes.NewBufferString("{}"), nil) + requestDetails, err := c.makePublicAPICall("DELETE", fmt.Sprintf("/v2/tests/api/%d", id), bytes.NewBufferString("{}"), nil) if err != nil { return 1, err } diff --git a/syntheticsclientv2/delete_apicheckv2_test.go b/syntheticsclientv2/delete_apicheckv2_test.go index 066b8ee..7cae14d 100644 --- a/syntheticsclientv2/delete_apicheckv2_test.go +++ b/syntheticsclientv2/delete_apicheckv2_test.go @@ -31,7 +31,7 @@ func TestDeleteApiCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/api/19", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/api/19", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") _, err := w.Write([]byte(deleteApiCheckV2RespBody)) if err != nil { diff --git a/syntheticsclientv2/delete_browsercheckv2.go b/syntheticsclientv2/delete_browsercheckv2.go index 1bc7fe8..c8aee4c 100644 --- a/syntheticsclientv2/delete_browsercheckv2.go +++ b/syntheticsclientv2/delete_browsercheckv2.go @@ -22,7 +22,7 @@ import ( ) func (c Client) DeleteBrowserCheckV2(id int) (int, error) { - requestDetails, err := c.makePublicAPICall("DELETE", fmt.Sprintf("/tests/browser/%d", id), bytes.NewBufferString("{}"), nil) + requestDetails, err := c.makePublicAPICall("DELETE", fmt.Sprintf("/v2/tests/browser/%d", id), bytes.NewBufferString("{}"), nil) if err != nil { return 1, err } diff --git a/syntheticsclientv2/delete_browsercheckv2_test.go b/syntheticsclientv2/delete_browsercheckv2_test.go index 764fa20..3b724b9 100644 --- a/syntheticsclientv2/delete_browsercheckv2_test.go +++ b/syntheticsclientv2/delete_browsercheckv2_test.go @@ -31,7 +31,7 @@ func TestDeleteBrowserCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/browser/19", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/browser/19", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") _, err := w.Write([]byte(deleteBrowserCheckV2RespBody)) if err != nil { diff --git a/syntheticsclientv2/get_apicheckv2.go b/syntheticsclientv2/get_apicheckv2.go index 390f1a0..c1ea842 100644 --- a/syntheticsclientv2/get_apicheckv2.go +++ b/syntheticsclientv2/get_apicheckv2.go @@ -34,7 +34,7 @@ func parseApiCheckV2Response(response string) (*ApiCheckV2Response, error) { func (c Client) GetApiCheckV2(id int) (*ApiCheckV2Response, *RequestDetails, error) { details, err := c.makePublicAPICall("GET", - fmt.Sprintf("/tests/api/%d", id), + fmt.Sprintf("/v2/tests/api/%d", id), bytes.NewBufferString("{}"), nil) diff --git a/syntheticsclientv2/get_apicheckv2_test.go b/syntheticsclientv2/get_apicheckv2_test.go index 600915e..499fa84 100644 --- a/syntheticsclientv2/get_apicheckv2_test.go +++ b/syntheticsclientv2/get_apicheckv2_test.go @@ -25,7 +25,7 @@ import ( ) var ( - getApiCheckV2Body = `{"test":{"id":489,"name":"Appinspect login API","active":true, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "frequency":5,"scheduling_strategy":"round_robin","created_at":"2022-08-16T15:47:43.730Z","updated_at":"2022-08-16T15:47:43.741Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","createdBy":"abc1234","updatedBy":"abc1234","location_ids":["aws-us-east-1"],"type":"api","device":{"id":1,"label":"Desktop","user_agent":"Mozilla/5.0 (X11; Linux x86_64; Splunk Synthetics) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36","viewport_width":1366,"viewport_height":768,"network_connection":{"description":"Standard Cable","upload_bandwidth":5000,"download_bandwidth":20000,"latency":28,"packet_loss":null}},"requests":[{"configuration":{"name":"Login","url":"https://api.splunk.com/2.0/rest/login/splunk","requestMethod":"GET","headers":{},"body":null},"setup":[],"validations":[]}]}}` + getApiCheckV2Body = `{"test":{"id":489,"name":"Appinspect login API","active":true, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "frequency":5,"scheduling_strategy":"round_robin","created_at":"2022-08-16T15:47:43.730Z","updated_at":"2022-08-16T15:47:43.741Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","createdBy":"abc1234","updatedBy":"abc1234","location_ids":["aws-us-east-1"],"type":"api","deviceId":1,"requests":[{"configuration":{"name":"Login","url":"https://api.splunk.com/2.0/rest/login/splunk","requestMethod":"GET","headers":{},"body":null},"setup":[],"validations":[]}]}}` inputGetApiCheckV2 = verifyApiCheckV2Input(string(getApiCheckV2Body)) ) @@ -33,7 +33,7 @@ func TestGetApiCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/api/489", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/api/489", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") _, err := w.Write([]byte(getApiCheckV2Body)) if err != nil { @@ -74,12 +74,8 @@ func TestGetApiCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Updatedat, inputGetApiCheckV2.Test.Updatedat) } - if !reflect.DeepEqual(resp.Test.Device, inputGetApiCheckV2.Test.Device) { - t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Device, inputGetApiCheckV2.Test.Device) - } - - if !reflect.DeepEqual(resp.Test.Device.Viewportheight, inputGetApiCheckV2.Test.Device.Viewportheight) { - t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Device.Viewportheight, inputGetApiCheckV2.Test.Device.Viewportheight) + if !reflect.DeepEqual(resp.Test.Deviceid, inputGetApiCheckV2.Test.Deviceid) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Deviceid, inputGetApiCheckV2.Test.Deviceid) } if !reflect.DeepEqual(resp.Test.Requests, inputGetApiCheckV2.Test.Requests) { diff --git a/syntheticsclientv2/get_browsercheckv2.go b/syntheticsclientv2/get_browsercheckv2.go index f263b0b..8f528fa 100644 --- a/syntheticsclientv2/get_browsercheckv2.go +++ b/syntheticsclientv2/get_browsercheckv2.go @@ -32,7 +32,7 @@ func parseGetBrowserCheckV2Response(response string) (*BrowserCheckV2Response, e } func (c Client) GetBrowserCheckV2(id int) (*BrowserCheckV2Response, *RequestDetails, error) { - details, err := c.makePublicAPICall("GET", fmt.Sprintf("/tests/browser/%d", id), bytes.NewBufferString("{}"), nil) + details, err := c.makePublicAPICall("GET", fmt.Sprintf("/v2/tests/browser/%d", id), bytes.NewBufferString("{}"), nil) // Check for errors if err != nil { diff --git a/syntheticsclientv2/get_browsercheckv2_test.go b/syntheticsclientv2/get_browsercheckv2_test.go index 01b6251..779430e 100644 --- a/syntheticsclientv2/get_browsercheckv2_test.go +++ b/syntheticsclientv2/get_browsercheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - getBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "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,"excludedFiles": [{"type": "google_analytics"},{"type": "custom","regex": "some-domain.com"},{"type": "all_except","regex": "another-domain.com"}]},"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,"waitForNavTimeout":2000,"waitForNavTimeoutDefault":true,"maxWaitTime":10000,"maxWaitTimeDefault":true}]}],"type":"browser","updatedAt":"2022-09-14T14:35:38.099Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","createdBy":"abc1234","updatedBy":"abc1234"}}` + getBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "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,"excludedFiles": [{"type": "google_analytics"},{"type": "custom","regex": "some-domain.com"},{"type": "all_except","regex": "another-domain.com"}]},"createdAt":"2022-09-14T14:35:37.801Z","deviceId":1,"frequency":5,"id":1,"locationIds":["na-us-virginia"],"name":"My Test","schedulingStrategy":"round_robin","transactions":[{"name":"Example transaction","steps":[{"name":"element step","selectors":[{"type":"css","value":".main"}],"type":"click_element","waitForNav":true,"waitForNavTimeout":2000,"waitForNavTimeoutDefault":true,"maxWaitTime":10000,"maxWaitTimeDefault":true}]}],"type":"browser","updatedAt":"2022-09-14T14:35:38.099Z","lastRunAt":"2024-03-07T00:47:43.741Z","lastRunStatus":"success","createdBy":"abc1234","updatedBy":"abc1234"}}` inputGetBrowserCheckV2 = verifyBrowserCheckV2Input(string(getBrowserCheckV2Body)) expectedBrowserCheckV2 = BrowserCheckV2Response{ Test: BrowserCheckV2ResponseTest{ @@ -53,20 +53,8 @@ var ( }, Verifycertificates: true, }, - Createdat: time.Date(2022, 9, 14, 14, 35, 37, 801000000, time.UTC), - Device: Device{ - ID: 1, - Label: "iPhone", - Networkconnection: Networkconnection{ - Description: "Mobile LTE", - Downloadbandwidth: 12000, - Latency: 70, - Packetloss: 0, - Uploadbandwidth: 12000, - }, - Viewportheight: 844, - Viewportwidth: 375, - }, + Createdat: time.Date(2022, 9, 14, 14, 35, 37, 801000000, time.UTC), + Deviceid: 1, Frequency: 5, ID: 1, Locationids: []string{"na-us-virginia"}, @@ -78,8 +66,7 @@ var ( StepsV2: []StepsV2{ { Name: "element step", - Selector: ".main", - SelectorType: "css", + Selectors: []Selector{{Type: "css", Value: ".main"}}, Type: "click_element", WaitForNav: true, WaitForNavTimeout: 2000, @@ -104,7 +91,7 @@ func TestGetBrowserCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/browser/1", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/browser/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") _, err := w.Write([]byte(getBrowserCheckV2Body)) if err != nil { @@ -150,8 +137,8 @@ func TestGetBrowserCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Updatedat, inputGetBrowserCheckV2.Test.Updatedat) } - if !reflect.DeepEqual(resp.Test.Device, inputGetBrowserCheckV2.Test.Device) { - t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Device, inputGetBrowserCheckV2.Test.Device) + if !reflect.DeepEqual(resp.Test.Deviceid, inputGetBrowserCheckV2.Test.Deviceid) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Deviceid, inputGetBrowserCheckV2.Test.Deviceid) } if !reflect.DeepEqual(resp.Test.Advancedsettings, inputGetBrowserCheckV2.Test.Advancedsettings) { diff --git a/syntheticsclientv2/get_checksv2.go b/syntheticsclientv2/get_checksv2.go index 700d395..c4ad302 100644 --- a/syntheticsclientv2/get_checksv2.go +++ b/syntheticsclientv2/get_checksv2.go @@ -108,7 +108,7 @@ func integersQueryParam(params []int, queryParamName string) string { if len(params) == 0 { return "" } - return queryParamName + strings.Trim(strings.Replace(fmt.Sprint(params), " ", queryParamName, -1), "[]") + return queryParamName + strings.Trim(strings.ReplaceAll(fmt.Sprint(params), " ", queryParamName), "[]") } func stringsQueryParam(params []string, queryParamName string) string { diff --git a/syntheticsclientv2/integration_test.go b/syntheticsclientv2/integration_test.go index 57521e3..4d48d0d 100644 --- a/syntheticsclientv2/integration_test.go +++ b/syntheticsclientv2/integration_test.go @@ -40,19 +40,19 @@ var ( inputHttpCheckV2Data = HttpCheckV2Input{} updateHttpCheckV2Body = `{"test":{"name":"a-maximal-http-integration-test-update","type":"http", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"url":"https://www.splunk.com/updated","locationIds":["aws-us-east-1","aws-ap-southeast-2","aws-ap-southeast-4"],"frequency":30,"schedulingStrategy":"round_robin","active":true,"requestMethod":"GET","body":null,"headers":[{"name":"header-1","value":"value-1"},{"name":"header_2","value":"value_2"}],"validations":[{"type":"assert_string","actual":"{{response.first_byte_time}}","expected":"100","comparator":"equals"},{"type":"assert_string","actual":"{{headers.Content-Length}}","expected":"100","comparator":"does_not_equal"}],"userAgent":"user-agent_standards met","authentication":{"username":"beepusers","password":"{{env.terraform-test-foo-301}}"},"verifyCertificates":true}}` updateHttpCheckV2Data = HttpCheckV2Input{} - createMaximalBrowserCheckV2Body = `{"test":{"name":"a-maximal-browser-beep-test", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectorType":"id","selector":"selectionz","optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectorType":"link","selector":"beepval","variableName":"{{env.terraform-test-foo-301}}"},{"name":"Wait","type":"wait","duration":1312},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":5,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"cookies":[{"key":"super","value":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}]}}}` + createMaximalBrowserCheckV2Body = `{"test":{"name":"a-maximal-browser-beep-test", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectors":[{"type":"id","value":"clicky"}],"waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectors":[{"type":"id","value":"beep"}],"value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectors":[{"type":"id","value":"selectionz"}],"optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectors":[{"type":"id","value":"textzz"}],"optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectors":[{"type":"id","value":"valz"}],"optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectors":[{"type":"link","value":"beepval"}],"variableName":"{{env.terraform-test-foo-301}}"},{"name":"Wait","type":"wait","duration":1312},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":5,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"cookies":[{"key":"super","value":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}]}}}` createMinimalBrowserCheckV2Body = `{"test":{"name":"a-minimal-browser-beep-test", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url"}]}],"locationIds":["aws-us-east-1"],"deviceId":1,"frequency":5,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true}}}` inputBrowserCheckV2Data = BrowserCheckV2Input{} - updateBrowserCheckV2Body = `{"test":{"name":"a-browser-beep-test", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectorType":"id","selector":"selectionz","optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectorType":"link","selector":"beepval","variableName":"{{env.terraform-test-foo-301}}"},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":15,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"cookies":[{"key":"super","value":"dooper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}]}}}` + updateBrowserCheckV2Body = `{"test":{"name":"a-browser-beep-test", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectors":[{"type":"id","value":"clicky"}],"waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectors":[{"type":"id","value":"beep"}],"value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectors":[{"type":"id","value":"selectionz"}],"optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectors":[{"type":"id","value":"textzz"}],"optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectors":[{"type":"id","value":"valz"}],"optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectors":[{"type":"link","value":"beepval"}],"variableName":"{{env.terraform-test-foo-301}}"},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":15,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"cookies":[{"key":"super","value":"dooper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}]}}}` updateBrowserCheckV2Data = BrowserCheckV2Input{} createPortCheckV2Body = `{"test":{"name":"a - port 443 check","type":"port", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"url":"","port":443,"protocol":"tcp","host":"www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true}}` inputPortCheckV2Data = PortCheckV2Input{} updatePortCheckV2Body = `{"test":{"name":"a2 - port 443 check","type":"port", "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"url":"","port":448,"protocol":"tcp","host":"www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true}}` updatePortCheckV2Data = PortCheckV2Input{} - createApiV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"locationIds":["aws-us-east-1"],"name":"a-maximual-API-boop-test","schedulingStrategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/489","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells","beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"sd","variable":"extractsetupvar"},{"name":"JavaScript run","type":"javascript","code":"asdasd","variable":"jsvarsetup"},{"name":"Save response body","type":"save","value":"{{response.body}}","variable":"savesetupvar"}],"validations":[{"name":"JavaScript run","type":"javascript","code":"codetorun","variable":"jscodevar"},{"name":"Save response body","type":"save","value":"{{response.body}}","variable":"saverespvar"},{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"},{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"js.extractor","variable":"extractjvar"}]}]}}` - createMinimalApiV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"locationIds":["aws-us-east-1"],"name":"a-minimal-API-boop-test","schedulingStrategy":"round_robin","requests":[{"configuration":{"name":"apishortGet-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/489"}}]}}` + createApiV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"locationIds":["aws-us-east-1"],"name":"a-maximual-API-boop-test","schedulingStrategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/v2/tests/api/489","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells","beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"sd","variable":"extractsetupvar"},{"name":"JavaScript run","type":"javascript","code":"asdasd","variable":"jsvarsetup"},{"name":"Save response body","type":"save","value":"{{response.body}}","variable":"savesetupvar"}],"validations":[{"name":"JavaScript run","type":"javascript","code":"codetorun","variable":"jscodevar"},{"name":"Save response body","type":"save","value":"{{response.body}}","variable":"saverespvar"},{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"},{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"js.extractor","variable":"extractjvar"}]}]}}` + createMinimalApiV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"locationIds":["aws-us-east-1"],"name":"a-minimal-API-boop-test","schedulingStrategy":"round_robin","requests":[{"configuration":{"name":"apishortGet-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/v2/tests/api/489"}}]}}` inputApiCheckV2Data = ApiCheckV2Input{} - updateApiCheckV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"locationIds":["aws-us-east-1"],"name":"a-API-boop-test","schedulingStrategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod": "GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/4892","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells", "beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}` + updateApiCheckV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5, "automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"locationIds":["aws-us-east-1"],"name":"a-API-boop-test","schedulingStrategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod": "GET","url":"https://api.us1.signalfx.com/v2/synthetics/v2/tests/api/4892","headers":{"X-SF-TOKEN":"jinglebellsbatmanshells", "beep":"boop"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}` updateApiCheckV2Data = ApiCheckV2Input{} inputDowntimeConfigurationV2Data = DowntimeConfigurationV2Input{} updateDowntimeConfigurationV2Data = DowntimeConfigurationV2Input{} diff --git a/syntheticsclientv2/synthetics.go b/syntheticsclientv2/synthetics.go index 57e8722..53acb1a 100644 --- a/syntheticsclientv2/synthetics.go +++ b/syntheticsclientv2/synthetics.go @@ -19,7 +19,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/http/httputil" "time" @@ -111,7 +110,7 @@ func (c Client) makePublicAPICall(method string, endpoint string, requestBody io return &details, fmt.Errorf("unknown error, status code: %d", resp.StatusCode) } - responseBody, err := ioutil.ReadAll(resp.Body) + responseBody, err := io.ReadAll(resp.Body) if err != nil { return &details, err } diff --git a/syntheticsclientv2/synthetics_test.go b/syntheticsclientv2/synthetics_test.go index b6435ad..0965d20 100644 --- a/syntheticsclientv2/synthetics_test.go +++ b/syntheticsclientv2/synthetics_test.go @@ -84,7 +84,7 @@ func TestConfigurableClientTimeout(t *testing.T) { testMux = http.NewServeMux() testServer = httptest.NewServer(testMux) - testMux.HandleFunc("/tests/browser/12", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/browser/12", func(w http.ResponseWriter, r *http.Request) { time.Sleep(2 * time.Second) }) diff --git a/syntheticsclientv2/update_apicheckv2.go b/syntheticsclientv2/update_apicheckv2.go index 9983f12..0df3d49 100644 --- a/syntheticsclientv2/update_apicheckv2.go +++ b/syntheticsclientv2/update_apicheckv2.go @@ -48,7 +48,7 @@ func (c Client) UpdateApiCheckV2(id int, ApiCheckV2Details *ApiCheckV2Input) (*A return nil, nil, err } - requestDetails, err := c.makePublicAPICall("PUT", fmt.Sprintf("/tests/api/%d", id), bytes.NewBuffer(body), nil) + requestDetails, err := c.makePublicAPICall("PUT", fmt.Sprintf("/v2/tests/api/%d", id), bytes.NewBuffer(body), nil) if err != nil { return nil, requestDetails, err } diff --git a/syntheticsclientv2/update_apicheckv2_test.go b/syntheticsclientv2/update_apicheckv2_test.go index a5a2124..2045fba 100644 --- a/syntheticsclientv2/update_apicheckv2_test.go +++ b/syntheticsclientv2/update_apicheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - updateApiCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"device_id":4,"frequency":5,"location_ids":["aws-us-east-1","aws-ap-northeast-1"],"name":"boop-test","scheduling_strategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/tests/api/489","headers":{"beep":"boop","X-SF-TOKEN":"jinglebellsbatmanshells"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}` + updateApiCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "active":true,"deviceId":4,"frequency":5,"location_ids":["aws-us-east-1","aws-ap-northeast-1"],"name":"boop-test","scheduling_strategy":"round_robin","requests":[{"configuration":{"name":"Get-Test","requestMethod":"GET","url":"https://api.us1.signalfx.com/v2/synthetics/v2/tests/api/489","headers":{"beep":"boop","X-SF-TOKEN":"jinglebellsbatmanshells"},"body":null},"setup":[{"name":"Extract from response body","type":"extract_json","source":"{{response.body}}","extractor":"$.requests","variable":"custom-varz"}],"validations":[{"name":"Assert response code equals 200","type":"assert_numeric","actual":"{{response.code}}","expected":"200","comparator":"equals"}]}]}}` inputApiCheckV2Update = ApiCheckV2Input{} ) @@ -34,7 +34,7 @@ func TestUpdateApiCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/api/10", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/api/10", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") _, err := w.Write([]byte(updateApiCheckV2Body)) if err != nil { diff --git a/syntheticsclientv2/update_browsercheckv2.go b/syntheticsclientv2/update_browsercheckv2.go index 383a676..c8d5bca 100644 --- a/syntheticsclientv2/update_browsercheckv2.go +++ b/syntheticsclientv2/update_browsercheckv2.go @@ -39,7 +39,7 @@ func (c Client) UpdateBrowserCheckV2(id int, BrowserCheckV2Details *BrowserCheck return nil, nil, err } - requestDetails, err := c.makePublicAPICall("PUT", fmt.Sprintf("/tests/browser/%d", id), bytes.NewBuffer(body), nil) + requestDetails, err := c.makePublicAPICall("PUT", fmt.Sprintf("/v2/tests/browser/%d", id), bytes.NewBuffer(body), nil) if err != nil { return nil, requestDetails, err } diff --git a/syntheticsclientv2/update_browsercheckv2_test.go b/syntheticsclientv2/update_browsercheckv2_test.go index 672955e..9b3de5e 100644 --- a/syntheticsclientv2/update_browsercheckv2_test.go +++ b/syntheticsclientv2/update_browsercheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - updateBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"browser-beep-test","transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectorType":"id","selector":"selectionz","optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectorType":"link","selector":"beepval","variableName":"{{env.terraform-test-foo-301}}"},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":15,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"chromeFlags":[{"name":"--proxy-bypass-list","value":"127.0.0.1:8080"}],"cookies":[{"key":"super","value":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}],"excludedFiles":[{"type":"google_analytics"},{"type":"custom","regex":"some-domain.com"},{"type":"all_except","regex":"another-domain.com"}]}}}` + updateBrowserCheckV2Body = `{"test":{"automaticRetries": 1, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"browser-beep-test","transactions":[{"name":"Synthetic transaction 1","steps":[{"name":"Go to URL","type":"go_to_url","url":"https://splunk.com","action":"go_to_url","options":{"url":"https://splunk.com"}},{"name":"click","type":"click_element","selectors":[{"type":"id","value":"clicky"}],"waitForNav":true,"waitForNavTimeout":2000},{"name":"fill in fieldz","type":"enter_value","selectors":[{"type":"id","value":"beep"}],"value":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"accept---Alert","type":"accept_alert"},{"name":"Select-Val-Index","type":"select_option","selectors":[{"type":"id","value":"selectionz"}],"optionSelectorType":"index","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-val-text","type":"select_option","selectors":[{"type":"id","value":"textzz"}],"optionSelectorType":"text","optionSelector":"sdad","waitForNav":false,"waitForNavTimeout":50},{"name":"Select-Val-Val","type":"select_option","selectors":[{"type":"id","value":"valz"}],"optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false,"waitForNavTimeout":50},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true,"waitForNavTimeout":2000},{"name":"Save as text","type":"store_variable_from_element","selectors":[{"type":"link","value":"beepval"}],"variableName":"{{env.terraform-test-foo-301}}"},{"name":"Save JS return Val","type":"store_variable_from_javascript","value":"sdasds","variableName":"{{env.terraform-test-foo-301}}","waitForNav":true,"waitForNavTimeout":2000}]}],"urlProtocol":"https://","startUrl":"www.splunk.com","locationIds":["aws-us-east-1"],"deviceId":1,"frequency":15,"schedulingStrategy":"round_robin","active":true,"advancedSettings":{"verifyCertificates":true,"authentication":{"username":"boopuser","password":"{{env.beep-var}}"},"headers":[{"name":"batman","value":"Agentoz","domain":"www.batmansagent.com"}],"chromeFlags":[{"name":"--proxy-bypass-list","value":"127.0.0.1:8080"}],"cookies":[{"key":"super","value":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}],"excludedFiles":[{"type":"google_analytics"},{"type":"custom","regex":"some-domain.com"},{"type":"all_except","regex":"another-domain.com"}]}}}` inputBrowserCheckV2Update = BrowserCheckV2Input{} ) @@ -34,7 +34,7 @@ func TestUpdateBrowserCheckV2(t *testing.T) { setup() defer teardown() - testMux.HandleFunc("/tests/browser/10", func(w http.ResponseWriter, r *http.Request) { + testMux.HandleFunc("/v2/tests/browser/10", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") _, err := w.Write([]byte(updateBrowserCheckV2Body)) if err != nil {