Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestLogger gzip response body corrupted in Native Automation #8114

Closed
codambro opened this issue Jan 5, 2024 · 2 comments
Closed

RequestLogger gzip response body corrupted in Native Automation #8114

codambro opened this issue Jan 5, 2024 · 2 comments
Labels
HAS WORKAROUND TYPE: bug The described behavior is considered as wrong (bug).

Comments

@codambro
Copy link

codambro commented Jan 5, 2024

What is your Scenario?

Trying to log all requests and responses using RequestLogger. Some responses are gzip bodies. I am unable to unzip them when running with native automation.

What is the Current behavior?

Trying to unzip compressed response bodies fails with native automation

What is the Expected behavior?

body unzips normally

What is the public URL of the test page? (attach your complete example)

https://testkenna.kennasecurity.com/users/sign_in

What is your TestCafe test code?

import { RequestLogger } from "testcafe";
import zlib from "zlib";

const url = "https://testkenna.kennasecurity.com/users/sign_in";

// create and attach request logger
const requestLogger = RequestLogger(url, { logResponseHeaders: true, logResponseBody: true })

fixture("Fixture").requestHooks(requestLogger);

test("Test", async t => {
    // go to URL that gives gzip response and wait for it to load
    await t.navigateTo(url);
    await t.wait(3000);

    // verify response status 200 and header indicates gzip
    const resp = requestLogger.requests[0].response;
    await t.expect(resp.statusCode).eql(200);
    await t.expect(resp.headers["content-encoding"]).eql("gzip");

    // decompress body
    const buffer = resp.body;
    const decoded = zlib.gunzipSync(buffer);
    console.log(decoded.toString());
})

With Native Automation:

 Fixture
 ✖ Test (screenshots:
 /Users/codambro/Documents/GitHub/KennaSecurity/qa-automation-e2e/results/screenshots/Chrome_120.0.0.0_macOS_10.15.7/Fixture_Test_1.png)

   1) Error: incorrect header check

      Browser: Chrome 120.0.0.0 / macOS 10.15.7
      Screenshot:
      /Users/codambro/Documents/GitHub/KennaSecurity/qa-automation-e2e/results/screenshots/Chrome_120.0.0.0_macOS_10.15.7/Fixture_Test_1.png

With disableNativeAutomation: true

Fixture

<!DOCTYPE html>
<html lang="en">
  <head>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,600' rel='stylesheet' type='text/css'>

<meta charset="utf-8">


<title>Cisco</title>
...
... 
...
  </body>
</html>

 ✓ Test


 1 passed (9s)

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

see above

TestCafe version

3.5.0

Node.js version

No response

Command-line arguments

using testcafe runner api

Browser name(s) and version(s)

chrome

Platform(s) and version(s)

macOS

Other

No response

@codambro codambro added the TYPE: bug The described behavior is considered as wrong (bug). label Jan 5, 2024
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 5, 2024
@Bayheck
Copy link
Collaborator

Bayheck commented Jan 8, 2024

Hello,
I managed to reproduce the issue. As a workaround, you can use stringifyResponseBody in RequestLogger Constructor options. Please try this solution and let us know if you encounter any issues.

@Bayheck Bayheck added HAS WORKAROUND and removed STATE: Need response An issue that requires a response or attention from the team. labels Jan 8, 2024
@codambro
Copy link
Author

codambro commented Jan 8, 2024

Interesting. With disableNativeAutomation, using stringifyResponseBody returned garbage data since it was gzip. But I do see stringifyResponseBody does return the correct string format. good to know

@codambro codambro closed this as completed Jan 8, 2024
@need-response-app need-response-app bot added STATE: Need response An issue that requires a response or attention from the team. and removed STATE: Need response An issue that requires a response or attention from the team. labels Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HAS WORKAROUND TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

2 participants