diff --git a/.github/workflows/integration-sqlite.yml b/.github/workflows/integration-sqlite.yml index 963219a709633..ab849b827eee9 100644 --- a/.github/workflows/integration-sqlite.yml +++ b/.github/workflows/integration-sqlite.yml @@ -152,7 +152,7 @@ jobs: run: | mkdir data ./occ maintenance:install --verbose ${{ contains(matrix.test-suite,'ldap') && '--data-dir=/dev/shm/nc_int' || '' }} --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin - ./occ config:system:set hashing_default_password --value=true --type=boolean + NC_debug=true ./occ testing:prepare-ci - name: Configure caching if: ${{ contains(matrix.test-suite,'ldap') }} diff --git a/.github/workflows/object-storage.yml b/.github/workflows/object-storage.yml index 62cf6d4a4b9e1..3ff51e84f9d6e 100644 --- a/.github/workflows/object-storage.yml +++ b/.github/workflows/object-storage.yml @@ -84,6 +84,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: Wait for object store diff --git a/.github/workflows/phpunit-kvstore.yml b/.github/workflows/phpunit-kvstore.yml index 11053277a203b..d968dc1541cd6 100644 --- a/.github/workflows/phpunit-kvstore.yml +++ b/.github/workflows/phpunit-kvstore.yml @@ -91,6 +91,7 @@ jobs: cp tests/kvstore-${{ matrix.topology }}.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit key-value store tests diff --git a/.github/workflows/phpunit-mariadb.yml b/.github/workflows/phpunit-mariadb.yml index 423ec1d46a1cb..92bb6c59eedfc 100644 --- a/.github/workflows/phpunit-mariadb.yml +++ b/.github/workflows/phpunit-mariadb.yml @@ -84,6 +84,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit diff --git a/.github/workflows/phpunit-memcached.yml b/.github/workflows/phpunit-memcached.yml index 0de1a54c7e5fc..ea2ec3855e65f 100644 --- a/.github/workflows/phpunit-memcached.yml +++ b/.github/workflows/phpunit-memcached.yml @@ -61,6 +61,7 @@ jobs: cp tests/memcached.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit memcached tests diff --git a/.github/workflows/phpunit-mysql-sharding.yml b/.github/workflows/phpunit-mysql-sharding.yml index 32d9acb5aabc7..59d1670189c5d 100644 --- a/.github/workflows/phpunit-mysql-sharding.yml +++ b/.github/workflows/phpunit-mysql-sharding.yml @@ -132,6 +132,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit diff --git a/.github/workflows/phpunit-mysql.yml b/.github/workflows/phpunit-mysql.yml index c1bb6be885e11..6a07f0aa9476d 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -86,6 +86,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=mysql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: Enable partitioning for oc_filecache diff --git a/.github/workflows/phpunit-nodb.yml b/.github/workflows/phpunit-nodb.yml index 7015f1b79e3ae..9057a60cfd4ce 100644 --- a/.github/workflows/phpunit-nodb.yml +++ b/.github/workflows/phpunit-nodb.yml @@ -65,6 +65,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit nodb testsuite diff --git a/.github/workflows/phpunit-object-store-primary.yml b/.github/workflows/phpunit-object-store-primary.yml index cebe68674d5b8..45c5b44770991 100644 --- a/.github/workflows/phpunit-object-store-primary.yml +++ b/.github/workflows/phpunit-object-store-primary.yml @@ -64,6 +64,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: Wait for S3 diff --git a/.github/workflows/phpunit-oci.yml b/.github/workflows/phpunit-oci.yml index 3b68ce5c0e531..4427d35430fe5 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -86,6 +86,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=oci --database-name=${{ matrix.oracle-versions < 23 && 'XE' || 'FREE' }} --database-host=127.0.0.1 --database-port=1521 --database-user=system --database-pass=oracle --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit diff --git a/.github/workflows/phpunit-pgsql.yml b/.github/workflows/phpunit-pgsql.yml index 0cc0ff2662e44..7482037c9b5e0 100644 --- a/.github/workflows/phpunit-pgsql.yml +++ b/.github/workflows/phpunit-pgsql.yml @@ -78,6 +78,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=pgsql --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: PHPUnit database tests diff --git a/.github/workflows/phpunit-sqlite.yml b/.github/workflows/phpunit-sqlite.yml index a43f2e5741efc..2e0036eb114b5 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.yml @@ -79,6 +79,7 @@ jobs: cp tests/redis.config.php config/ cp tests/preseed-config.php config/config.php ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin + NC_debug=true ./occ testing:prepare-ci php -f tests/enable_all.php - name: Nextcloud debug information diff --git a/autotest-external.sh b/autotest-external.sh index ba6354b26e12a..e1e780c70b53f 100755 --- a/autotest-external.sh +++ b/autotest-external.sh @@ -146,6 +146,7 @@ EOF # trigger installation echo "Installing ...." ./occ maintenance:install -vvv --database=$1 --database-name=$DATABASENAME --database-host=localhost --database-user=$DATABASEUSER --database-pass=owncloud --admin-user=$ADMINLOGIN --admin-pass=admin --data-dir=$DATADIR + NC_debug=true ./occ testing:prepare-ci ./occ config:system:set --value true --type boolean allow_local_remote_servers diff --git a/autotest.sh b/autotest.sh index b90fdd3ce1a38..843a09ecdf07f 100755 --- a/autotest.sh +++ b/autotest.sh @@ -355,6 +355,7 @@ function execute_tests { # trigger installation echo "Installing ...." "$PHP" ./occ maintenance:install -vvv --database="$_DB" --database-name="$DATABASENAME" --database-host="$DATABASEHOST" --database-user="$DATABASEUSER" --database-pass=owncloud --admin-user="$ADMINLOGIN" --admin-pass=admin --data-dir="$DATADIR" + NC_debug=true "$PHP" ./occ testing:prepare-ci #test execution echo "Testing with $DB ..." diff --git a/core/Command/Testing/PrepareCi.php b/core/Command/Testing/PrepareCi.php new file mode 100644 index 0000000000000..fd62a1da5e9d0 --- /dev/null +++ b/core/Command/Testing/PrepareCi.php @@ -0,0 +1,52 @@ +setName('testing:prepare-ci') + ->setDescription('Trade security for speed on a CI instance, never use this in production'); + } + + #[\Override] + protected function execute(InputInterface $input, OutputInterface $output): int { + $openssl = $this->config->getSystemValue('openssl', []); + $openssl['private_key_bits'] = 2048; + + $values = [ + // bcrypt instead of argon2, so hashingCost applies + 'hashing_default_password' => true, + 'hashingCost' => 4, + 'openssl' => $openssl, + ]; + $this->config->setSystemValues($values); + + foreach ($values as $key => $value) { + $output->writeln('Set ' . $key . ' to ' . json_encode($value) . ''); + } + + return self::SUCCESS; + } +} diff --git a/core/register_command.php b/core/register_command.php index ee9dcc1c03dd7..610ce4bf802bc 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -106,6 +106,7 @@ use OC\Core\Command\TaskProcessing\GetCommand; use OC\Core\Command\TaskProcessing\Statistics; use OC\Core\Command\TaskProcessing\WorkerCommand; +use OC\Core\Command\Testing\PrepareCi; use OC\Core\Command\TwoFactorAuth\Cleanup; use OC\Core\Command\TwoFactorAuth\Enforce; use OC\Core\Command\TwoFactorAuth\State; @@ -199,6 +200,7 @@ $application->addCommand(Server::get(MigrateCommand::class)); $application->addCommand(Server::get(GenerateCommand::class)); $application->addCommand(Server::get(ExecuteCommand::class)); + $application->addCommand(Server::get(PrepareCi::class)); } $application->addCommand(Server::get(Command\Encryption\Disable::class)); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 7195cffc18211..8bb5d593e88b9 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1570,6 +1570,7 @@ 'OC\\Core\\Command\\TaskProcessing\\ListCommand' => $baseDir . '/core/Command/TaskProcessing/ListCommand.php', 'OC\\Core\\Command\\TaskProcessing\\Statistics' => $baseDir . '/core/Command/TaskProcessing/Statistics.php', 'OC\\Core\\Command\\TaskProcessing\\WorkerCommand' => $baseDir . '/core/Command/TaskProcessing/WorkerCommand.php', + 'OC\\Core\\Command\\Testing\\PrepareCi' => $baseDir . '/core/Command/Testing/PrepareCi.php', 'OC\\Core\\Command\\TwoFactorAuth\\Base' => $baseDir . '/core/Command/TwoFactorAuth/Base.php', 'OC\\Core\\Command\\TwoFactorAuth\\Cleanup' => $baseDir . '/core/Command/TwoFactorAuth/Cleanup.php', 'OC\\Core\\Command\\TwoFactorAuth\\Disable' => $baseDir . '/core/Command/TwoFactorAuth/Disable.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 62bf2d79948fd..b7412813556c6 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1611,6 +1611,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OC\\Core\\Command\\TaskProcessing\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/ListCommand.php', 'OC\\Core\\Command\\TaskProcessing\\Statistics' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/Statistics.php', 'OC\\Core\\Command\\TaskProcessing\\WorkerCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/WorkerCommand.php', + 'OC\\Core\\Command\\Testing\\PrepareCi' => __DIR__ . '/../../..' . '/core/Command/Testing/PrepareCi.php', 'OC\\Core\\Command\\TwoFactorAuth\\Base' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Base.php', 'OC\\Core\\Command\\TwoFactorAuth\\Cleanup' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Cleanup.php', 'OC\\Core\\Command\\TwoFactorAuth\\Disable' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Disable.php', diff --git a/tests/Core/Command/Testing/PrepareCiTest.php b/tests/Core/Command/Testing/PrepareCiTest.php new file mode 100644 index 0000000000000..01f31a0194c88 --- /dev/null +++ b/tests/Core/Command/Testing/PrepareCiTest.php @@ -0,0 +1,61 @@ +config = $this->createMock(IConfig::class); + $this->commandTester = new CommandTester(new PrepareCi($this->config)); + } + + public function testSetsValues(): void { + $this->config->method('getSystemValue') + ->with('openssl', []) + ->willReturn([]); + $this->config->expects($this->once()) + ->method('setSystemValues') + ->with([ + 'hashing_default_password' => true, + 'hashingCost' => 4, + 'openssl' => ['private_key_bits' => 2048], + ]); + + $this->assertSame(0, $this->commandTester->execute([])); + + $display = $this->commandTester->getDisplay(); + $this->assertStringContainsString('Set hashing_default_password to true', $display); + $this->assertStringContainsString('Set hashingCost to 4', $display); + $this->assertStringContainsString('Set openssl to {"private_key_bits":2048}', $display); + } + + public function testKeepsOtherOpensslOptions(): void { + $this->config->method('getSystemValue') + ->with('openssl', []) + ->willReturn(['config' => '/etc/ssl/openssl.cnf', 'private_key_bits' => 4096]); + $this->config->expects($this->once()) + ->method('setSystemValues') + ->with($this->callback(static fn (array $values): bool + => $values['openssl'] === ['config' => '/etc/ssl/openssl.cnf', 'private_key_bits' => 2048])); + + $this->assertSame(0, $this->commandTester->execute([])); + } +} diff --git a/tests/preseed-config.php b/tests/preseed-config.php index e3e07eb7accb7..0853b220a653e 100644 --- a/tests/preseed-config.php +++ b/tests/preseed-config.php @@ -9,15 +9,6 @@ */ $CONFIG = [ 'appstoreenabled' => false, - // Argon2 at its minimum cost. The suite creates users constantly and the - // default parameters make every password hash take ~100ms. - 'hashingMemoryCost' => 8, - 'hashingTimeCost' => 1, - 'hashingThreads' => 1, - // Only used when argon2 is unavailable and bcrypt is the fallback. - 'hashingCost' => 4, - // Smaller keys are faster to generate and the tests do not need 4096 bit. - 'openssl' => ['private_key_bits' => 2048], 'apps_paths' => [ [ 'path' => OC::$SERVERROOT . '/apps',