-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0d0ca0
commit 6d7bd85
Showing
5 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
using Amazon.Runtime.CredentialManagement; | ||
using Amazon.Runtime; | ||
using AWS.Deploy.CLI; | ||
|
||
namespace AWS.Deploy.CLI | ||
public class CredentialProfileStoreChainWrapper : ICredentialProfileStoreChain | ||
{ | ||
public class CredentialProfileStoreChainWrapper : ICredentialProfileStoreChain | ||
private readonly CredentialProfileStoreChain _chain; | ||
|
||
public CredentialProfileStoreChainWrapper(CredentialProfileStoreChain? chain = null) | ||
{ | ||
private readonly CredentialProfileStoreChain _chain = new CredentialProfileStoreChain(); | ||
_chain = chain ?? new CredentialProfileStoreChain(); | ||
} | ||
|
||
public bool TryGetAWSCredentials(string profileName, out AWSCredentials credentials) | ||
=> _chain.TryGetAWSCredentials(profileName, out credentials); | ||
public bool TryGetAWSCredentials(string profileName, out AWSCredentials credentials) | ||
=> _chain.TryGetAWSCredentials(profileName, out credentials); | ||
|
||
public bool TryGetProfile(string profileName, out CredentialProfile profile) | ||
=> _chain.TryGetProfile(profileName, out profile); | ||
} | ||
public bool TryGetProfile(string profileName, out CredentialProfile profile) | ||
=> _chain.TryGetProfile(profileName, out profile); | ||
} |
This file contains 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 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
47 changes: 47 additions & 0 deletions
47
test/AWS.Deploy.CLI.UnitTests/CredentialProfileStoreChainWrapperTests.cs
This file contains 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,47 @@ | ||
using Xunit; | ||
|
||
namespace AWS.Deploy.CLI.UnitTests | ||
{ | ||
public class CredentialProfileStoreChainWrapperTests | ||
{ | ||
[Fact] | ||
public void TryGetAWSCredentials_ReturnsExpectedResult() | ||
{ | ||
// Arrange | ||
var wrapper = new CredentialProfileStoreChainWrapper(); | ||
var profileName = "non-existent-profile"; // Use a profile name that's unlikely to exist | ||
|
||
// Act | ||
bool result = wrapper.TryGetAWSCredentials(profileName, out var credentials); | ||
|
||
// Assert | ||
Assert.False(result); | ||
Assert.Null(credentials); | ||
} | ||
|
||
[Fact] | ||
public void TryGetProfile_ReturnsExpectedResult() | ||
{ | ||
// Arrange | ||
var wrapper = new CredentialProfileStoreChainWrapper(); | ||
var profileName = "non-existent-profile"; // Use a profile name that's unlikely to exist | ||
|
||
// Act | ||
bool result = wrapper.TryGetProfile(profileName, out var profile); | ||
|
||
// Assert | ||
Assert.False(result); | ||
Assert.Null(profile); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_CreatesNonNullWrapper() | ||
{ | ||
// Arrange & Act | ||
var wrapper = new CredentialProfileStoreChainWrapper(); | ||
|
||
// Assert | ||
Assert.NotNull(wrapper); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
test/AWS.Deploy.CLI.UnitTests/SharedCredentialsFileWrapperTests.cs
This file contains 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,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Amazon.Runtime.CredentialManagement; | ||
using Xunit; | ||
|
||
namespace AWS.Deploy.CLI.UnitTests | ||
{ | ||
public class SharedCredentialsFileWrapperTests | ||
{ | ||
[Fact] | ||
public void ListProfileNames_ReturnsNonNullList() | ||
{ | ||
// Arrange | ||
var wrapper = new SharedCredentialsFileWrapper(); | ||
|
||
// Act | ||
var result = wrapper.ListProfileNames(); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
// The list might be empty depending on the environment, but it should never be null | ||
} | ||
|
||
[Fact] | ||
public void Constructor_CreatesNonNullWrapper() | ||
{ | ||
// Arrange & Act | ||
var wrapper = new SharedCredentialsFileWrapper(); | ||
|
||
// Assert | ||
Assert.NotNull(wrapper); | ||
} | ||
|
||
[Fact] | ||
public void ListProfileNames_ReturnsListOfStrings() | ||
{ | ||
// Arrange | ||
var wrapper = new SharedCredentialsFileWrapper(); | ||
|
||
// Act | ||
var result = wrapper.ListProfileNames(); | ||
|
||
// Assert | ||
Assert.IsType<List<string>>(result); | ||
} | ||
} | ||
} |