Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/object-storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-kvstore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-memcached.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-mysql-sharding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-nodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-object-store-primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-oci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-pgsql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/phpunit-sqlite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions autotest-external.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions autotest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..."
Expand Down
52 changes: 52 additions & 0 deletions core/Command/Testing/PrepareCi.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OC\Core\Command\Testing;

use OC\Core\Command\Base;
use OCP\IConfig;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class PrepareCi extends Base {
public function __construct(
private readonly IConfig $config,
) {
parent::__construct();
}

#[\Override]
protected function configure(): void {
parent::configure();

$this
->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('<info>Set ' . $key . ' to ' . json_encode($value) . '</info>');
}

return self::SUCCESS;
}
}
2 changes: 2 additions & 0 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
61 changes: 61 additions & 0 deletions tests/Core/Command/Testing/PrepareCiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace Tests\Core\Command\Testing;

use OC\Core\Command\Testing\PrepareCi;
use OCP\IConfig;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;

class PrepareCiTest extends TestCase {
private IConfig&MockObject $config;
private CommandTester $commandTester;

#[\Override]
protected function setUp(): void {
parent::setUp();

$this->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([]));
}
}
9 changes: 0 additions & 9 deletions tests/preseed-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading