Skip to content

Commit

Permalink
Merged Pull Request '#40 resource-key-env-var->main : Ensure resource…
Browse files Browse the repository at this point in the history
…_key environment variable is consistently used'

Ensure resource_key environment variable is consistently used
  • Loading branch information
Automation51D authored Jan 19, 2024
2 parents e1d46fb + 64380f0 commit 397a227
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion ci/run-integration-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (!$Keys.TestResourceKey) {
return
}

$env:RESOURCEKEY = $Keys.TestResourceKey
$env:resource_key = $Keys.TestResourceKey

./php/run-integration-tests.ps1 -RepoName $RepoName

Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<phpunit bootstrap="vendor/autoload.php">
<php>
<env name="RESOURCEKEY" value="!!YOUR_RESOURCE_KEY!!"/>
<env name="resource_key" value="!!YOUR_RESOURCE_KEY!!"/>
</php>
<testsuites>
<testsuite name="Unit">
Expand Down
55 changes: 30 additions & 25 deletions tests/CloudRequestTests.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?php
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
/* *********************************************************************
* This Original Work is copyright of 51 Degrees Mobile Experts Limited.
* Copyright 2023 51 Degrees Mobile Experts Limited, Davidson House,
* Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
*
* This Original Work is licensed under the European Union Public Licence
* (EUPL) v.1.2 and is subject to its terms as set out below.
*
* If a copy of the EUPL was not distributed with this file, You can obtain
* one at https://opensource.org/licenses/EUPL-1.2.
*
* The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
* amended by the European Commission) shall be deemed incompatible for
* the purposes of the Work and the provisions of the compatibility
* clause in Article 5 of the EUPL shall not apply.
*
* If using the Work as, or as part of, a network application, by
* including the attribution notice(s) required under Article 5 of the EUPL
* in the end user terms of the application under an appropriate heading,
* such notice(s) shall fulfill the requirements of that article.
* ********************************************************************* */

namespace fiftyone\pipeline\cloudrequestengine\tests;
Expand All @@ -33,7 +33,7 @@ class CloudRequestTests extends CloudRequestEngineTestsBase
{
public function testCloudRequestEngine()
{
$params = ['resourceKey' => $_ENV['RESOURCEKEY']];
$params = ['resourceKey' => $this->getResourceKey()];

$this->assertNotSame(
'!!YOUR_RESOURCE_KEY!!',
Expand Down Expand Up @@ -73,7 +73,7 @@ public function testCloudRequestEngine()
*/
public function testCloudPostRequestWithSequenceEvidence()
{
$params = ['resourceKey' => $_ENV['RESOURCEKEY']];
$params = ['resourceKey' => $this->getResourceKey()];

$this->assertNotSame(
'!!YOUR_RESOURCE_KEY!!',
Expand Down Expand Up @@ -121,7 +121,7 @@ public function testCloudGetRequestWithSequenceEvidence()
$httpClient = new HttpClient();

$params = [
'resourceKey' => $_ENV['RESOURCEKEY'],
'resourceKey' => $this->getResourceKey(),
'httpClient' => $httpClient
];

Expand Down Expand Up @@ -202,7 +202,7 @@ public function testHttpDataSetInException()
public function testPipelineSuppressesExceptionsWhenCloudServiceIsDown()
{
$params = [
'resourceKey' => $_ENV['RESOURCEKEY'],
'resourceKey' => $this->getResourceKey(),
'httpClient' => $this->mockHttp()
];

Expand Down Expand Up @@ -246,7 +246,7 @@ public function testPipelineSuppressesExceptionsWhenCloudServiceIsDown()
public function testPipelineDoesNotSuppressExceptionsWhenCloudServiceIsDown()
{
$params = [
'resourceKey' => $_ENV['RESOURCEKEY'],
'resourceKey' => $this->getResourceKey(),
'httpClient' => $this->mockHttp()
];

Expand Down Expand Up @@ -277,4 +277,9 @@ public function testPipelineDoesNotSuppressExceptionsWhenCloudServiceIsDown()
$this->expectException(CloudRequestException::class);
$fd->process();
}

private function getResourceKey()
{
return $_ENV[self::resourceKey] ?? null;
}
}

0 comments on commit 397a227

Please sign in to comment.