summaryrefslogtreecommitdiffstats
path: root/tests/lib/appframework/http/RequestTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/appframework/http/RequestTest.php')
-rw-r--r--tests/lib/appframework/http/RequestTest.php84
1 files changed, 6 insertions, 78 deletions
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index bb9910b6a46..f628a30f1da 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -54,7 +54,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -87,7 +86,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -110,7 +108,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -130,7 +127,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -150,7 +146,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -167,7 +162,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -189,7 +183,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -213,7 +206,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -235,7 +227,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -260,7 +251,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -281,7 +271,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -306,7 +295,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -336,7 +324,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -358,7 +345,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
$vars,
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -382,7 +368,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -394,7 +379,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
\OC::$server->getSecureRandom(),
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -419,7 +403,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -448,7 +431,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -477,7 +459,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -510,7 +491,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -561,7 +541,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -589,7 +568,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -611,7 +589,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -622,7 +599,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -646,7 +622,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -667,7 +642,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -684,7 +658,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -705,7 +678,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -727,7 +699,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -816,7 +787,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -833,7 +803,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -851,7 +820,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -869,7 +837,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -897,7 +864,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -919,7 +885,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -946,7 +911,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -973,7 +937,6 @@ class RequestTest extends \Test\TestCase {
],
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -990,7 +953,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1018,7 +980,6 @@ class RequestTest extends \Test\TestCase {
$request = new Request(
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1034,7 +995,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1055,7 +1015,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1076,7 +1035,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1099,7 +1057,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1122,7 +1079,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1145,7 +1101,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1168,7 +1123,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1223,7 +1177,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
);
@@ -1263,7 +1216,6 @@ class RequestTest extends \Test\TestCase {
]
],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
])
@@ -1277,25 +1229,17 @@ class RequestTest extends \Test\TestCase {
}
public function testPassesCSRFCheckWithGet() {
- $crypto = $this->getMock('\OCP\Security\ICrypto');
- $crypto
- ->expects($this->once())
- ->method('decrypt')
- ->with('1c637c4147e40a8a8f09428ec2059cebea3480c27b402b4e793c69710a731513|wlXxNUaFqHuQnZr5|e6ab49c9e0e20c8d3607e02f1d8e6ec17ad6020ae10b7d64ab4b0a6318c0875940943a6aa303dc090fea0b4cd5b9fb8bcbecac4308a2bd15d9f369cdc22121a4', 'secret')
- ->will($this->returnValue('MyStoredRequestToken'));
-
/** @var Request $request */
$request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
->setMethods(['getScriptName'])
->setConstructorArgs([
[
'get' => [
- 'requesttoken' => '1c637c4147e40a8a8f09428ec2059cebea3480c27b402b4e793c69710a731513|wlXxNUaFqHuQnZr5|e6ab49c9e0e20c8d3607e02f1d8e6ec17ad6020ae10b7d64ab4b0a6318c0875940943a6aa303dc090fea0b4cd5b9fb8bcbecac4308a2bd15d9f369cdc22121a4:secret',
+ 'requesttoken' => 'AAAHGxsTCTc3BgMQESAcNR0OAR0=:MyTotalSecretShareds',
],
'requesttoken' => 'MyStoredRequestToken',
],
$this->secureRandom,
- $crypto,
$this->config,
$this->stream
])
@@ -1305,25 +1249,17 @@ class RequestTest extends \Test\TestCase {
}
public function testPassesCSRFCheckWithPost() {
- $crypto = $this->getMock('\OCP\Security\ICrypto');
- $crypto
- ->expects($this->once())
- ->method('decrypt')
- ->with('1c637c4147e40a8a8f09428ec2059cebea3480c27b402b4e793c69710a731513|wlXxNUaFqHuQnZr5|e6ab49c9e0e20c8d3607e02f1d8e6ec17ad6020ae10b7d64ab4b0a6318c0875940943a6aa303dc090fea0b4cd5b9fb8bcbecac4308a2bd15d9f369cdc22121a4', 'secret')
- ->will($this->returnValue('MyStoredRequestToken'));
-
/** @var Request $request */
$request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
->setMethods(['getScriptName'])
->setConstructorArgs([
[
'post' => [
- 'requesttoken' => '1c637c4147e40a8a8f09428ec2059cebea3480c27b402b4e793c69710a731513|wlXxNUaFqHuQnZr5|e6ab49c9e0e20c8d3607e02f1d8e6ec17ad6020ae10b7d64ab4b0a6318c0875940943a6aa303dc090fea0b4cd5b9fb8bcbecac4308a2bd15d9f369cdc22121a4:secret',
+ 'requesttoken' => 'AAAHGxsTCTc3BgMQESAcNR0OAR0=:MyTotalSecretShareds',
],
'requesttoken' => 'MyStoredRequestToken',
],
$this->secureRandom,
- $crypto,
$this->config,
$this->stream
])
@@ -1333,24 +1269,17 @@ class RequestTest extends \Test\TestCase {
}
public function testPassesCSRFCheckWithHeader() {
- $crypto = $this->getMock('\OCP\Security\ICrypto');
- $crypto
- ->expects($this->once())
- ->method('decrypt')
- ->with('1c637c4147e40a8a8f09428ec2059cebea3480c27b402b4e793c69710a731513|wlXxNUaFqHuQnZr5|e6ab49c9e0e20c8d3607e02f1d8e6ec17ad6020ae10b7d64ab4b0a6318c0875940943a6aa303dc090fea0b4cd5b9fb8bcbecac4308a2bd15d9f369cdc22121a4', 'secret')
- ->will($this->returnValue('MyStoredRequestToken'));
/** @var Request $request */
$request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
->setMethods(['getScriptName'])
->setConstructorArgs([
[
'server' => [
- 'HTTP_REQUESTTOKEN' => '1c637c4147e40a8a8f09428ec2059cebea3480c27b402b4e793c69710a731513|wlXxNUaFqHuQnZr5|e6ab49c9e0e20c8d3607e02f1d8e6ec17ad6020ae10b7d64ab4b0a6318c0875940943a6aa303dc090fea0b4cd5b9fb8bcbecac4308a2bd15d9f369cdc22121a4:secret',
+ 'HTTP_REQUESTTOKEN' => 'AAAHGxsTCTc3BgMQESAcNR0OAR0=:MyTotalSecretShareds',
],
'requesttoken' => 'MyStoredRequestToken',
],
$this->secureRandom,
- $crypto,
$this->config,
$this->stream
])
@@ -1359,6 +1288,9 @@ class RequestTest extends \Test\TestCase {
$this->assertTrue($request->passesCSRFCheck());
}
+ /**
+ * @return array
+ */
public function invalidTokenDataProvider() {
return [
['InvalidSentToken'],
@@ -1373,8 +1305,6 @@ class RequestTest extends \Test\TestCase {
* @param string $invalidToken
*/
public function testPassesCSRFCheckWithInvalidToken($invalidToken) {
- $crypto = new Crypto($this->config, $this->secureRandom);
-
/** @var Request $request */
$request = $this->getMockBuilder('\OC\AppFramework\Http\Request')
->setMethods(['getScriptName'])
@@ -1386,7 +1316,6 @@ class RequestTest extends \Test\TestCase {
'requesttoken' => 'MyStoredRequestToken',
],
$this->secureRandom,
- $crypto,
$this->config,
$this->stream
])
@@ -1402,7 +1331,6 @@ class RequestTest extends \Test\TestCase {
->setConstructorArgs([
[],
$this->secureRandom,
- $this->getMock('\OCP\Security\ICrypto'),
$this->config,
$this->stream
])