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

testing HTTP request withPlainCookie() always encodes the cookie #87

Open
jared-f opened this issue Jul 9, 2024 · 2 comments
Open

testing HTTP request withPlainCookie() always encodes the cookie #87

jared-f opened this issue Jul 9, 2024 · 2 comments

Comments

@jared-f
Copy link

jared-f commented Jul 9, 2024

Package version

7.2.3

Describe the bug

I am trying to make an API Client test using HTTP client that has a simple plain cookie set.

When I try sending a request using withPlainCookie I can see in the route under test that the cookie is base64 encoded json string of my plain cookie value set in the test.

I would like to be able to disable the encoding on that cookie so that in the route handler I can access ctx.request.plainCookie('sauce', { encoded: false }) and retrieve the value.

Below are some example code:

// test

 test('It creates a taco', async ({ client, assert }) => {
    const companyName = 'Acme Inc'
    const response = await client
      .post('/tacos')
      .withPlainCookie('sauce','spicy')
      .form({ toppings: [ 'cilantro'] })
      .withCsrfToken()
    response.assertStatus(200)
    const taco = await Taco.findBy({ toppings: 'cilantro' })
    assert.ok(taco, 'It should make a tacos')
  })

In the route when I inspect ctx.request.plainCookie('sauce') I have a string like this:
eyJtZXNzYWdlIjogInNwaWN5In0=

which is a json object like this:

{ "message": "spicy"}

and should be a simply spicy.

Thanks

Reproduction repo

No response

@jared-f
Copy link
Author

jared-f commented Jul 9, 2024

@RomainLanz
Copy link
Member

Hey @jared-f! 👋🏻

Would you mind creating a PR with a failing test to help illustrate the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants