|
const | REALM = 'SabreDAV unittest' |
|
Definition at line 8 of file AWSTest.php.
◆ hmacsha1()
Sabre\HTTP\Auth\AWSTest::hmacsha1 |
( |
|
$key, |
|
|
|
$message |
|
) |
| |
|
private |
Generates an HMAC-SHA1 signature.
- Parameters
-
string | $key | |
string | $message | |
- Returns
- string
Definition at line 222 of file AWSTest.php.
References $key, and $message.
Referenced by Sabre\HTTP\Auth\AWSTest\testValidRequest().
225 if (strlen(
$key) > $blocksize)
227 $key = str_pad(
$key, $blocksize, chr(0x00));
228 $ipad = str_repeat(chr(0x36), $blocksize);
229 $opad = str_repeat(chr(0x5c), $blocksize);
230 $hmac = pack(
'H*', sha1((
$key ^ $opad) . pack(
'H*', sha1((
$key ^ $ipad) .
$message))));
catch(Exception $e) $message
◆ setUp()
Sabre\HTTP\Auth\AWSTest::setUp |
( |
| ) |
|
Definition at line 27 of file AWSTest.php.
29 $this->response =
new Response();
30 $this->request =
new Request();
31 $this->auth =
new AWS(self::REALM, $this->request, $this->response);
◆ test401()
Sabre\HTTP\Auth\AWSTest::test401 |
( |
| ) |
|
Definition at line 207 of file AWSTest.php.
References $test.
209 $this->auth->requireLogin();
210 $test = preg_match(
'/^AWS$/', $this->response->getHeader(
'WWW-Authenticate'), $matches);
211 $this->assertTrue(
$test ==
true,
'The WWW-Authenticate response didn\'t match our pattern');
◆ testFutureDate()
Sabre\HTTP\Auth\AWSTest::testFutureDate |
( |
| ) |
|
Definition at line 88 of file AWSTest.php.
References $result, and Sabre\HTTP\Auth\AWS\ERR_REQUESTTIMESKEWED.
90 $accessKey =
'accessKey';
91 $secretKey =
'secretKey';
92 $content =
'thisisthebody';
93 $contentMD5 = base64_encode(md5($content,
true));
95 $date = new \DateTime(
'@' . (time() + (60 * 20)));
97 $date = $date->format(
'D, d M Y H:i:s \\G\\M\\T');
99 $this->request->setMethod(
'POST');
100 $this->request->setHeaders([
101 'Authorization' =>
"AWS $accessKey:sig",
102 'Content-MD5' => $contentMD5,
106 $this->request->setBody($content);
109 $result = $this->auth->validate($secretKey);
const ERR_REQUESTTIMESKEWED
◆ testIncorrectContentMD5()
Sabre\HTTP\Auth\AWSTest::testIncorrectContentMD5 |
( |
| ) |
|
Definition at line 45 of file AWSTest.php.
References $result, and Sabre\HTTP\Auth\AWS\ERR_MD5CHECKSUMWRONG.
47 $accessKey =
'accessKey';
48 $secretKey =
'secretKey';
50 $this->request->setMethod(
'GET');
51 $this->request->setHeaders([
52 'Authorization' =>
"AWS $accessKey:sig",
53 'Content-MD5' =>
'garbage',
55 $this->request->setUrl(
'/');
58 $result = $this->auth->validate($secretKey);
const ERR_MD5CHECKSUMWRONG
◆ testIncorrectSignature()
Sabre\HTTP\Auth\AWSTest::testIncorrectSignature |
( |
| ) |
|
Definition at line 144 of file AWSTest.php.
References $result, and Sabre\HTTP\Auth\AWS\ERR_INVALIDSIGNATURE.
146 $accessKey =
'accessKey';
147 $secretKey =
'secretKey';
148 $content =
'thisisthebody';
150 $contentMD5 = base64_encode(md5($content,
true));
152 $date = new \DateTime(
'now');
154 $date = $date->format(
'D, d M Y H:i:s \\G\\M\\T');
156 $this->request->setUrl(
'/');
157 $this->request->setMethod(
'POST');
158 $this->request->setHeaders([
159 'Authorization' =>
"AWS $accessKey:sig",
160 'Content-MD5' => $contentMD5,
161 'X-amz-date' => $date,
163 $this->request->setBody($content);
166 $result = $this->auth->validate($secretKey);
const ERR_INVALIDSIGNATURE
◆ testNoDate()
Sabre\HTTP\Auth\AWSTest::testNoDate |
( |
| ) |
|
Definition at line 65 of file AWSTest.php.
References $result, and Sabre\HTTP\Auth\AWS\ERR_INVALIDDATEFORMAT.
67 $accessKey =
'accessKey';
68 $secretKey =
'secretKey';
69 $content =
'thisisthebody';
70 $contentMD5 = base64_encode(md5($content,
true));
72 $this->request->setMethod(
'POST');
73 $this->request->setHeaders([
74 'Authorization' =>
"AWS $accessKey:sig",
75 'Content-MD5' => $contentMD5,
77 $this->request->setUrl(
'/');
78 $this->request->setBody($content);
81 $result = $this->auth->validate($secretKey);
const ERR_INVALIDDATEFORMAT
◆ testNoHeader()
Sabre\HTTP\Auth\AWSTest::testNoHeader |
( |
| ) |
|
◆ testPastDate()
Sabre\HTTP\Auth\AWSTest::testPastDate |
( |
| ) |
|
Definition at line 116 of file AWSTest.php.
References $result, and Sabre\HTTP\Auth\AWS\ERR_REQUESTTIMESKEWED.
118 $accessKey =
'accessKey';
119 $secretKey =
'secretKey';
120 $content =
'thisisthebody';
121 $contentMD5 = base64_encode(md5($content,
true));
123 $date = new \DateTime(
'@' . (time() - (60 * 20)));
125 $date = $date->format(
'D, d M Y H:i:s \\G\\M\\T');
127 $this->request->setMethod(
'POST');
128 $this->request->setHeaders([
129 'Authorization' =>
"AWS $accessKey:sig",
130 'Content-MD5' => $contentMD5,
134 $this->request->setBody($content);
137 $result = $this->auth->validate($secretKey);
const ERR_REQUESTTIMESKEWED
◆ testValidRequest()
Sabre\HTTP\Auth\AWSTest::testValidRequest |
( |
| ) |
|
Definition at line 173 of file AWSTest.php.
References $result, and Sabre\HTTP\Auth\AWSTest\hmacsha1().
175 $accessKey =
'accessKey';
176 $secretKey =
'secretKey';
177 $content =
'thisisthebody';
178 $contentMD5 = base64_encode(md5($content,
true));
180 $date = new \DateTime(
'now');
182 $date = $date->format(
'D, d M Y H:i:s \\G\\M\\T');
185 $sig = base64_encode($this->
hmacsha1($secretKey,
186 "POST\n$contentMD5\n\n$date\nx-amz-date:$date\n/evert" 189 $this->request->setUrl(
'/evert');
190 $this->request->setMethod(
'POST');
191 $this->request->setHeaders([
192 'Authorization' =>
"AWS $accessKey:$sig",
193 'Content-MD5' => $contentMD5,
194 'X-amz-date' => $date,
197 $this->request->setBody($content);
200 $result = $this->auth->validate($secretKey);
202 $this->assertTrue(
$result,
'Signature did not validate, got errorcode ' . $this->auth->errorCode);
203 $this->assertEquals($accessKey, $this->auth->getAccessKey());
hmacsha1($key, $message)
Generates an HMAC-SHA1 signature.
◆ $auth
Sabre\HTTP\Auth\AWSTest::$auth |
|
private |
◆ $request
Sabre\HTTP\Auth\AWSTest::$request |
|
private |
◆ $response
Sabre\HTTP\Auth\AWSTest::$response |
|
private |
◆ REALM
const Sabre\HTTP\Auth\AWSTest::REALM = 'SabreDAV unittest' |
The documentation for this class was generated from the following file:
- libs/composer/vendor/sabre/http/tests/HTTP/Auth/AWSTest.php