|
const | REALM = 'SabreDAV unittest' |
|
Definition at line 8 of file DigestTest.php.
◆ getServerTokens()
Definition at line 165 of file DigestTest.php.
References $test, Sabre\HTTP\Auth\Digest\QOP_AUTH, Sabre\HTTP\Auth\Digest\QOP_AUTHINT, and Sabre\HTTP\Auth\DigestTest\setUp().
Referenced by Sabre\HTTP\Auth\DigestTest\testDigest(), Sabre\HTTP\Auth\DigestTest\testDigestAuthBoth(), Sabre\HTTP\Auth\DigestTest\testDigestAuthInt(), and Sabre\HTTP\Auth\DigestTest\testInvalidDigest().
167 $this->auth->requireLogin();
172 default : $qopstr =
'auth,auth-int';
break;
175 $test = preg_match(
'/Digest realm="' . self::REALM .
'",qop="' . $qopstr .
'",nonce="([0-9a-f]*)",opaque="([0-9a-f]*)"/',
176 $this->response->getHeader(
'WWW-Authenticate'), $matches);
178 $this->assertTrue(
$test ==
true,
'The WWW-Authenticate response didn\'t match our pattern. We received: ' . $this->response->getHeader(
'WWW-Authenticate'));
180 $nonce = $matches[1];
181 $opaque = $matches[2];
185 $this->auth->setQOP($qop);
187 return [$nonce,$opaque];
const QOP_AUTH
These constants are used in setQOP();.
◆ setUp()
Sabre\HTTP\Auth\DigestTest::setUp |
( |
| ) |
|
◆ testDigest()
Sabre\HTTP\Auth\DigestTest::testDigest |
( |
| ) |
|
Definition at line 38 of file DigestTest.php.
References $password, and Sabre\HTTP\Auth\DigestTest\getServerTokens().
48 md5($username .
':' . self::REALM .
':' .
$password) .
':' .
53 md5(
'GET' .
':' .
'/')
56 $this->request->setMethod(
'GET');
57 $this->request->setHeader(
'Authorization',
'Digest username="' . $username .
'", realm="' . self::REALM .
'", nonce="' . $nonce .
'", uri="/", response="' . $digestHash .
'", opaque="' . $opaque .
'", qop=auth,nc=' . $nc .
',cnonce="' . $cnonce .
'"');
61 $this->assertEquals($username, $this->auth->getUsername());
62 $this->assertEquals(self::REALM, $this->auth->getRealm());
63 $this->assertTrue($this->auth->validateA1(md5($username .
':' . self::REALM .
':' . $password)),
'Authentication is deemed invalid through validateA1');
64 $this->assertTrue($this->auth->validatePassword($password),
'Authentication is deemed invalid through validatePassword');
getServerTokens($qop=Digest::QOP_AUTH)
◆ testDigestAuthBoth()
Sabre\HTTP\Auth\DigestTest::testDigestAuthBoth |
( |
| ) |
|
Definition at line 135 of file DigestTest.php.
References $password, Sabre\HTTP\Auth\DigestTest\getServerTokens(), Sabre\HTTP\Auth\Digest\QOP_AUTH, and Sabre\HTTP\Auth\Digest\QOP_AUTHINT.
146 md5($username .
':' . self::REALM .
':' .
$password) .
':' .
151 md5(
'POST' .
':' .
'/' .
':' . md5(
'body'))
154 $this->request->setMethod(
'POST');
155 $this->request->setHeader(
'Authorization',
'Digest username="' . $username .
'", realm="' . self::REALM .
'", nonce="' . $nonce .
'", uri="/", response="' . $digestHash .
'", opaque="' . $opaque .
'", qop=auth-int,nc=' . $nc .
',cnonce="' . $cnonce .
'"');
156 $this->request->setBody(
'body');
160 $this->assertTrue($this->auth->validateA1(md5($username .
':' . self::REALM .
':' . $password)),
'Authentication is deemed invalid through validateA1');
const QOP_AUTH
These constants are used in setQOP();.
getServerTokens($qop=Digest::QOP_AUTH)
◆ testDigestAuthInt()
Sabre\HTTP\Auth\DigestTest::testDigestAuthInt |
( |
| ) |
|
Definition at line 106 of file DigestTest.php.
References $password, Sabre\HTTP\Auth\DigestTest\getServerTokens(), and Sabre\HTTP\Auth\Digest\QOP_AUTHINT.
117 md5($username .
':' . self::REALM .
':' .
$password) .
':' .
122 md5(
'POST' .
':' .
'/' .
':' . md5(
'body'))
125 $this->request->setMethod(
'POST');
126 $this->request->setHeader(
'Authorization',
'Digest username="' . $username .
'", realm="' . self::REALM .
'", nonce="' . $nonce .
'", uri="/", response="' . $digestHash .
'", opaque="' . $opaque .
'", qop=auth-int,nc=' . $nc .
',cnonce="' . $cnonce .
'"');
127 $this->request->setBody(
'body');
131 $this->assertTrue($this->auth->validateA1(md5($username .
':' . self::REALM .
':' . $password)),
'Authentication is deemed invalid through validateA1');
getServerTokens($qop=Digest::QOP_AUTH)
◆ testInvalidDigest()
Sabre\HTTP\Auth\DigestTest::testInvalidDigest |
( |
| ) |
|
Definition at line 68 of file DigestTest.php.
References $password, and Sabre\HTTP\Auth\DigestTest\getServerTokens().
78 md5($username .
':' . self::REALM .
':' .
$password) .
':' .
83 md5(
'GET' .
':' .
'/')
86 $this->request->setMethod(
'GET');
87 $this->request->setHeader(
'Authorization',
'Digest username="' . $username .
'", realm="' . self::REALM .
'", nonce="' . $nonce .
'", uri="/", response="' . $digestHash .
'", opaque="' . $opaque .
'", qop=auth,nc=' . $nc .
',cnonce="' . $cnonce .
'"');
91 $this->assertFalse($this->auth->validateA1(md5($username .
':' . self::REALM .
':' . ($password .
'randomness'))),
'Authentication is deemed invalid through validateA1');
getServerTokens($qop=Digest::QOP_AUTH)
◆ testInvalidDigest2()
Sabre\HTTP\Auth\DigestTest::testInvalidDigest2 |
( |
| ) |
|
Definition at line 95 of file DigestTest.php.
97 $this->request->setMethod(
'GET');
98 $this->request->setHeader(
'Authorization',
'basic blablabla');
101 $this->assertFalse($this->auth->validateA1(md5(
'user:realm:password')));
◆ $auth
Sabre\HTTP\Auth\DigestTest::$auth |
|
private |
◆ $request
Sabre\HTTP\Auth\DigestTest::$request |
|
private |
◆ $response
Sabre\HTTP\Auth\DigestTest::$response |
|
private |
◆ REALM
const Sabre\HTTP\Auth\DigestTest::REALM = 'SabreDAV unittest' |
The documentation for this class was generated from the following file: