Skip to content

Commit

Permalink
Fix problems with non-fully-reset environment-variables after test
Browse files Browse the repository at this point in the history
  • Loading branch information
Zombaya committed May 11, 2022
1 parent ea3df80 commit 56c7ea6
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 3 deletions.
3 changes: 3 additions & 0 deletions tests/ClientSideMonitoring/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public static function _setUpBeforeClass()
'port' => getenv(ConfigurationProvider::ENV_PORT) ?: '',
'client_id' => getenv(ConfigurationProvider::ENV_CLIENT_ID) ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

Expand Down Expand Up @@ -90,6 +91,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['client_id']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
}

public function testCreatesFromEnvironmentVariables()
Expand Down
4 changes: 4 additions & 0 deletions tests/DefaultsMode/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public static function _setUpBeforeClass()
'mode' => getenv(ConfigurationProvider::ENV_MODE) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

private function clearEnv()
{
putenv(ConfigurationProvider::ENV_MODE . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -62,6 +64,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['mode']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Aws\Endpoint\UseDualstackEndpoint;
namespace Aws\Test\Endpoint\UseDualstackEndpoint;


use Aws\LruArrayCache;
Expand Down Expand Up @@ -40,13 +40,15 @@ public static function _setUpBeforeClass()
'use_dualstack_endpoint' => getenv(ConfigurationProvider::ENV_USE_DUAL_STACK_ENDPOINT) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

private function clearEnv()
{
putenv(ConfigurationProvider::ENV_USE_DUAL_STACK_ENDPOINT . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -63,6 +65,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['use_dualstack_endpoint']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down
8 changes: 6 additions & 2 deletions tests/Endpoint/UseFipsEndpoint/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Aws\Endpoint\UseFipsEndpoint;
namespace Aws\Test\Endpoint\UseFipsEndpoint;

use Aws\Endpoint\UseFipsEndpoint\ConfigurationProvider;
use Aws\LruArrayCache;
Expand Down Expand Up @@ -39,12 +39,14 @@ public static function _setUpBeforeClass()
'use_fips_endpoint' => getenv(ConfigurationProvider::ENV_USE_FIPS_ENDPOINT) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

private function clearEnv()
{
putenv(ConfigurationProvider::ENV_USE_FIPS_ENDPOINT . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');

$dir = sys_get_temp_dir() . '/.aws';
Expand All @@ -60,9 +62,11 @@ public static function _tearDownAfterClass()
{
putenv(ConfigurationProvider::ENV_USE_FIPS_ENDPOINT . '=' .
self::$originalEnv['use_fips_endpoint']);
putenv('HOME=' . self::$originalEnv['home']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv('HOME=' . self::$originalEnv['home']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
}

public function testCreatesFromEnvironmentVariables()
Expand Down
4 changes: 4 additions & 0 deletions tests/EndpointDiscovery/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static function _setUpBeforeClass()
'enabled_alt' => getenv(ConfigurationProvider::ENV_ENABLED_ALT) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

Expand All @@ -52,6 +53,7 @@ private function clearEnv()
putenv(ConfigurationProvider::ENV_ENABLED . '=');
putenv(ConfigurationProvider::ENV_ENABLED_ALT . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -70,6 +72,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['enabled_alt']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Retry/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static function _setUpBeforeClass()
'mode' => getenv(ConfigurationProvider::ENV_MODE) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

Expand All @@ -52,6 +53,7 @@ private function clearEnv()
putenv(ConfigurationProvider::ENV_MODE . '=');
putenv(ConfigurationProvider::ENV_MAX_ATTEMPTS . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -70,6 +72,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['mode']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/S3/RegionalEndpoint/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ public static function _setUpBeforeClass()
'endpoints_type' => getenv(ConfigurationProvider::ENV_ENDPOINTS_TYPE) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

private function clearEnv()
{
putenv(ConfigurationProvider::ENV_ENDPOINTS_TYPE . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -65,6 +67,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['endpoints_type']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/S3/UseArnRegion/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ public static function _setUpBeforeClass()
'use_arn_region' => getenv(ConfigurationProvider::ENV_USE_ARN_REGION) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

private function clearEnv()
{
putenv(ConfigurationProvider::ENV_USE_ARN_REGION . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -62,6 +64,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['use_arn_region']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Sts/RegionalEndpoints/ConfigurationProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public static function _setUpBeforeClass()
'endpoints_type' => getenv(ConfigurationProvider::ENV_ENDPOINTS_TYPE) ?: '',
'home' => getenv('HOME') ?: '',
'profile' => getenv(ConfigurationProvider::ENV_PROFILE) ?: '',
'config_file' => getenv(ConfigurationProvider::ENV_CONFIG_FILE) ?: '',
];
}

private function clearEnv()
{
putenv(ConfigurationProvider::ENV_ENDPOINTS_TYPE . '=');
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=');
putenv(ConfigurationProvider::ENV_PROFILE . '=');

$dir = sys_get_temp_dir() . '/.aws';

Expand All @@ -63,6 +65,8 @@ public static function _tearDownAfterClass()
self::$originalEnv['endpoints_type']);
putenv(ConfigurationProvider::ENV_PROFILE . '=' .
self::$originalEnv['profile']);
putenv(ConfigurationProvider::ENV_CONFIG_FILE . '=' .
self::$originalEnv['config_file']);
putenv('HOME=' . self::$originalEnv['home']);
}

Expand Down

0 comments on commit 56c7ea6

Please sign in to comment.