From 32dd8315d36b8c4362b884dddce70e4d1bfbac41 Mon Sep 17 00:00:00 2001 From: Jeremy Hicks Date: Tue, 14 Nov 2023 12:53:30 -0500 Subject: [PATCH] Getting changes from Main into v2 (#14) * SYN-3197: Custom Properties * adds custom properties to integration tests. * add new CLA workflow * update readme and contributing docs * docs change --------- Co-authored-by: Brian Gustafson Co-authored-by: greatestusername-splunk <83726369+greatestusername-splunk@users.noreply.github.com> --- .github/workflows/cla.yaml | 53 +++++ .gitignore | 3 + CONTRIBUTING.md | 19 +- README.md | 23 ++- syntheticsclientv2/common_models.go | 184 ++++++++++-------- syntheticsclientv2/create_apicheckv2_test.go | 5 +- .../create_browsercheckv2_test.go | 5 +- syntheticsclientv2/create_httpcheckv2_test.go | 5 +- syntheticsclientv2/create_portcheckv2_test.go | 5 +- syntheticsclientv2/get_apicheckv2_test.go | 5 +- syntheticsclientv2/get_browsercheckv2_test.go | 5 +- syntheticsclientv2/get_httpcheckv2_test.go | 5 +- syntheticsclientv2/get_portcheckv2_test.go | 5 +- syntheticsclientv2/integration_test.go | 22 +-- syntheticsclientv2/update_apicheckv2_test.go | 5 +- .../update_browsercheckv2_test.go | 5 +- syntheticsclientv2/update_httpcheckv2_test.go | 5 +- syntheticsclientv2/update_portcheckv2_test.go | 5 +- 18 files changed, 242 insertions(+), 122 deletions(-) create mode 100644 .github/workflows/cla.yaml diff --git a/.github/workflows/cla.yaml b/.github/workflows/cla.yaml new file mode 100644 index 0000000..b6733f9 --- /dev/null +++ b/.github/workflows/cla.yaml @@ -0,0 +1,53 @@ +name: "CLA Assistant" +on: + issue_comment: + types: [created] + pull_request_target: + types: [opened, closed, synchronize] +# explicitly configure permissions, in case your GITHUB_TOKEN workflow permissions are set to read-only in repository settings +permissions: + actions: write + contents: write + pull-requests: write + statuses: write +jobs: + CLAAssistant: + runs-on: ubuntu-latest + steps: + - name: "CLA Assistant" + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target' + uses: contributor-assistant/github-action@v2.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # the below token should have repo scope and must be manually added by you in the repository's secret + # This token is required only if you have configured to store the signatures in a remote repository/organization + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + with: + path-to-signatures: 'signatures/version1/cla.json' + path-to-document: 'https://github.com/splunk/cla-agreement/blob/main/CLA.md' # e.g. a CLA or a DCO document + # branch should not be protected + branch: 'main' + allowlist: dependabot[bot] + remote-organization-name: splunk + remote-repository-name: cla-agreement + CodeOfConduct: + runs-on: ubuntu-latest + steps: + - name: "COC Assistant" + if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the Code of Conduct and I hereby accept the Terms') || github.event_name == 'pull_request_target' + uses: cla-assistant/github-action@v2.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + with: + path-to-signatures: "signatures/version1/coc.json" + path-to-document: "https://github.com/splunk/cla-agreement/blob/main/CODE_OF_CONDUCT.md" # e.g. a COC or a DCO document + branch: "main" + allowlist: dependabot[bot] + remote-organization-name: splunk + remote-repository-name: cla-agreement + custom-pr-sign-comment: "I have read the Code of Conduct and I hereby accept the Terms" + create-file-commit-message: "For example: Creating file for storing COC Signatures" + signed-commit-message: "$contributorName has signed the COC in #$pullRequestNo" + custom-notsigned-prcomment: "All contributors have NOT signed the COC Document" + custom-allsigned-prcomment: "****CLA Assistant Lite bot**** All contributors have signed the COC ✍️ ✅" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1ea71a6..ae03155 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ .DS_Store .vscode/settings.json + +# Jetbrains IDEs +.idea \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5be950c..b8d5347 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -13,7 +13,7 @@ If you are reporting a bug or issues, please include: - Operating system name and version. - Any details about your local setup that might be helpful - in troubleshooting (E.G. Python version if using a python script, Terraform version if you're using a Terraform script.). + in troubleshooting - Detailed steps to reproduce the bug. ### Fix Bugs @@ -23,17 +23,16 @@ a "bug" ticket type is open to whoever wants to implement it. ### Implement Features -If you have a great set of dashboards, detectors, API scripts for sending metrics, or any other content -you believe will be of use to others, please contribute it! - -Or check the Issues for this repo on GitHub. Anything tagged with "enhancement" +Please file an issue or check the issues for this repo on GitHub. Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it. +Once issues are posted and triaged please include their issue number in any PRs related to that work + ### Write Documentation Submissions and `README.md` files could always use more documentation. Documentation can always use an update or tweak in the official docs, in docstrings of scripts, comments in configs, or anywhere a bit of clarity may be useful.. -### Submit Feedback +### Submit Issues / Feedback If you are proposing a feature: @@ -47,9 +46,5 @@ If you are proposing a feature: Before you submit a pull request, check that it meets these guidelines: -1. The pull request should include a `README.md` for any new submission. -2. If the pull request adds functionality, the `README.md` docs for that component or submission should be updated. - Put your new functionality into a function with a docstring, and add - the feature to the list in README.md. -3. Terraform submissions should work with the most current version of the included Terraform Provider. -4. Python submissions should work for Python3 \ No newline at end of file +1. The pull request should include documentation and example changes for any new functionality. +2. If the pull request adds functionality, the tests should be updated. \ No newline at end of file diff --git a/README.md b/README.md index 4f5399d..80a6851 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # syntheticsclient -A Splunk Synthetics (Formerly Rigor) client for golang. +A Splunk Synthetics for Splunk Observability (Formerly Rigor) client for golang. ## Installation `go get https://github.com/splunk/syntheticsclient.git` @@ -52,4 +52,23 @@ func main() { API Docs are [available here](https://dev.splunk.com/observability/reference) ## Additional Information -This client is largely a copypasta mutation of the [go-victor](https://github.com/victorops/go-victorops) client for Splunk On-Call (formerly known as VictorOps). \ No newline at end of file +This client is largely a copypasta mutation of the [go-victor](https://github.com/victorops/go-victorops) client for Splunk On-Call (formerly known as VictorOps). + +## Contributions +Contributions are welcome and encouraged! + +Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for details on contributing to this repository. + +Before your contribution can be accepted, you will be asked to sign our +[Splunk Contributor License Agreement (CLA)](https://github.com/splunk/cla-agreement/blob/main/CLA.md). + +To agree to the CLA and COC please comment these in **separate individual messages** on your PR: + +CLA: +``` +I have read the CLA Document and I hereby sign the CLA +``` + +Code of Conduct: +``` +I have read the Code of Conduct and I hereby accept the Terms diff --git a/syntheticsclientv2/common_models.go b/syntheticsclientv2/common_models.go index 558d8fe..fcb2abe 100644 --- a/syntheticsclientv2/common_models.go +++ b/syntheticsclientv2/common_models.go @@ -140,15 +140,16 @@ type Validations struct { } type Tests []struct { - Active bool `json:"active"` - Createdat time.Time `json:"createdAt"` - Frequency int `json:"frequency"` - ID int `json:"id"` - Locationids []string `json:"locationIds"` - Name string `json:"name"` - Schedulingstrategy string `json:"schedulingStrategy"` - Type string `json:"type"` - Updatedat time.Time `json:"updatedAt"` + Active bool `json:"active"` + Createdat time.Time `json:"createdAt"` + Frequency int `json:"frequency"` + ID int `json:"id"` + Locationids []string `json:"locationIds"` + Name string `json:"name"` + Schedulingstrategy string `json:"schedulingStrategy"` + Type string `json:"type"` + Updatedat time.Time `json:"updatedAt"` + Customproperties []CustomProperties `json:"customProperties"` } type GetChecksV2Options struct { @@ -237,86 +238,91 @@ type ChecksV2Response struct { type PortCheckV2Response struct { Test struct { - ID int `json:"id"` - Name string `json:"name"` - Active bool `json:"active"` - Frequency int `json:"frequency"` - SchedulingStrategy string `json:"schedulingStrategy"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - LocationIds []string `json:"locationIds"` - Type string `json:"type"` - Protocol string `json:"protocol"` - Host string `json:"host"` - Port int `json:"port"` + ID int `json:"id"` + Name string `json:"name"` + Active bool `json:"active"` + Frequency int `json:"frequency"` + SchedulingStrategy string `json:"schedulingStrategy"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + LocationIds []string `json:"locationIds"` + Type string `json:"type"` + Protocol string `json:"protocol"` + Host string `json:"host"` + Port int `json:"port"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } type PortCheckV2Input struct { Test struct { - Name string `json:"name"` - Type string `json:"type"` - URL string `json:"url"` - Port int `json:"port"` - Protocol string `json:"protocol"` - Host string `json:"host"` - LocationIds []string `json:"locationIds"` - Frequency int `json:"frequency"` - SchedulingStrategy string `json:"schedulingStrategy"` - Active bool `json:"active"` + Name string `json:"name"` + Type string `json:"type"` + URL string `json:"url"` + Port int `json:"port"` + Protocol string `json:"protocol"` + Host string `json:"host"` + LocationIds []string `json:"locationIds"` + Frequency int `json:"frequency"` + SchedulingStrategy string `json:"schedulingStrategy"` + Active bool `json:"active"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } type HttpCheckV2Response struct { Test struct { - ID int `json:"id"` - Name string `json:"name"` - Active bool `json:"active"` - Frequency int `json:"frequency"` - SchedulingStrategy string `json:"schedulingStrategy"` - CreatedAt time.Time `json:"createdAt,omitempty"` - UpdatedAt time.Time `json:"updatedAt,omitempty"` - LocationIds []string `json:"locationIds"` - Type string `json:"type"` - URL string `json:"url"` - RequestMethod string `json:"requestMethod"` - Body string `json:"body,omitempty"` - Authentication *Authentication `json:"authentication"` - UserAgent *string `json:"userAgent"` - Verifycertificates bool `json:"verifyCertificates"` - HttpHeaders []HttpHeaders `json:"headers"` - Validations []Validations `json:"validations"` + ID int `json:"id"` + Name string `json:"name"` + Active bool `json:"active"` + Frequency int `json:"frequency"` + SchedulingStrategy string `json:"schedulingStrategy"` + CreatedAt time.Time `json:"createdAt,omitempty"` + UpdatedAt time.Time `json:"updatedAt,omitempty"` + LocationIds []string `json:"locationIds"` + Type string `json:"type"` + URL string `json:"url"` + RequestMethod string `json:"requestMethod"` + Body string `json:"body,omitempty"` + Authentication *Authentication `json:"authentication"` + UserAgent *string `json:"userAgent"` + Verifycertificates bool `json:"verifyCertificates"` + HttpHeaders []HttpHeaders `json:"headers,omitempty"` + Validations []Validations `json:"validations"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } type HttpCheckV2Input struct { Test struct { - Name string `json:"name"` - Type string `json:"type"` - URL string `json:"url"` - LocationIds []string `json:"locationIds"` - Frequency int `json:"frequency"` - SchedulingStrategy string `json:"schedulingStrategy"` - Active bool `json:"active"` - RequestMethod string `json:"requestMethod"` - Body string `json:"body,omitempty"` - Authentication *Authentication `json:"authentication"` - UserAgent *string `json:"userAgent"` - Verifycertificates bool `json:"verifyCertificates"` - HttpHeaders []HttpHeaders `json:"headers"` - Validations []Validations `json:"validations"` + Name string `json:"name"` + Type string `json:"type"` + URL string `json:"url"` + LocationIds []string `json:"locationIds"` + Frequency int `json:"frequency"` + SchedulingStrategy string `json:"schedulingStrategy"` + Active bool `json:"active"` + RequestMethod string `json:"requestMethod"` + Body string `json:"body,omitempty"` + Authentication *Authentication `json:"authentication"` + UserAgent *string `json:"userAgent"` + Verifycertificates bool `json:"verifyCertificates"` + HttpHeaders []HttpHeaders `json:"headers,omitempty"` + Validations []Validations `json:"validations"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } type ApiCheckV2Input struct { Test struct { - Active bool `json:"active"` - Deviceid int `json:"deviceId"` - Frequency int `json:"frequency"` - Locationids []string `json:"locationIds"` - Name string `json:"name"` - Requests []Requests `json:"requests"` - Schedulingstrategy string `json:"schedulingStrategy"` + Active bool `json:"active"` + Deviceid int `json:"deviceId"` + Frequency int `json:"frequency"` + Locationids []string `json:"locationIds"` + Name string `json:"name"` + Requests []Requests `json:"requests"` + Schedulingstrategy string `json:"schedulingStrategy"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } @@ -325,14 +331,15 @@ type ApiCheckV2Response struct { Active bool `json:"active"` Createdat time.Time `json:"createdAt"` Device `json:"device,omitempty"` - Frequency int `json:"frequency,omitempty"` - ID int `json:"id,omitempty"` - Locationids []string `json:"locationIds,omitempty"` - Name string `json:"name,omitempty"` - Requests []Requests `json:"requests,omitempty"` - Schedulingstrategy string `json:"schedulingStrategy,omitempty"` - Type string `json:"type,omitempty"` - Updatedat time.Time `json:"updatedAt,omitempty"` + Frequency int `json:"frequency,omitempty"` + ID int `json:"id,omitempty"` + Locationids []string `json:"locationIds,omitempty"` + Name string `json:"name,omitempty"` + Requests []Requests `json:"requests,omitempty"` + Schedulingstrategy string `json:"schedulingStrategy,omitempty"` + Type string `json:"type,omitempty"` + Updatedat time.Time `json:"updatedAt,omitempty"` + Customproperties []CustomProperties `json:"customProperties"` } } @@ -348,6 +355,7 @@ type BrowserCheckV2Input struct { Schedulingstrategy string `json:"schedulingStrategy"` Active bool `json:"active"` Advancedsettings `json:"advancedSettings,omitempty"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } @@ -357,13 +365,19 @@ type BrowserCheckV2Response struct { Advancedsettings `json:"advancedSettings"` Createdat time.Time `json:"createdAt"` Device `json:"device"` - Frequency int `json:"frequency"` - ID int `json:"id"` - Locationids []string `json:"locationIds"` - Name string `json:"name"` - Schedulingstrategy string `json:"schedulingStrategy"` - Transactions []Transactions `json:"transactions"` - Type string `json:"type"` - Updatedat time.Time `json:"updatedAt"` + Frequency int `json:"frequency"` + ID int `json:"id"` + Locationids []string `json:"locationIds"` + Name string `json:"name"` + Schedulingstrategy string `json:"schedulingStrategy"` + Transactions []Transactions `json:"transactions"` + Type string `json:"type"` + Updatedat time.Time `json:"updatedAt"` + Customproperties []CustomProperties `json:"customProperties"` } `json:"test"` } + +type CustomProperties struct { + Key string `json:"key"` + Value string `json:"value"` +} diff --git a/syntheticsclientv2/create_apicheckv2_test.go b/syntheticsclientv2/create_apicheckv2_test.go index 9eb1e60..7e3c991 100644 --- a/syntheticsclientv2/create_apicheckv2_test.go +++ b/syntheticsclientv2/create_apicheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - createApiV2Body = `{"test":{"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":{"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"}]}]}}` inputData = ApiCheckV2Input{} ) @@ -79,4 +79,7 @@ func TestCreateApiCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Schedulingstrategy, inputData.Test.Schedulingstrategy) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputData.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputData.Test.Customproperties) + } } diff --git a/syntheticsclientv2/create_browsercheckv2_test.go b/syntheticsclientv2/create_browsercheckv2_test.go index 2960704..2c333c0 100644 --- a/syntheticsclientv2/create_browsercheckv2_test.go +++ b/syntheticsclientv2/create_browsercheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - createBrowserCheckV2Body = `{"test":{"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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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"}]}}}` + createBrowserCheckV2Body = `{"test":{"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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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"}]}}}` inputBrowserCheckV2Data = BrowserCheckV2Input{} ) @@ -83,4 +83,7 @@ func TestCreateBrowserCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Schedulingstrategy, inputBrowserCheckV2Data.Test.Schedulingstrategy) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputBrowserCheckV2Data.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputBrowserCheckV2Data.Test.Customproperties) + } } diff --git a/syntheticsclientv2/create_httpcheckv2_test.go b/syntheticsclientv2/create_httpcheckv2_test.go index aebaf9c..3dcdb8a 100644 --- a/syntheticsclientv2/create_httpcheckv2_test.go +++ b/syntheticsclientv2/create_httpcheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - createHttpCheckV2Body = `{"test":{"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"}]}}` + 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"}]}}` inputHttpCheckV2Data = HttpCheckV2Input{} ) @@ -83,4 +83,7 @@ func TestCreateHttpCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.SchedulingStrategy, inputHttpCheckV2Data.Test.SchedulingStrategy) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputHttpCheckV2Data.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputHttpCheckV2Data.Test.Customproperties) + } } diff --git a/syntheticsclientv2/create_portcheckv2_test.go b/syntheticsclientv2/create_portcheckv2_test.go index fed9cab..3361569 100644 --- a/syntheticsclientv2/create_portcheckv2_test.go +++ b/syntheticsclientv2/create_portcheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - createPortCheckV2Body = `{"test":{"name":"splunk - port 443","type":"port","url":"","port":443,"protocol":"tcp","host":"www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true}}` + createPortCheckV2Body = `{"test":{"customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"splunk - port 443","type":"port","url":"","port":443,"protocol":"tcp","host":"www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true}}` inputPortCheckV2Data = PortCheckV2Input{} ) @@ -83,4 +83,7 @@ func TestCreatePortCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Port, inputPortCheckV2Data.Test.Port) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputPortCheckV2Data.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputPortCheckV2Data.Test.Customproperties) + } } diff --git a/syntheticsclientv2/get_apicheckv2_test.go b/syntheticsclientv2/get_apicheckv2_test.go index 645a750..677a61b 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,"frequency":5,"scheduling_strategy":"round_robin","created_at":"2022-08-16T15:47:43.730Z","updated_at":"2022-08-16T15:47:43.741Z","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, "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","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":[]}]}}` inputGetApiCheckV2 = verifyApiCheckV2Input(string(getApiCheckV2Body)) ) @@ -86,6 +86,9 @@ func TestGetApiCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Requests, inputGetApiCheckV2.Test.Requests) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputGetApiCheckV2.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputGetApiCheckV2.Test.Customproperties) + } } func verifyApiCheckV2Input(stringInput string) *ApiCheckV2Response { diff --git a/syntheticsclientv2/get_browsercheckv2_test.go b/syntheticsclientv2/get_browsercheckv2_test.go index cedcdc7..9b19caf 100644 --- a/syntheticsclientv2/get_browsercheckv2_test.go +++ b/syntheticsclientv2/get_browsercheckv2_test.go @@ -25,7 +25,7 @@ import ( ) var ( - getBrowserCheckV2Body = `{"test":{"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"}}` + getBrowserCheckV2Body = `{"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"}}` inputGetBrowserCheckV2 = verifyBrowserCheckV2Input(string(getBrowserCheckV2Body)) ) @@ -86,6 +86,9 @@ func TestGetBrowserCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Transactions, inputGetBrowserCheckV2.Test.Transactions) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputGetBrowserCheckV2.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputGetBrowserCheckV2.Test.Customproperties) + } } func verifyBrowserCheckV2Input(stringInput string) *BrowserCheckV2Response { diff --git a/syntheticsclientv2/get_httpcheckv2_test.go b/syntheticsclientv2/get_httpcheckv2_test.go index b80f0bc..d558df3 100644 --- a/syntheticsclientv2/get_httpcheckv2_test.go +++ b/syntheticsclientv2/get_httpcheckv2_test.go @@ -25,7 +25,7 @@ import ( ) var ( - getHttpCheckV2Body = `{"test":{"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"}}` + 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"}}` inputGetHttpCheckV2 = verifyHttpCheckV2Input(string(getHttpCheckV2Body)) ) @@ -98,6 +98,9 @@ func TestGetHttpCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.CreatedAt, inputGetHttpCheckV2.Test.CreatedAt) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputGetHttpCheckV2.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputGetHttpCheckV2.Test.Customproperties) + } } func verifyHttpCheckV2Input(stringInput string) *HttpCheckV2Response { diff --git a/syntheticsclientv2/get_portcheckv2_test.go b/syntheticsclientv2/get_portcheckv2_test.go index af8781f..c39e3ff 100644 --- a/syntheticsclientv2/get_portcheckv2_test.go +++ b/syntheticsclientv2/get_portcheckv2_test.go @@ -25,7 +25,7 @@ import ( ) var ( - getPortCheckV2Body = `{"test":{"id":1647,"name":"splunk - port 443","active":true,"frequency":10,"scheduling_strategy":"round_robin","created_at":"2022-11-21T15:38:54.546Z","updated_at":"2022-11-21T15:38:54.554Z","location_ids":["aws-us-east-1"],"type":"port","protocol":"tcp","host":"www.splunk.com","port":443}}` + getPortCheckV2Body = `{"test":{"id":1647, "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "name":"splunk - port 443","active":true,"frequency":10,"scheduling_strategy":"round_robin","created_at":"2022-11-21T15:38:54.546Z","updated_at":"2022-11-21T15:38:54.554Z","location_ids":["aws-us-east-1"],"type":"port","protocol":"tcp","host":"www.splunk.com","port":443}}` inputGetPortCheckV2 = verifyPortCheckV2Input(string(getPortCheckV2Body)) ) @@ -86,6 +86,9 @@ func TestGetPortCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Port, inputGetPortCheckV2.Test.Port) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputGetPortCheckV2.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputGetPortCheckV2.Test.Customproperties) + } } func verifyPortCheckV2Input(stringInput string) *PortCheckV2Response { diff --git a/syntheticsclientv2/integration_test.go b/syntheticsclientv2/integration_test.go index 9d5cf7b..b368a03 100644 --- a/syntheticsclientv2/integration_test.go +++ b/syntheticsclientv2/integration_test.go @@ -36,23 +36,23 @@ var ( updateVariableV2Data = VariableV2Input{} createLocationV2Body = `{"location":{"id":"private-data-center-go-test","label":"Data Center place", "default":false}}` inputLocationV2Data = LocationV2Input{} - createHttpCheckV2Body = `{"test":{"name":"a-minimal-http-integration-test","type":"http","url":"https://www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true,"requestMethod":"GET","body":null,"userAgent":null,"authentication":null,"verifyCertificates":false}}` + createHttpCheckV2Body = `{"test":{"name":"a-minimal-http-integration-test","type":"http","customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}],"url":"https://www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true,"requestMethod":"GET","body":null,"userAgent":null,"authentication":null,"verifyCertificates":false}}` inputHttpCheckV2Data = HttpCheckV2Input{} - updateHttpCheckV2Body = `{"test":{"name":"a-maximal-http-integration-test-update","type":"http","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}}` + updateHttpCheckV2Body = `{"test":{"name":"a-maximal-http-integration-test-update","type":"http","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","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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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","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}}}` + createMaximalBrowserCheckV2Body = `{"test":{"name":"a-maximal-browser-beep-test","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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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","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","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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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","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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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","url":"","port":443,"protocol":"tcp","host":"www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true}}` + createPortCheckV2Body = `{"test":{"name":"a - port 443 check","type":"port","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","url":"","port":448,"protocol":"tcp","host":"www.splunk.com","locationIds":["aws-us-east-1"],"frequency":10,"schedulingStrategy":"round_robin","active":true}}` + updatePortCheckV2Body = `{"test":{"name":"a2 - port 443 check","type":"port","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,"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,"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,"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,"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"}}]}}` inputApiCheckV2Data = ApiCheckV2Input{} - updateApiCheckV2Body = `{"test":{"active":true,"deviceId":1,"frequency":5,"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,"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"}]}]}}` updateApiCheckV2Data = ApiCheckV2Input{} ) @@ -251,7 +251,7 @@ func CreateHttpCheckV2(test string, c *Client) (int, error) { } func UpdateHttpCheckV2(checkId int, test string, c *Client) error { - + err := json.Unmarshal([]byte(test), &inputHttpCheckV2Data) if err != nil { return err diff --git a/syntheticsclientv2/update_apicheckv2_test.go b/syntheticsclientv2/update_apicheckv2_test.go index f683257..28fefe4 100644 --- a/syntheticsclientv2/update_apicheckv2_test.go +++ b/syntheticsclientv2/update_apicheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - updateApiCheckV2Body = `{"test":{"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":{"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"}]}]}}` inputApiCheckV2Update = ApiCheckV2Input{} ) @@ -78,4 +78,7 @@ func TestUpdateApiCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Schedulingstrategy, inputApiCheckV2Update.Test.Schedulingstrategy) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputApiCheckV2Update.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputApiCheckV2Update.Test.Customproperties) + } } diff --git a/syntheticsclientv2/update_browsercheckv2_test.go b/syntheticsclientv2/update_browsercheckv2_test.go index 0a2b307..77b4ae9 100644 --- a/syntheticsclientv2/update_browsercheckv2_test.go +++ b/syntheticsclientv2/update_browsercheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - updateBrowserCheckV2Body = `{"test":{"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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}]}}}` + updateBrowserCheckV2Body = `{"test":{"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"},"waitForNav":true},{"name":"click","type":"click_element","selectorType":"id","selector":"clicky","waitForNav":true},{"name":"fill in fieldz","type":"enter_value","selectorType":"id","selector":"beep","value":"{{env.beep-var}}","waitForNav":false},{"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},{"name":"Select-val-text","type":"select_option","selectorType":"id","selector":"textzz","optionSelectorType":"text","optionSelector":"sdad","waitForNav":false},{"name":"Select-Val-Val","type":"select_option","selectorType":"id","selector":"valz","optionSelectorType":"value","optionSelector":"{{env.beep-var}}","waitForNav":false},{"name":"Run JS","type":"run_javascript","value":"beeeeeeep","waitForNav":true},{"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}]}],"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":"duper","domain":"www.batmansagent.com","path":"/boom/goes/beep"}]}}}` inputBrowserCheckV2Update = BrowserCheckV2Input{} ) @@ -58,4 +58,7 @@ func TestUpdateBrowserCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Name, inputBrowserCheckV2Update.Test.Name) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputBrowserCheckV2Update.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputBrowserCheckV2Update.Test.Customproperties) + } } diff --git a/syntheticsclientv2/update_httpcheckv2_test.go b/syntheticsclientv2/update_httpcheckv2_test.go index d8794ac..c462c7c 100644 --- a/syntheticsclientv2/update_httpcheckv2_test.go +++ b/syntheticsclientv2/update_httpcheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - updateHttpCheckV2Body = `{"test":{"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"}]}}` + 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"}]}}` inputHttpCheckV2Update = HttpCheckV2Input{} ) @@ -58,4 +58,7 @@ func TestUpdateHttpCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Name, inputHttpCheckV2Update.Test.Name) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputHttpCheckV2Update.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputHttpCheckV2Update.Test.Customproperties) + } } diff --git a/syntheticsclientv2/update_portcheckv2_test.go b/syntheticsclientv2/update_portcheckv2_test.go index 47186fd..925c18f 100644 --- a/syntheticsclientv2/update_portcheckv2_test.go +++ b/syntheticsclientv2/update_portcheckv2_test.go @@ -26,7 +26,7 @@ import ( ) var ( - updatePortCheckV2Body = `{"test":{"name":"splunk - port 443","type":"port","url":"","port":80,"protocol":"tcp","host":"www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true}}` + updatePortCheckV2Body = `{"test":{"name":"splunk - port 443", "customProperties": [{"key": "Test_Key", "value": "Test Custom Properties"}], "type":"port","url":"","port":80,"protocol":"tcp","host":"www.splunk.com","location_ids":["aws-us-east-1"],"frequency":10,"scheduling_strategy":"round_robin","active":true}}` inputPortCheckV2Update = PortCheckV2Input{} ) @@ -58,4 +58,7 @@ func TestUpdatePortCheckV2(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Name, inputPortCheckV2Update.Test.Name) } + if !reflect.DeepEqual(resp.Test.Customproperties, inputPortCheckV2Update.Test.Customproperties) { + t.Errorf("returned \n\n%#v want \n\n%#v", resp.Test.Customproperties, inputPortCheckV2Update.Test.Customproperties) + } }