Skip to content

Commit 30c1dbc

Browse files
committed
Fix literalis WFS import
1 parent 42fa6be commit 30c1dbc

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed

.github/workflows/litteralis_import.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ jobs:
8686
- name: Run import
8787
run: make ci_litteralis_import BIN_PHP="php" BIN_CONSOLE="php bin/console" BIN_COMPOSER="composer"
8888

89+
- name: Run communication import
90+
if: ${{ vars.APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS != '' && vars.APP_LITTERALIS_COMMUNICATION_ENABLED_ORGS != '[]' }}
91+
run: make ci_litteralis_import_communication BIN_PHP="php" BIN_CONSOLE="php bin/console"
92+
8993
- name: Get log file path
9094
id: logfile
9195
if: ${{ !cancelled() }}

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ ci_litteralis_import: ## Run CI steps for Litteralis Import workflow
289289
scalingo login --ssh --ssh-identity ~/.ssh/id_rsa
290290
./tools/scalingodbtunnel dialog --host-url --port 10000 & ./tools/wait-for-it.sh 127.0.0.1:10000
291291
make console CMD="app:litteralis:import"
292+
293+
ci_litteralis_import_communication: ## Run CI steps for Litteralis Communication Import workflow
292294
make console CMD="app:litteralis:import-communication"
293295

294296
ci_bdtopo_migrate: ## Run CI steps for BD TOPO Migrate workflow

src/Infrastructure/Integration/Litteralis/LitteralisCommunicationExtractor.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ public function configure(array $enabledOrgs, LitteralisCredentials $credentials
3939

4040
foreach ($enabledOrgs as $name) {
4141
$orgCredentials = $credentials->getCredentials($name);
42+
43+
if (empty($orgCredentials)) {
44+
throw new \RuntimeException(\sprintf(
45+
'Organization "%s": missing credentials (check APP_LITTERALIS_ORG_%s_CREDENTIALS)',
46+
$name,
47+
strtoupper($name),
48+
));
49+
}
50+
4251
$client = $this->clientFactory->create($orgCredentials);
4352
$this->clients[$name] = $client;
4453
}

src/Infrastructure/Symfony/DependencyInjection/LitteralisCredentialsEnvVarProcessor.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class LitteralisCredentialsEnvVarProcessor implements EnvVarProcessorInterface
1212
public function __construct(
1313
private readonly string $dialogOrgId,
1414
private readonly ?array $litteralisEnabledOrgs,
15+
private readonly ?array $litteralisCommunicationEnabledOrgs,
1516
) {
1617
}
1718

@@ -21,7 +22,12 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): Litteral
2122

2223
$orgEnvPrefix = $name;
2324

24-
foreach (($this->litteralisEnabledOrgs ?? []) as $orgName) {
25+
$allOrgNames = array_unique(array_merge(
26+
$this->litteralisEnabledOrgs ?? [],
27+
$this->litteralisCommunicationEnabledOrgs ?? [],
28+
));
29+
30+
foreach ($allOrgNames as $orgName) {
2531
$orgEnvName = \sprintf('%s%s_ID', $orgEnvPrefix, strtoupper($orgName));
2632
$orgIdEnv = $getEnv($orgEnvName);
2733

tests/Unit/Infrastructure/Symfony/DependencyInjection/LitteralisCredentialsEnvVarProcessorTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,18 @@ public function testProvidedTypes(): void
1717
$processor = new LitteralisCredentialsEnvVarProcessor(
1818
$this->dialogOrgId,
1919
litteralisEnabledOrgs: [],
20+
litteralisCommunicationEnabledOrgs: [],
2021
);
2122

2223
$this->assertEquals(['litteralis_credentials' => 'string'], $processor->getProvidedTypes());
2324
}
2425

25-
private function doTest(array $enabledOrgs, array $getEnvReturnValues, ?LitteralisCredentials $expectedCredentials = null): void
26+
private function doTest(array $enabledOrgs, array $getEnvReturnValues, ?LitteralisCredentials $expectedCredentials = null, array $communicationEnabledOrgs = []): void
2627
{
2728
$processor = new LitteralisCredentialsEnvVarProcessor(
2829
$this->dialogOrgId,
2930
litteralisEnabledOrgs: $enabledOrgs,
31+
litteralisCommunicationEnabledOrgs: $communicationEnabledOrgs,
3032
);
3133

3234
$value = $processor->getEnv(
@@ -68,6 +70,23 @@ public function testEnvValid(): void
6870
);
6971
}
7072

73+
public function testEnvValidWithCommunicationOrgs(): void
74+
{
75+
$this->doTest(
76+
['test'],
77+
[
78+
['APP_LITTERALIS_ORG_TEST_ID', '1442d806-559c-41a9-aa4b-cdd18195a38f'],
79+
['APP_LITTERALIS_ORG_TEST_CREDENTIALS', 'testuser:testpass'],
80+
['APP_LITTERALIS_ORG_SAVOIE_ID', 'b556d806-559c-41a9-aa4b-cdd18195a38f'],
81+
['APP_LITTERALIS_ORG_SAVOIE_CREDENTIALS', 'savoieuser:savoiepass'],
82+
],
83+
(new LitteralisCredentials())
84+
->add('test', '1442d806-559c-41a9-aa4b-cdd18195a38f', 'testuser:testpass')
85+
->add('savoie', 'b556d806-559c-41a9-aa4b-cdd18195a38f', 'savoieuser:savoiepass'),
86+
communicationEnabledOrgs: ['savoie'],
87+
);
88+
}
89+
7190
public function testGetEnvInvalidOrgIdMissing(): void
7291
{
7392
$this->expectException(\RuntimeException::class);

0 commit comments

Comments
 (0)