Skip to content

Commit

Permalink
Merge pull request #2 from druidfi/hash_salt_handling
Browse files Browse the repository at this point in the history
Added hash salt testing & handling
  • Loading branch information
back-2-95 authored Feb 14, 2020
2 parents c5a574b + d401b2a commit 30629a7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/EnvMapping/AmazeeIoLegacy.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function getEnvs() : array {
'DRUPAL_DB_PORT' => getenv('AMAZEEIO_DB_PORT'),
'DRUPAL_ROUTES' => getenv('AMAZEEIO_BASE_URL'),
'DRUPAL_TMP_PATH' => getenv('AMAZEEIO_TMP_PATH'),
'DRUPAL_HASH_SALT' => getenv('AMAZEEIO_HASH_SALT'),
];
}

Expand Down
1 change: 1 addition & 0 deletions tests/AmazeeIoLegacy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<env name="AMAZEEIO_DB_HOST" value="db"/>
<env name="AMAZEEIO_DB_PORT" value="3306"/>
<env name="AMAZEEIO_TMP_PATH" value="/tmp"/>
<env name="AMAZEEIO_HASH_SALT" value="hash"/>
</php>
<testsuites>
<testsuite name="drupal">
Expand Down
13 changes: 13 additions & 0 deletions tests/BaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ abstract class BaseCase extends TestCase

protected $expected_host = 'local.drupal.com';

protected $expected_hash_salt = "hash";

protected $config = [];

protected $databases = [];
Expand Down Expand Up @@ -71,6 +73,17 @@ public function testTrustedHostPattern()
$this->assertContains($pattern, $this->settings['trusted_host_patterns'], $message);
}

public function testHash()
{
if ($this->expected_hash_salt) {
$this->assertEquals($this->expected_hash_salt, $this->settings['hash_salt']);
}
// Do not test if explicitly set to null in the test class.
else {
$this->assertTrue(TRUE);
}
}

public function testConfigDefaults()
{
$app_env = getenv('APP_ENV');
Expand Down
2 changes: 2 additions & 0 deletions tests/Lagoon/LagoonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ class LagoonTest extends BaseCase
];

protected $expected_host = 'nginx-drupal-dev.ch.amazee.io';

protected $expected_hash_salt = '1a16b869ad6213440f9466338d3066fdf7d5addab8855fc3cc9928258ccbbeb0';
}
1 change: 1 addition & 0 deletions tests/Lando/LandoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
class LandoTest extends BaseCase
{
protected $expected_host = 'drupal.lndo.site';
protected $expected_hash_salt = NULL;
}
2 changes: 2 additions & 0 deletions tests/Pantheon/PantheonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
class PantheonTest extends BaseCase
{
protected $expected_host = 'live-pantheon-test.pantheon.io';

protected $expected_hash_salt = NULL;
}
2 changes: 2 additions & 0 deletions tests/Wodby/WodbyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
class WodbyTest extends BaseCase
{
protected $expected_host = 'dev.drupal.wod.by';

protected $expected_hash_salt = NULL;
}

0 comments on commit 30629a7

Please sign in to comment.