8000 merged branch sstok/browserkit-client-http-auth (PR #7059) · symfony/symfony@fc695f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc695f5

Browse files
committed
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 :+1: --------------------------------------------------------------------------- by fabpot at 2013-02-17T12:49:35Z This cannot be related to #6995 as your test does not involve any HttpFoundation classes.
2 parents 7d4d1f8 + b240d1f commit fc695f5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/Symfony/Component/BrowserKit/Tests/ClientTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,37 @@ public function testSubmit()
262262
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
263263
}
264264

265+
public function testSubmitPreserveAuth()
266+
{
267+
if (!class_exists('Symfony\Component\DomCrawler\Crawler')) {
268+
$this->markTestSkipped('The "DomCrawler" component is not available');
269+
}
270+
271+
if (!class_exists('Symfony\Component\CssSelector\CssSelector')) {
272+
$this->markTestSkipped('The "CssSelector" component is not available');
273+
}
274+
275+
$client = new TestClient();
276+
$client->setNextResponse(new Response('<html><form action="/foo"><input type="submit" /></form></html>'));
277+
$crawler = $client->request('GET', 'http://www.example.com/foo/foobar', array(), array(), array('PHP_AUTH_USER' => 'foo', 'PHP_AUTH_PW' => 'bar'));
278+
279+
$server = $client->getRequest()->getServer();
280+
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
281+
$this->assertEquals('foo', $server['PHP_AUTH_USER']);
282+
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
283+
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
284+
285+
$client->submit($crawler->filter('input')->form());
286+
287+
$this->assertEquals('http://www.example.com/foo', $client->getRequest()->getUri(), '->submit() submit forms');
288+
289+
$server = $client->getRequest()->getServer();
290+
$this->assertArrayHasKey('PHP_AUTH_USER', $server);
291+
$this->assertEquals('foo', $server['PHP_AUTH_USER']);
292+
$this->assertArrayHasKey('PHP_AUTH_PW', $server);
293+
$this->assertEquals('bar', $server['PHP_AUTH_PW']);
294+
}
295+
265296
public function testFollowRedirect()
266297
{
267298
$client = new TestClient();

0 commit comments

Comments
 (0)
0