Skip to content

Commit

Permalink
fix(tests): Avoid user login before a private key is setup
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Nov 28, 2024
1 parent f812d3d commit 2a1e5fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion apps/files_sharing/tests/EncryptedSizePropagationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ class EncryptedSizePropagationTest extends SizePropagationTest {
use EncryptionTrait;

protected function setupUser($name, $password = '') {
$this->config->setAppValue('encryption', 'useMasterKey', '0');
$this->createUser($name, $password);
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
$this->config->setAppValue('encryption', 'useMasterKey', '0');
$this->setupForUser($name, $password);
$this->loginWithEncryption($name);
return new View('/' . $name . '/files');
}

protected function loginHelper($user, $create = false, $password = false) {
$this->setupForUser($user, $password);
parent::loginHelper($user, $create, $password);
}
}
4 changes: 2 additions & 2 deletions apps/files_sharing/tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function setUp(): void {
\OC::$server->get(DisplayNameCache::class)->clear();

//login as user1
self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
$this->loginHelper(self::TEST_FILES_SHARING_API_USER1);

$this->data = 'foobar';
$this->view = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
Expand Down Expand Up @@ -167,7 +167,7 @@ public static function tearDownAfterClass(): void {
* @param bool $create
* @param bool $password
*/
protected static function loginHelper($user, $create = false, $password = false) {
protected function loginHelper($user, $create = false, $password = false) {
if ($password === false) {
$password = $user;
}
Expand Down

0 comments on commit 2a1e5fd

Please sign in to comment.