Skip to content
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

UHF-X update domains #88

Merged
merged 7 commits into from
Jan 18, 2023
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
90 changes: 9 additions & 81 deletions fixtures/environments.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@
"protocol": "http",
"domain": "helfi-asuminen.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-asuminen",
"sv": "/sv/dev-boende",
"en": "/en/dev-housing"
},
"domain": "nginx-asuminen-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-asuminen",
"sv": "/sv/test-boende",
"en": "/en/test-housing"
},
"domain": "nginx-asuminen-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -52,21 +44,13 @@
"protocol": "http",
"domain": "helfi-etusivu.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-etusivu",
"sv": "/sv/dev-huvudsida",
"en": "/en/dev-frontpage"
},
"domain": "nginx-etusivu-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-etusivu",
"sv": "/sv/test-huvudsida",
"en": "/en/test-frontpage"
},
"domain": "nginx-etusivu-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -95,21 +79,13 @@
"protocol": "http",
"domain": "helfi-kasko.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-kasvatus-koulutus",
"sv": "/sv/dev-fostran-och-utbildning",
"en": "/en/dev-childhood-and-education"
},
"domain": "nginx-kasvatus-koulutus-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-kasvatus-koulutus",
"sv": "/sv/test-fostran-och-utbildning",
"en": "/en/test-childhood-and-education"
},
"domain": "nginx-kasvatus-koulutus-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -138,21 +114,13 @@
"protocol": "http",
"domain": "helfi-kuva.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-kulttuuri-ja-vapaa-aika",
"sv": "/sv/dev-kultur-och-fritid",
"en": "/en/dev-culture-and-leisure"
},
"domain": "nginx-kuva-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-kulttuuri-ja-vapaa-aika",
"sv": "/sv/test-kultur-och-fritid",
"en": "/en/test-culture-and-leisure"
},
"domain": "nginx-kuva-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -181,21 +149,13 @@
"protocol": "http",
"domain": "helfi-kymp.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-kaupunkiymparisto-ja-liikenne",
"sv": "/sv/dev-stadsmiljo-och-trafik",
"en": "/en/dev-urban-environment-and-traffic"
},
"domain": "nginx-liikenne-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-kaupunkiymparisto-ja-liikenne",
"sv": "/sv/test-stadsmiljo-och-trafik",
"en": "/en/test-urban-environment-and-traffic"
},
"domain": "nginx-liikenne-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -224,21 +184,13 @@
"protocol": "http",
"domain": "helfi-rekry.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-avoimet-tyopaikat",
"sv": "/sv/dev-lediga-jobb",
"en": "/en/dev-open-jobs"
},
"domain": "nginx-rekry-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-avoimet-tyopaikat",
"sv": "/sv/test-lediga-jobb",
"en": "/en/test-open-jobs"
},
"domain": "nginx-rekry-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -267,21 +219,13 @@
"protocol": "http",
"domain": "strategia.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-paatoksenteko-ja-hallinto",
"sv": "/sv/dev-beslutsfattande-och-forvaltning",
"en": "/en/dev-decision-making"
},
"domain": "nginx-strategia-talous-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-paatoksenteko-ja-hallinto",
"sv": "/sv/test-beslutsfattande-och-forvaltning",
"en": "/en/test-decision-making"
},
"domain": "nginx-strategia-talous-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -310,21 +254,13 @@
"protocol": "http",
"domain": "helfi-sote.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-sosiaali-ja-terveyspalvelut",
"sv": "/sv/dev-social-och-halsovardstjanster",
"en": "/en/dev-health-and-social-services"
},
"domain": "nginx-terveys-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-sosiaali-ja-terveyspalvelut",
"sv": "/sv/test-social-och-halsovardstjanster",
"en": "/en/test-health-and-social-services"
},
"domain": "nginx-terveys-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down Expand Up @@ -353,21 +289,13 @@
"protocol": "http",
"domain": "helfi-elo.docker.so:8080"
},
"dev": {
"path": {
"fi": "/fi/dev-yritykset-ja-tyo",
"sv": "/sv/dev-foretag-och-arbete",
"en": "/en/dev-business-and-work"
},
"domain": "nginx-tyo-yrittaminen-dev.agw.arodevtest.hel.fi"
},
"test": {
"path": {
"fi": "/fi/test-yritykset-ja-tyo",
"sv": "/sv/test-foretag-och-arbete",
"en": "/en/test-business-and-work"
},
"domain": "nginx-tyo-yrittaminen-test.agw.arodevtest.hel.fi"
"domain": "www.hel.fi"
},
"stage": {
"path": {
Expand Down
6 changes: 2 additions & 4 deletions src/Environment/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ public function getEnvironment(string $environment) : Environment {
* The environment name.
*/
private function mapEnvironmentName(string $environment) : ? string {
// APP_ENV uses 'production', 'staging', 'testing' and 'development' as
// a name, while environment resolver uses 'local', 'dev', 'test,' 'stage'
// APP_ENV uses 'production', 'staging' and 'testing' as
// a name, while environment resolver uses 'local', 'test,' 'stage'
// and 'prod'.
// Map all known environment name variations to match environment resolver.
$environments = [
'devel' => 'dev',
'development' => 'dev',
'testing' => 'test',
'staging' => 'stage',
'production' => 'prod',
Expand Down
8 changes: 0 additions & 8 deletions tests/fixtures/environments.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
},
"domain": "www.hel.fi"
},
"dev": {
"path": {
"fi": "/fi/dev-asuminen",
"sv": "/sv/dev-boende",
"en": "/en/dev-housing"
},
"domain": "helfi-asuminen-dev.docker.so"
},
"test": {
"path": {
"fi": "/fi/test-asuminen",
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Kernel/EnvironmentResponseSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public function testNoResponseHeader() : void {
*/
public function testHeadersExist() : void {
$this->config('helfi_api_base.environment_resolver.settings')
->set('environment_name', 'dev')
->set('environment_name', 'test')
->set('project_name', 'liikenne')
->save();

$event = $this->getResponseEvent();
$this->getSut()->onResponse($event);
$this->assertEquals('dev', $event->getResponse()->headers->get(EnvironmentResponseSubscriber::ENVIRONMENT_HEADER_NAME));
$this->assertEquals('test', $event->getResponse()->headers->get(EnvironmentResponseSubscriber::ENVIRONMENT_HEADER_NAME));
$this->assertEquals('liikenne', $event->getResponse()->headers->get(EnvironmentResponseSubscriber::INSTANCE_HEADER_NAME));
}

Expand Down
27 changes: 2 additions & 25 deletions tests/src/Unit/EnvironmentResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function testResolveUrlException(
public function resolvePathExceptionData() : array {
return [
['nonexistent', '', '', 'Project "nonexistent" not found.'],
['asuminen', 'sk', 'dev', 'Path not found for "sk" language.'],
['asuminen', 'sk', 'test', 'Path not found for "sk" language.'],
['asuminen', 'en', 'nonexistent', 'Environment "nonexistent" not found.'],
];
}
Expand Down Expand Up @@ -208,8 +208,6 @@ public function testEnvironmentMap(string $envName, string $expected) : void {
*/
public function environmentMapData() : array {
return [
['development', 'dev'],
['devel', 'dev'],
['testing', 'test'],
['production', 'prod'],
['staging', 'stage'],
Expand Down Expand Up @@ -261,27 +259,6 @@ public function testValidUrl(
*/
public function validUrlData() : array {
return [
[
'asuminen',
'fi',
'dev',
'https://helfi-asuminen-dev.docker.so/fi/dev-asuminen',
'https://helfi-asuminen-dev.docker.so/fi/dev-asuminen',
],
[
'asuminen',
'en',
'dev',
'https://helfi-asuminen-dev.docker.so/en/dev-housing',
'https://helfi-asuminen-dev.docker.so/en/dev-housing',
],
[
'asuminen',
'sv',
'dev',
'https://helfi-asuminen-dev.docker.so/sv/dev-boende',
'https://helfi-asuminen-dev.docker.so/sv/dev-boende',
],
[
'asuminen',
'fi',
Expand Down Expand Up @@ -405,7 +382,7 @@ public function testGetActiveEnvironmentFallback() : void {
* @covers \Drupal\helfi_api_base\Environment\Project::mapEnvironmentName
*/
public function testGetActiveEnvironment() : void {
$sut = $this->getEnvironmentResolver(Project::ASUMINEN, 'dev');
$sut = $this->getEnvironmentResolver(Project::ASUMINEN, 'test');
$this->assertInstanceOf(Environment::class, $sut->getActiveEnvironment());
}

Expand Down