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

Recieved Error: Invalid cookie fields on passing Bearer token #8253

Closed
Awatatah opened this issue Aug 12, 2024 · 7 comments
Closed

Recieved Error: Invalid cookie fields on passing Bearer token #8253

Awatatah opened this issue Aug 12, 2024 · 7 comments
Labels
STATE: Need clarification An issue lacks information for further research. TYPE: bug The described behavior is considered as wrong (bug).

Comments

@Awatatah
Copy link

Awatatah commented Aug 12, 2024

What is your Scenario?

API test call with Authorization Bearer token header causes an error.

What is the Current behavior?

Getting the following errors when the test runs:

 ✖ Get Profile

   1) Error: Invalid cookie fields

      Browser: Chrome 127.0.0.0 / Ubuntu 22.04

         89 |                    if (error) {
         90 |                        const request = {method, params, sessionId};
         91 |                        reject(
         92 |                            error instanceof Error
         93 |                                ? error // low-level WebSocket error
       > 94 |                                : new ProtocolError(request, response)
         95 |                        );
         96 |                    } else {
         97 |                        fulfill(response);
         98 |                    }
         99 |                });

         at <anonymous> (/root/repos/XXXXXXXXX/node_modules/chrome-remote-interface/lib/chrome.js:94:35)
         at Chrome._handleMessage (/root/repos/XXXXXXXXX/node_modules/chrome-remote-interface/lib/chrome.js:272:17)
         at WebSocket.<anonymous> (/root/repos/XXXXXXXXX/node_modules/chrome-remote-interface/lib/chrome.js:240:22)
         at Receiver.receiverOnMessage (/root/repos/XXXXXXXXX/node_modules/ws/lib/websocket.js:1070:20)
         at Receiver.dataMessage (/root/repos/XXXXXXXXX/node_modules/ws/lib/receiver.js:517:14)

What is the Expected behavior?

To not receive error :)

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

N/A

What is your TestCafe test code?

fixture`Profile Login Test`;

let token = "";

test("Test Login", async (t) => {
  const results = await t.request({
    url: `${process.env.MY_AUTH_URL}/some/login`,
    method: "post",
    body: {
      email: process.env.MY_USERNAME,
      password: process.env.MYPASSWORD,
    },
  });

  await t
    .expect(results.status)
    .eql(200)
    .expect(results.headers)
    .contains({ "content-type": "application/json;charset=UTF-8" })
    .expect(results.body.accessToken)
    .ok();

  token = results.body.accessToken;
});

test("Get Profile", async (t) => {
  const results = await t.request({
    url: `${process.env.MY_AUTH_URL}/some/profile`,
    method: "get",
    headers: {
      Authorization: `Bearer ${token}`,
    },
  });

  await t
    .expect(results.status)
    .eql(200)
    .expect(results.headers)
    .contains({ "content-type": "application/json" })
    .expect(results.body.id)
    .ok();
});

Your complete configuration file

N/A

Your complete test report

N/A

Screenshots

N/A

Steps to Reproduce

Create a test with the mentioned code and run it

TestCafe version

3.x.x

Node.js version

22.1.0

Command-line arguments

testcafe 'chromium:headless --no-sandbox' main.js

Browser name(s) and version(s)

Chromium 127.0.6533.88 snap

Platform(s) and version(s)

Ubuntu 22.04

Other

This is a initial setup. There are no other tests.

@Awatatah Awatatah added the TYPE: bug The described behavior is considered as wrong (bug). label Aug 12, 2024
@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 12, 2024
@Awatatah
Copy link
Author

Additionally, I went back to version 2.6.2 and it works fine. I tested every minor release of version 3 and the error is present

@PavelMor25 PavelMor25 added STATE: Need simple sample A simple sample is required to examine the issue. and removed STATE: Need response An issue that requires a response or attention from the team. labels Aug 16, 2024
Copy link

Thank you for submitting a bug report. We would love to help you investigate the issue. Please share a simple code example that reliably reproduces the bug. For more information, read the following article: How To Create a Minimal Working Example When You Submit an Issue. We look forward to your response.

@github-actions github-actions bot added STATE: Need clarification An issue lacks information for further research. and removed STATE: Need simple sample A simple sample is required to examine the issue. labels Aug 16, 2024
Copy link

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

@Awatatah
Copy link
Author

Why was this closed? What sample did you need? @PavelMor25

@testcafe-need-response-bot testcafe-need-response-bot bot added the STATE: Need response An issue that requires a response or attention from the team. label Aug 26, 2024
@github-actions github-actions bot removed the STATE: Need clarification An issue lacks information for further research. label Aug 26, 2024
@github-actions github-actions bot reopened this Aug 26, 2024
@Awatatah
Copy link
Author

The issue is pretty straight forward based on the information I provided. spin up a basic bearer token auth API, and create a test that adds the authorization bearer token headers. When the tests runs, it will produce the Error: Invalid cookie fields error.

I had to revert to testcafe version 2.6.2 in order to get around the error. All 3.x versions produce this error

@Bayheck
Copy link
Collaborator

Bayheck commented Aug 30, 2024

Hello,

Please share a simple and reliable example, preferably in the form of a repository.

The repository should contain all the information and files necessary to reproduce the issue. Any user should be able to follow your instructions. Something like this:
image

See: How to create a Minimal Working Example when you submit an issue.

@Bayheck Bayheck added STATE: Need clarification An issue lacks information for further research. and removed STATE: Need response An issue that requires a response or attention from the team. labels Aug 30, 2024
Copy link

github-actions bot commented Sep 9, 2024

This issue was automatically closed because there was no response to our request for more information from the original author. Currently, we don't have enough information to take action. Please reach out to us if you find the necessary information and are able to share it. We are also eager to know if you resolved the issue on your own and can share your findings with everyone.

@github-actions github-actions bot closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATE: Need clarification An issue lacks information for further research. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

3 participants