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

Getting invalid cookie exception #2234

Closed
abaklanov opened this issue Aug 3, 2015 · 9 comments
Closed

Getting invalid cookie exception #2234

abaklanov opened this issue Aug 3, 2015 · 9 comments
Assignees

Comments

@abaklanov
Copy link

Hello there.

I'm trying to build an acceptance test for my local project using Codeception 2.1. Everything was doing fine until I got to submit a paypal form, a paypal button. Here's how it looks:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="BUTTONID">
<input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

When I try to submit it, Codeception goes

* I submit form "form:nth-child(3)",
  [Uri] https://www.sandbox.paypal.com/cgi-bin/webscr
  [Method] POST
  [Parameters] {"cmd":"_s-xclick","hosted_button_id":"BUTTONID"}
 ERROR 

And then fires up the following error:

[RuntimeException] Invalid cookie: The cookie value must not be empty

I do NOT set any cookie manually. You can see it in my cest file:

<?php
use \AcceptanceTester;

class SubscriptionCest
{
    public function _before(AcceptanceTester $I)
    {
    }

    public function _after(AcceptanceTester $I)
    {
    }

    // Main function
    public function run(AcceptanceTester $I)
    {
        $I->am("New user");
        $I->wantTo("purchase a membership");
        $I->amOnPage("/subscription");

        $I->submitForm("form:nth-child(3)", []);
    }
}

Why am i getting this error?

@Naktibalda
Copy link
Member

Paypal images are setting cookies:

https://www.sandbox.paypal.com/en_US/i/btn/btn_subscribeCC_LG.gif
Set-Cookie
X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D880%26app%3Dappdispatcher%26TIME%3D1266073429; domain=.paypal.com; path=/; Secure; HttpOnly
X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT

@Naktibalda
Copy link
Member

Please run the test with -vvv option to get more information.

@abaklanov
Copy link
Author

@Naktibalda, yep. Thanks for the reply.
I've removed the image from the form and it looks like headers from https://www.sandbox.paypal.com/cgi-bin/webscr contain this as well:

Set-Cookie:X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT

But how can I evict/dodge or somehow manage this cookie setting with Codeception?

@Naktibalda
Copy link
Member

I did a quick investigation before making the previous comment and it looks like a bug in Symfony BrowserKit to me.

I will investigate it more and try to fix it later.

@Naktibalda Naktibalda self-assigned this Aug 4, 2015
@Naktibalda
Copy link
Member

Actually it is an issue of Guzzle,
I reported it here - guzzle/guzzle#1205

@Naktibalda
Copy link
Member

It is a bad day for me - I was wrong again.
It was a fault of Codeception, because Codeception creates a CookieJar with strictMode turned on.

return new CookieJar(true, $jar);

Naktibalda added a commit to Naktibalda/Codeception that referenced this issue Aug 4, 2015
Naktibalda added a commit to Naktibalda/Codeception that referenced this issue Aug 4, 2015
@abaklanov
Copy link
Author

@Naktibalda Thanks for your help.
When will it be turned into a phar?

@Naktibalda
Copy link
Member

I don't know for sure, but it should happen over the next few weeks.

If you need this patch now, install codeception/codeception: 2.1-dev with composer.

@abaklanov
Copy link
Author

@Naktibalda Thanks a lot.

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