Skip to content

IBX-10159: Corrected generate dfs_database_url parameter for Ibexa Cloud #595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: 4.6
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions src/bundle/Core/DependencyInjection/IbexaCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,12 @@ private function configurePlatformShSetup(ContainerBuilder $container): void
$container->setParameter(
'dfs_database_url',
sprintf(
'%s://%s:%s:%d@%s/%s',
'%s://%s:%s@%s:%d/%s',
$endpoint['scheme'],
$endpoint['username'],
$endpoint['password'],
$endpoint['port'],
$endpoint['host'],
$endpoint['port'],
$endpoint['path']
)
);
Expand Down
45 changes: 45 additions & 0 deletions tests/bundle/Core/DependencyInjection/IbexaCoreExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,51 @@ public function testLoadsTestServicesWhenParameterIsSpecified(): void
$this->assertContainerBuilderHasService(QueryControllerContext::class);
}

/**
* @throws \JsonException
*/
public function testConfigurePlatformShDFS(): void
{
$dsn = 'mysql://dfs:dfs@localhost:3306/dfs';
$parts = parse_url($dsn);

$relationship = [
'dfs_database' => [
[
'host' => $parts['host'],
'scheme' => $parts['scheme'],
'username' => $parts['user'],
'password' => $parts['pass'],
'port' => $parts['port'],
'path' => ltrim($parts['path'], '/'),
'query' => [
'is_master' => true,
],
],
],
];

$_SERVER['PLATFORM_RELATIONSHIPS'] = base64_encode(json_encode($relationship, JSON_THROW_ON_ERROR));
$_SERVER['PLATFORMSH_DFS_NFS_PATH'] = '/';
$_SERVER['PLATFORM_ROUTES'] = base64_encode(json_encode([], JSON_THROW_ON_ERROR));
$_SERVER['PLATFORM_PROJECT_ENTROPY'] = '';

$this->container->setParameter('database_charset', 'utf8mb4');
$this->container->setParameter('database_collation', 'utf8mb4_general_ci');
$this->container->setParameter('kernel.project_dir', __DIR__ . '/../Resources');
$this->load();

$this->assertContainerBuilderHasParameter('dfs_database_url');
self::assertEquals($dsn, $this->container->getParameter('dfs_database_url'));

unset(
$_SERVER['PLATFORM_RELATIONSHIPS'],
$_SERVER['PLATFORMSH_DFS_NFS_PATH'],
$_SERVER['PLATFORM_ROUTES'],
$_SERVER['PLATFORM_PROJECT_ENTROPY']
);
}

/**
* Prepare Core Container for compilation by mocking required parameters and compile it.
*/
Expand Down
1 change: 1 addition & 0 deletions tests/bundle/Core/Resources/config/packages/dfs/dfs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# dummy file for \Ibexa\Tests\Bundle\Core\DependencyInjection\IbexaCoreExtensionTest::testConfigurePlatformShDFS
Loading