|
|
@@ -550,10 +550,10 @@ class SecurityComponentTest extends TestCase
|
|
|
$this->Security->startup($event);
|
|
|
$unlocked = '';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'],
|
|
|
'_Token' => compact('unlocked')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost('AuthSecurityException', '\'_Token.fields\' was not found in request data.');
|
|
|
$this->assertFalse($result, 'validatePost passed when fields were missing. %s');
|
|
|
}
|
|
|
@@ -602,10 +602,10 @@ class SecurityComponentTest extends TestCase
|
|
|
$attack = 'O:3:"App":1:{s:5:"__map";a:1:{s:3:"foo";s:7:"Hacked!";s:1:"fail"}}';
|
|
|
$fields .= urlencode(':' . str_rot13($attack));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => 'mark', 'password' => 'foo', 'valid' => '0'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost('SecurityException', 'Bad Request');
|
|
|
$this->assertFalse($result, 'validatePost passed when key was missing. %s');
|
|
|
}
|
|
|
@@ -627,11 +627,11 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'_csrfToken' => 'abc123',
|
|
|
'Model' => ['multi_field' => ['1', '3']],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$this->assertTrue($this->validatePost());
|
|
|
}
|
|
|
|
|
|
@@ -656,16 +656,16 @@ class SecurityComponentTest extends TestCase
|
|
|
[]
|
|
|
]));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['multi_field' => ['1', '3']],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$this->assertTrue($this->validatePost());
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['multi_field' => [12 => '1', 20 => '3']],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$this->assertTrue($this->validatePost());
|
|
|
}
|
|
|
|
|
|
@@ -689,10 +689,10 @@ class SecurityComponentTest extends TestCase
|
|
|
[]
|
|
|
]));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
1 => 'value,',
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$this->assertTrue($this->validatePost());
|
|
|
}
|
|
|
|
|
|
@@ -711,10 +711,10 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'anything' => 'some_data',
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -735,10 +735,10 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => '', 'password' => ''],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -766,10 +766,10 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = '';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => '', 'password' => ''],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -792,7 +792,7 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Addresses' => [
|
|
|
'0' => [
|
|
|
'id' => '123456', 'title' => '', 'first_name' => '', 'last_name' => '',
|
|
|
@@ -804,7 +804,7 @@ class SecurityComponentTest extends TestCase
|
|
|
]
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
}
|
|
|
@@ -826,33 +826,33 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Tag' => ['Tag' => [1, 2]],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Tag' => ['Tag' => [1, 2, 3]],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Tag' => ['Tag' => [1, 2, 3, 4]],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
$fields = '1e4c9269b64756e9b141d364497c5f037b428a37%3A';
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'User.password' => 'bar', 'User.name' => 'foo', 'User.is_valid' => '1',
|
|
|
'Tag' => ['Tag' => [1]],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
}
|
|
|
@@ -874,31 +874,31 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => '', 'password' => '', 'valid' => '0'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
$fields = '3f368401f9a8610bcace7746039651066cdcdc38%3A';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => '', 'password' => '', 'valid' => '0'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([]);
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([]));
|
|
|
$this->Security->startup($event);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => '', 'password' => '', 'valid' => '0'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -918,13 +918,13 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => '', 'password' => '', 'hidden' => '0',
|
|
|
'other_hidden' => 'some hidden value'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
}
|
|
|
@@ -944,12 +944,12 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => '', 'password' => '', 'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -974,14 +974,14 @@ class SecurityComponentTest extends TestCase
|
|
|
);
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => 'mark',
|
|
|
'password' => 'sekret',
|
|
|
'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -1002,14 +1002,14 @@ class SecurityComponentTest extends TestCase
|
|
|
$fields = ['Model.hidden', 'Model.password', 'Model.username'];
|
|
|
$fields = urlencode(Security::hash(serialize($fields) . Security::getSalt()));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => 'mark',
|
|
|
'password' => 'sekret',
|
|
|
'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost('SecurityException', '\'_Token.unlocked\' was not found in request data.');
|
|
|
$this->assertFalse($result);
|
|
|
@@ -1031,14 +1031,14 @@ class SecurityComponentTest extends TestCase
|
|
|
$fields = urlencode(Security::hash(serialize($fields) . Security::getSalt()));
|
|
|
$unlocked = '';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => 'mark',
|
|
|
'password' => 'sekret',
|
|
|
'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost('SecurityException', '\'_Token.debug\' was not found in request data.');
|
|
|
$this->assertFalse($result);
|
|
|
@@ -1060,14 +1060,14 @@ class SecurityComponentTest extends TestCase
|
|
|
$fields = urlencode(Security::hash(serialize($fields) . Security::getSalt()));
|
|
|
$unlocked = '';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => 'mark',
|
|
|
'password' => 'sekret',
|
|
|
'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
Configure::write('debug', false);
|
|
|
$result = $this->validatePost('SecurityException', 'The request has been black-holed');
|
|
|
}
|
|
|
@@ -1096,14 +1096,14 @@ class SecurityComponentTest extends TestCase
|
|
|
// Tamper the values.
|
|
|
$unlocked = 'Model.username|Model.password';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => 'mark',
|
|
|
'password' => 'sekret',
|
|
|
'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost('SecurityException', 'Missing field \'Model.password\' in POST data, Unexpected unlocked field \'Model.password\' in POST data');
|
|
|
$this->assertFalse($result);
|
|
|
@@ -1123,12 +1123,12 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => ['username' => '', 'password' => '', 'valid' => '0'],
|
|
|
'Model2' => ['valid' => '0'],
|
|
|
'Model3' => ['valid' => '0'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
}
|
|
|
@@ -1148,7 +1148,7 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
[
|
|
|
'username' => 'username', 'password' => 'password',
|
|
|
@@ -1160,7 +1160,7 @@ class SecurityComponentTest extends TestCase
|
|
|
]
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -1181,7 +1181,7 @@ class SecurityComponentTest extends TestCase
|
|
|
$unlocked = '';
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Address' => [
|
|
|
0 => [
|
|
|
'id' => '123',
|
|
|
@@ -1205,7 +1205,7 @@ class SecurityComponentTest extends TestCase
|
|
|
]
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -1230,13 +1230,13 @@ class SecurityComponentTest extends TestCase
|
|
|
);
|
|
|
$debug = 'not used';
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'TaxonomyData' => [
|
|
|
1 => [[2]],
|
|
|
2 => [[3]]
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
}
|
|
|
@@ -1279,7 +1279,7 @@ class SecurityComponentTest extends TestCase
|
|
|
[]
|
|
|
]));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Address' => [
|
|
|
0 => [
|
|
|
'id' => '123',
|
|
|
@@ -1303,7 +1303,7 @@ class SecurityComponentTest extends TestCase
|
|
|
]
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost('SecurityException', 'Bad Request');
|
|
|
$this->assertFalse($result);
|
|
|
}
|
|
|
@@ -1327,20 +1327,20 @@ class SecurityComponentTest extends TestCase
|
|
|
[]
|
|
|
]));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'MyModel' => ['name' => 'some data'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost('SecurityException', 'Unexpected field \'MyModel.name\' in POST data');
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
$this->Security->startup($event);
|
|
|
$this->Security->setConfig('disabledFields', ['MyModel.name']);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'MyModel' => ['name' => 'some data'],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
@@ -1366,30 +1366,30 @@ class SecurityComponentTest extends TestCase
|
|
|
[]
|
|
|
]));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost('SecurityException', 'Bad Request');
|
|
|
$this->assertFalse($result);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
'Test' => ['test' => '']
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
'Test' => ['test' => '1']
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug'),
|
|
|
'Test' => ['test' => '2']
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
$result = $this->validatePost();
|
|
|
$this->assertTrue($result);
|
|
|
}
|
|
|
@@ -1484,7 +1484,7 @@ class SecurityComponentTest extends TestCase
|
|
|
{
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
|
$event = new Event('Controller.startup', $this->Controller);
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody(['data']);
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody(['data']));
|
|
|
$this->Security->unlockedActions = 'index';
|
|
|
$this->Security->blackHoleCallback = null;
|
|
|
$result = $this->Controller->Security->startup($event);
|
|
|
@@ -1513,14 +1513,14 @@ class SecurityComponentTest extends TestCase
|
|
|
['not expected']
|
|
|
]));
|
|
|
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'username' => 'mark',
|
|
|
'password' => 'sekret',
|
|
|
'hidden' => '0'
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost('SecurityException', 'Invalid security debug token.');
|
|
|
$this->assertFalse($result);
|
|
|
@@ -1589,13 +1589,13 @@ class SecurityComponentTest extends TestCase
|
|
|
]));
|
|
|
$fields = urlencode(Security::hash(serialize($fields) . $unlocked . Security::getSalt()));
|
|
|
$fields .= urlencode(':Model.hidden|Model.id');
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withParsedBody([
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withParsedBody([
|
|
|
'Model' => [
|
|
|
'hidden' => 'tampered',
|
|
|
'id' => '1',
|
|
|
],
|
|
|
'_Token' => compact('fields', 'unlocked', 'debug')
|
|
|
- ]);
|
|
|
+ ]));
|
|
|
|
|
|
$result = $this->validatePost('SecurityException', 'Tampered field \'Model.hidden\' in POST data (expected value \'value\' but found \'tampered\')');
|
|
|
$this->assertFalse($result);
|
|
|
@@ -1622,10 +1622,10 @@ class SecurityComponentTest extends TestCase
|
|
|
]));
|
|
|
$fields = urlencode(Security::hash(serialize($fields) . $unlocked . Security::getSalt()));
|
|
|
$fields .= urlencode(':Model.hidden|Model.id');
|
|
|
- $this->Controller->request = $this->Controller->getRequest()->withData('Model', [
|
|
|
+ $this->Controller->setRequest($this->Controller->getRequest()->withData('Model', [
|
|
|
'hidden' => ['some-key' => 'some-value'],
|
|
|
'id' => '1',
|
|
|
- ])->withData('_Token', compact('fields', 'unlocked', 'debug'));
|
|
|
+ ])->withData('_Token', compact('fields', 'unlocked', 'debug')));
|
|
|
|
|
|
$result = $this->validatePost(
|
|
|
'SecurityException',
|