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 with unencrypted cookies doesn't work #31282

Closed
gjm opened this issue Jan 29, 2020 · 2 comments · Fixed by #31390
Closed

Testing with unencrypted cookies doesn't work #31282

gjm opened this issue Jan 29, 2020 · 2 comments · Fixed by #31390
Labels

Comments

@gjm
Copy link

gjm commented Jan 29, 2020

  • Laravel Version: 6.11.0
  • PHP Version: 7.4
  • Database Driver & Version: n/a

Description:

I have configured a cookie not to be encrypted in App\Http\Middleware\EncryptCookies middleware. This cookie is used in another middleware, along with other (normally encrypted) cookies.

When I'm testing the middleware, I can't access both types of cookies. Either I can access the unencrypted one (using disableCookieEncryption) or the encrypted one.

Steps To Reproduce:

Configure the cookie name plain not to be encrypted in App\Http\Middleware\EncryptCookies:

class EncryptCookies extends BaseEncrypter
{
    protected $except = [
        'plain',
    ];
}

With this test I can only access plain cookie (encrypted is null):

public function testCanAccessCookies ()
{
    $this->disableCookieEncryption()
         ->withCookie('plain', 'plain value')
         ->withCookie('encrypted', 'encrypted value')
         ->get('/');
}

With this test I can only access encrypted cookie (plain is the encrypted string value):

public function testCanAccessCookies ()
{
    $this->withCookie('plain', 'plain value')
         ->withCookie('encrypted', 'encrypted value')
         ->get('/');
}
@driesvints
Copy link
Member

You seem to be correct. The except property isn't taken into account when using this method.

@gentcys
Copy link
Contributor

gentcys commented Feb 7, 2020

@driesvints i want to help to solve this problem, so i create a PR about my solution. If there are some suggestions, that would be great.

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

Successfully merging a pull request may close this issue.

3 participants