From 489610636262eee23169dc3436ba85eb7e6e3f8e Mon Sep 17 00:00:00 2001 From: Simran Khalsa <68570441+skhalsa-sigsci@users.noreply.github.com> Date: Thu, 23 Jan 2025 12:02:00 -0800 Subject: [PATCH] update --- api.go | 30 +++++++++++++++--------------- api_test.go | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/api.go b/api.go index e3002d6..e0dae28 100644 --- a/api.go +++ b/api.go @@ -3040,14 +3040,14 @@ func (sc *Client) UpdateEdgeDeploymentBackends(corpName, siteName, fastlySID str return err } -// Simulator request the sample request and response for the simulator test -type SimulatorBody struct { +// Simulation request the sample request and response for the simulation test +type SimulationBody struct { SampleRequest string `json:"sample_request"` SampleResponse string `json:"sample_response"` } -// SimulatorResponse the response of the simulator test -type ResponseSimulatorBody struct { +// SimulationResponse the response of the simulation test +type ResponseSimulationBody struct { Data struct { WafResponse int `json:"waf_response"` ResponseCode int `json:"response_code"` @@ -3063,25 +3063,25 @@ type ResponseSimulatorBody struct { } `json:"data"` } -// getSimulatorOutput gets the simulator output -func getResponseSimulatorBody(response []byte) (ResponseSimulatorBody, error) { - var responseSimulator ResponseSimulatorBody - err := json.Unmarshal(response, &responseSimulator) +// getSimulationOutput gets the simulation output +func getResponseSimulationBody(response []byte) (ResponseSimulationBody, error) { + var responseSimulation ResponseSimulationBody + err := json.Unmarshal(response, &responseSimulation) if err != nil { - return ResponseSimulatorBody{}, err + return ResponseSimulationBody{}, err } - return responseSimulator, nil + return responseSimulation, nil } -// SendSimulator sends a simulator test to -func (sc *Client) SendSimulator(corpName, siteName string, body SimulatorBody) (ResponseSimulatorBody, error) { +// SendSimulation sends a simulation test to +func (sc *Client) SendSimulation(corpName, siteName string, body SimulationBody) (ResponseSimulationBody, error) { b, err := json.Marshal(body) if err != nil { - return ResponseSimulatorBody{}, err + return ResponseSimulationBody{}, err } resp, err := sc.doRequest("POST", fmt.Sprintf("/v0/corps/%s/sites/%s/simulator", corpName, siteName), string(b)) if err != nil { - return ResponseSimulatorBody{}, err + return ResponseSimulationBody{}, err } - return getResponseSimulatorBody(resp) + return getResponseSimulationBody(resp) } diff --git a/api_test.go b/api_test.go index b8c255b..a7251d7 100644 --- a/api_test.go +++ b/api_test.go @@ -1887,22 +1887,22 @@ func TestCRUDSiteRequestRule(t *testing.T) { } } -func TestSendSimulator(t *testing.T) { +func TestSendSimulation(t *testing.T) { sc := NewTokenClient(testcreds.email, testcreds.token) corp := testcreds.corp site := testcreds.site - body := SimulatorBody{ + body := SimulationBody{ // sample request with xss paylaod SampleRequest: `POST /?q= HTTP/1.1\nHost: sample.foo\n\n`, SampleResponse: `HTTP/1.1 200 OK`, } - responseSimulator, err := sc.SendSimulator(corp, site, body) + responseSimulation, err := sc.SendSimulation(corp, site, body) if err != nil { t.Fatal(err) } // check for XSS signal found := false - for _, signal := range responseSimulator.Data.Signals { + for _, signal := range responseSimulation.Data.Signals { if signal.Type == "XSS" { found = true }