nextcloud/tests/lib/Repair/NC29/MoveCertificateBundlesTest.php
Thomas Citharel dd54f35f29
fix(certificate manager): migrate certificate bundles from files_external to data
CertificateManager doesn't work propertly if the files_external app is disabled, so let's store
directly in /data/certificate_manager the bundled certificates. This always has to be done on local
disk as curl currently requires a path to the cert bundle.

When we require PHP 8.1 we will be able to simply store the certificate
bundle in database/memory/cache and pass it through the CURLOPT_SSLCERT_BLOB option.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2024-02-01 18:40:59 +01:00

70 lines
2.2 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2024 Thomas Citharel <nextcloud@tcit.fr>
*
* @author Thomas Citharel <nextcloud@tcit.fr>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Test\Repair\NC29;
use OC\Files\View;
use OC\Repair\NC29\MoveCertificateBundles;
use OCP\IConfig;
use OCP\Migration\IOutput;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
/**
* Class FixMountStoragesTest
*
* @package Test\Repair\NC11
* @group DB
*/
class MoveCertificateBundlesTest extends TestCase {
private View|MockObject $view;
private IConfig|MockObject $config;
private IOutput $output;
private MoveCertificateBundles $repair;
protected function setUp(): void {
parent::setUp();
$this->output = $this->createMock(IOutput::class);
$this->view = $this->createMock(View::class);
$this->config = $this->createMock(IConfig::class);
$this->config->expects($this->once())->method('getSystemValue')->with('datadirectory', \OC::$SERVERROOT . '/data-autotest')->willReturn(\OC::$SERVERROOT . '/data-autotest');
$this->repair = new MoveCertificateBundles(
$this->view,
$this->config
);
}
public function testGetName() {
$this->assertSame('Move the certificate bundles from data/files_external/ to data/certificate_manager/', $this->repair->getName());
}
public function testSkipRepairStep() {
$this->view->expects($this->once())->method('file_exists')->with('/data-autotest/certificate_manager/rootcerts.crt')->willReturn(true);
$this->view->expects($this->never())->method('copy');
$this->repair->run($this->output);
}
}