-
Notifications
You must be signed in to change notification settings - Fork 61
Link environments to credential pairs #2038
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d1ff05d
Link environments to credential pairs
danepowell e07415e
add description
danepowell b643847
add test, fix warning, add validation
danepowell 633ee2c
Merge branch 'main' into auth-login-environment
deepakmishra2 99bd93d
add coverage
danepowell a7f7ac4
kill mutant
danepowell 1ec92b8
mutants
danepowell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Acquia\Cli\Tests\CloudApi; | ||
|
|
||
| use Acquia\Cli\Tests\TestBase; | ||
|
|
||
| class CloudCredentialsTest extends TestBase | ||
| { | ||
| public function testGetBaseUriReturnsNullWhenNoStoredUri(): void | ||
| { | ||
| $this->assertNull($this->cloudCredentials->getBaseUri()); | ||
| $this->assertNull($this->cloudCredentials->getAccountsUri()); | ||
| } | ||
|
|
||
| public function testGetBaseUriReturnsStoredUriWhenNoEnvVar(): void | ||
| { | ||
| $this->datastoreCloud->set('keys', [ | ||
| self::$key => [ | ||
| 'accounts_uri' => 'https://staging.accounts.acquia.com/api/auth/oauth/token', | ||
| 'cloud_api_base_uri' => 'https://staging.cloud.acquia.com/api', | ||
| 'label' => 'Test Key', | ||
| 'secret' => self::$secret, | ||
| 'uuid' => self::$key, | ||
| ], | ||
| ]); | ||
|
|
||
| $this->assertSame('https://staging.cloud.acquia.com/api', $this->cloudCredentials->getBaseUri()); | ||
| $this->assertSame('https://staging.accounts.acquia.com/api/auth/oauth/token', $this->cloudCredentials->getAccountsUri()); | ||
| } | ||
|
|
||
| public function testGetBaseUriReturnsNullWhenActiveKeyNotInKeysArray(): void | ||
| { | ||
| $this->datastoreCloud->set('keys', [ | ||
| self::$key => [ | ||
| 'accounts_uri' => 'https://staging.accounts.acquia.com/api/auth/oauth/token', | ||
| 'cloud_api_base_uri' => 'https://staging.cloud.acquia.com/api', | ||
| 'label' => 'Test Key', | ||
| 'secret' => self::$secret, | ||
| 'uuid' => self::$key, | ||
| ], | ||
| ]); | ||
| $this->datastoreCloud->set('acli_key', 'nonexistent-key-uuid'); | ||
|
|
||
| $this->assertNull($this->cloudCredentials->getBaseUri()); | ||
| $this->assertNull($this->cloudCredentials->getAccountsUri()); | ||
| } | ||
|
|
||
| public function testGetBaseUriEnvVarTakesPriorityOverStoredUri(): void | ||
| { | ||
| $this->datastoreCloud->set('keys', [ | ||
| self::$key => [ | ||
| 'accounts_uri' => 'https://staging.accounts.acquia.com/api/auth/oauth/token', | ||
| 'cloud_api_base_uri' => 'https://staging.cloud.acquia.com/api', | ||
| 'label' => 'Test Key', | ||
| 'secret' => self::$secret, | ||
| 'uuid' => self::$key, | ||
| ], | ||
| ]); | ||
| putenv('ACLI_CLOUD_API_BASE_URI=https://qa.cloud.acquia.com/api'); | ||
| putenv('ACLI_CLOUD_API_ACCOUNTS_URI=https://qa.accounts.acquia.com/api/auth/oauth/token'); | ||
|
|
||
| try { | ||
| $this->assertSame('https://qa.cloud.acquia.com/api', $this->cloudCredentials->getBaseUri()); | ||
| $this->assertSame('https://qa.accounts.acquia.com/api/auth/oauth/token', $this->cloudCredentials->getAccountsUri()); | ||
| } finally { | ||
| putenv('ACLI_CLOUD_API_BASE_URI'); | ||
| putenv('ACLI_CLOUD_API_ACCOUNTS_URI'); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm open to making this parameter completely hidden (if that's possible), or changing the language so there's no confusion between Cloud API environments (aka realms) and Cloud environments.