Check editor accounts.
A new editor needs a username and a password of at least 12 characters. A persistent login needs an unexpired key and an existing account. Removing an account revokes its persistent logins, and its sessions end.
This commit is contained in:
@@ -124,8 +124,17 @@ abstract class PageTestCase extends \PHPUnit\Framework\TestCase {
|
||||
return $id;
|
||||
}
|
||||
|
||||
// An editor's session, with a CSRF token; returns the token
|
||||
/*
|
||||
* An editor's session, with a CSRF token; returns the token. The pages
|
||||
* log out an editor without an account, so this adds the account to the
|
||||
* editors table if it is missing.
|
||||
*/
|
||||
protected function loginAs(string $username = 'ed', array $data = array()): string {
|
||||
$saved = unserialize(file_get_contents(self::$state . '/tables.ser'));
|
||||
if (!in_array($username, array_column($saved['tables']['editors'], 'username'), TRUE)) {
|
||||
$saved['tables']['editors'][] = array('username' => $username, 'password' => '', 'email' => '');
|
||||
file_put_contents(self::$state . '/tables.ser', serialize($saved));
|
||||
}
|
||||
$token = str_repeat('c0ffee', 10) . 'c0de';
|
||||
$this->startSession($data + array('editor' => $username, 'csrf_token' => $token));
|
||||
return $token;
|
||||
|
||||
Reference in New Issue
Block a user