Skip to content

Commit

Permalink
[HttpFoundation] added some missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Sep 1, 2014
1 parent cefe237 commit 3b4046e
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Symfony/Component/HttpFoundation/Tests/ServerBagTest.php
Expand Up @@ -71,19 +71,20 @@ public function testHttpBasicAuthWithPhpCgiBogus()
{
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar')));

$this->assertEquals(array(
'AUTHORIZATION' => 'Basic_'.base64_encode('foo:bar'),
), $bag->getHeaders());
// Username and passwords should not be set as the header is bogus
$headers = $bag->getHeaders();
$this->assertFalse(isset($headers['PHP_AUTH_USER']));
$this->assertFalse(isset($headers['PHP_AUTH_PW']));
}

public function testHttpBasicAuthWithPhpCgiRedirect()
{
$bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('foo:bar')));
$bag = new ServerBag(array('REDIRECT_HTTP_AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word')));

$this->assertEquals(array(
'AUTHORIZATION' => 'Basic '.base64_encode('foo:bar'),
'PHP_AUTH_USER' => 'foo',
'PHP_AUTH_PW' => 'bar'
'AUTHORIZATION' => 'Basic '.base64_encode('username:pass:word'),
'PHP_AUTH_USER' => 'username',
'PHP_AUTH_PW' => 'pass:word'
), $bag->getHeaders());
}

Expand Down Expand Up @@ -114,9 +115,10 @@ public function testHttpDigestAuthWithPhpCgiBogus()
$digest = 'Digest_username="foo", realm="acme", nonce="'.md5('secret').'", uri="/protected, qop="auth"';
$bag = new ServerBag(array('HTTP_AUTHORIZATION' => $digest));

$this->assertEquals(array(
'AUTHORIZATION' => $digest,
), $bag->getHeaders());
// Username and passwords should not be set as the header is bogus
$headers = $bag->getHeaders();
$this->assertFalse(isset($headers['PHP_AUTH_USER']));
$this->assertFalse(isset($headers['PHP_AUTH_PW']));
}

public function testHttpDigestAuthWithPhpCgiRedirect()
Expand Down

0 comments on commit 3b4046e

Please sign in to comment.