merged branch sstok/browserkit-client-http-auth (PR #7059)
This PR was merged into the 2.2 branch.
Commits
-------
b240d1f
[BrowserKit] added a test to make sure HTTP authentication is preserved when submitting a form
Discussion
----------
[WIP]BrowserKit] added a test to make sure HTTP authentication is preserved
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | no
| Fixed tickets |
| License | MIT
| Doc PR |
Since #6995 BrowseKit no longer seems to preserve the HTTP authentication when submitting a form. This PR adds a test to demonstrate the failure.
---------------------------------------------------------------------------
by vicb at 2013-02-13T12:49:16Z
Thanks. Could you add a "[WIP]" prefix to the PR tittle and set "bug fix" to "no" for now ?
---------------------------------------------------------------------------
by sstok at 2013-02-13T13:59:42Z
done 👍
---------------------------------------------------------------------------
by fabpot at 2013-02-17T12:49:35Z
This cannot be related to #6995 as your test does not involve any HttpFoundation classes.
This commit is contained in:
commit
fc695f506f
@ -262,6 +262,37 @@ class ClientTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
|
||||
}
|
||||
|
||||
public function testSubmitPreserveAuth()
|
||||
{
|
||||
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
|
||||
$this->markTestSkipped('The "DomCrawler" component is not available');
|
||||
}
|
||||
|
||||
if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
|
||||
$this->markTestSkipped('The "CssSelector" component is not available');
|
||||
}
|
||||
|
||||
$client = new TestClient();
|
||||
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
|
||||
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar', array(), array(), array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar'));
|
||||
|
||||
$server = $client->getRequest()->getServer();
|
||||
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
|
||||
$this->assertEquals('foo', $server['PHP_AUTH_USER']);
|
||||
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
|
||||
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
|
||||
|
||||
$client->submit($crawler->filter('input')->form());
|
||||
|
||||
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
|
||||
|
||||
$server = $client->getRequest()->getServer();
|
||||
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
|
||||
$this->assertEquals('foo', $server['PHP_AUTH_USER']);
|
||||
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
|
||||
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
|
||||
}
|
||||
|
||||
public function testFollowRedirect()
|
||||
{
|
||||
$client = new TestClient();
|
||||
|
Reference in New Issue
Block a user