From 39f98fcfb75676d1a48a0c8c6cd5de88252bb2cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20M=C3=BCller?= Date: Mon, 12 Oct 2026 09:23:46 +0200 Subject: [PATCH] feat: Add testing:prepare-ci command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: Marcel Müller --- .github/workflows/integration-sqlite.yml | 2 +- .github/workflows/phpunit-kvstore.yml | 1 + .github/workflows/phpunit-mariadb.yml | 1 + .github/workflows/phpunit-memcached.yml | 1 + .github/workflows/phpunit-mysql-sharding.yml | 1 + .github/workflows/phpunit-mysql.yml | 1 + .github/workflows/phpunit-nodb.yml | 1 + .../phpunit-object-store-primary.yml | 1 + .github/workflows/phpunit-oci.yml | 1 + .github/workflows/phpunit-pgsql.yml | 1 + .github/workflows/phpunit-sqlite.yml | 1 + autotest-external.sh | 1 + autotest.sh | 1 + core/Command/Testing/PrepareCi.php | 52 ++++++++++++++++ core/register_command.php | 2 + lib/composer/composer/autoload_classmap.php | 1 + lib/composer/composer/autoload_static.php | 1 + tests/Core/Command/Testing/PrepareCiTest.php | 61 +++++++++++++++++++ 18 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 core/Command/Testing/PrepareCi.php create mode 100644 tests/Core/Command/Testing/PrepareCiTest.php diff --git a/.github/workflows/integration-sqlite.yml b/.github/workflows/integration-sqlite.yml index ae70591e2a975..7adfc19087f6a 100644 --- a/.github/workflows/integration-sqlite.yml +++ b/.github/workflows/integration-sqlite.yml @@ -158,7 +158,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/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 70144fa428b00..214fd35c2677a 100644 --- a/.github/workflows/phpunit-mariadb.yml +++ b/.github/workflows/phpunit-mariadb.yml @@ -83,6 +83,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 b158d6e872c4b..2844edde6e117 100644 --- a/.github/workflows/phpunit-memcached.yml +++ b/.github/workflows/phpunit-memcached.yml @@ -60,6 +60,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 12ce38c31d527..29b77ec8486bb 100644 --- a/.github/workflows/phpunit-mysql-sharding.yml +++ b/.github/workflows/phpunit-mysql-sharding.yml @@ -121,6 +121,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 5728efb262609..57ba884706c21 100644 --- a/.github/workflows/phpunit-mysql.yml +++ b/.github/workflows/phpunit-mysql.yml @@ -83,6 +83,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-nodb.yml b/.github/workflows/phpunit-nodb.yml index ed21da0206e62..12ea39a845b82 100644 --- a/.github/workflows/phpunit-nodb.yml +++ b/.github/workflows/phpunit-nodb.yml @@ -66,6 +66,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 3a2e2c945c521..5f58517b57693 100644 --- a/.github/workflows/phpunit-object-store-primary.yml +++ b/.github/workflows/phpunit-object-store-primary.yml @@ -63,6 +63,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 bf3680181cf88..62f3e6d462243 100644 --- a/.github/workflows/phpunit-oci.yml +++ b/.github/workflows/phpunit-oci.yml @@ -85,6 +85,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 155e2231dd77a..65ff4a5028a6d 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 eb27fac4f8b77..d038d52511da8 100644 --- a/.github/workflows/phpunit-sqlite.yml +++ b/.github/workflows/phpunit-sqlite.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=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 234ce5fb4dedd..89be9ae188541 100755 --- a/autotest.sh +++ b/autotest.sh @@ -354,6 +354,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 1a7fd50349dcb..3bc30222571ae 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -94,6 +94,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; @@ -182,6 +183,7 @@ $application->add(Server::get(MigrateCommand::class)); $application->add(Server::get(GenerateCommand::class)); $application->add(Server::get(ExecuteCommand::class)); + $application->add(Server::get(PrepareCi::class)); } $application->add(Server::get(Command\Encryption\Disable::class)); diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index d095419b5ed6e..331bddeb65aba 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -1472,6 +1472,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 4e08b359c23c0..04b8c4b2966f8 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -1513,6 +1513,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([])); + } +}