Skip to content

Commit c8be7ef

Browse files
committed
clean up
1 parent 68b87e8 commit c8be7ef

File tree

8 files changed

+25
-50
lines changed

8 files changed

+25
-50
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
**/Temp/
1616
**/buildlogs/
1717
**/.vs/
18-
sdk/test/UnitTests/Custom/Util/get_credentials.bat
1918

2019
**/*project.lock.json
2120
**/project.lock.json

sdk/src/Core/Amazon.Runtime/Credentials/ProcessAWSCredentials.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ public class ProcessAWSCredentials : RefreshingAWSCredentials
5454

5555
#region Public constructors
5656
[SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")]
57-
public ProcessAWSCredentials(string processCredentialInfo, string accountId)
57+
public ProcessAWSCredentials(string processCredentialInfo)
58+
{
59+
60+
}
61+
62+
63+
public ProcessAWSCredentials(string processCredentialInfo, string accountId) : this(processCredentialInfo, null)
5864
{
5965
processCredentialInfo = processCredentialInfo.Trim();
6066

@@ -80,18 +86,12 @@ public ProcessAWSCredentials(string processCredentialInfo, string accountId)
8086
RedirectStandardOutput = true,
8187
CreateNoWindow = true
8288
};
83-
89+
8490
// Make sure to fetch new credentials well before the current credentials expire to avoid
8591
// any request being made with expired credentials.
8692
PreemptExpiryTime = TimeSpan.FromMinutes(15);
8793
}
8894

89-
90-
public ProcessAWSCredentials(string processCredentialInfo) : this(processCredentialInfo, null)
91-
{
92-
93-
}
94-
9595
#endregion
9696

9797
#region Protected overridden methods

sdk/src/Core/Amazon.Runtime/Credentials/ProcessCredentialVersion1.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class ProcessCredentialVersion1
5757
public DateTime Expiration { get; set; } = DateTime.SpecifyKind(DateTime.MaxValue, DateTimeKind.Utc);
5858

5959
/// <summary>
60-
/// The AccountId used for accountId based endpoints
60+
/// The AccountId used for AccountId based endpoints.
6161
/// </summary>
6262
public string AccountId { get; set; }
6363
}

sdk/src/Core/Amazon.Runtime/Credentials/SAMLImmutableCredentials.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
using System.Globalization;
2121
using System.Text.Json;
2222

23-
//Add constructor for account id here?
2423
namespace Amazon.Runtime
2524
{
2625
/// <summary>
@@ -64,7 +63,7 @@ public SAMLImmutableCredentials(string awsAccessKeyId,
6463
}
6564

6665
/// <summary>
67-
/// Constructs an instance with supplied keys and SAML assertion data.
66+
/// Constructs an instance with supplied keys SAML assertion data, and an account id
6867
/// </summary>
6968
/// <param name="awsAccessKeyId"></param>
7069
/// <param name="awsSecretAccessKey"></param>
@@ -84,7 +83,7 @@ public SAMLImmutableCredentials(string awsAccessKeyId,
8483
Subject = subject;
8584
}
8685
/// <summary>
87-
/// Constructs an instance with supplied keys and SAML assertion data and an accountId.
86+
/// Constructs an instance with supplied keys and SAML assertion data and an account id.
8887
/// </summary>
8988
/// <param name="credentials"></param>
9089
/// <param name="expires"></param>
@@ -112,7 +111,6 @@ public SAMLImmutableCredentials(ImmutableCredentials credentials,
112111
{
113112
}
114113

115-
116114
#endregion
117115

118116
#region Overrides

sdk/src/Core/Amazon.Runtime/Credentials/_bcl+netstandard/SSOImmutableCredentials.cs

+14-7
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,22 @@ public class SSOImmutableCredentials : ImmutableCredentials
3939
/// <param name="expiration">The expiration time for the credentials.</param>
4040
public SSOImmutableCredentials(
4141
string awsAccessKeyId, string awsSecretAccessKey,
42-
string token, DateTime expiration)
43-
: base(awsAccessKeyId, awsSecretAccessKey, token)
42+
string token, DateTime expiration) : this(awsAccessKeyId, awsSecretAccessKey, token, expiration, null)
4443
{
45-
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException(nameof(token));
46-
Expiration = expiration;
4744
}
4845

49-
public SSOImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, DateTime expiration, string accountId) : this(awsAccessKeyId, awsSecretAccessKey, token, expiration)
46+
/// <summary>
47+
/// Constructs an instance with supplied keys, token, expiration, and account id
48+
/// </summary>
49+
/// <param name="awsAccessKeyId"></param>
50+
/// <param name="awsSecretAccessKey"></param>
51+
/// <param name="token"></param>
52+
/// <param name="expiration"></param>
53+
/// <param name="accountId"></param>
54+
/// <exception cref="ArgumentNullException"></exception>
55+
public SSOImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey, string token, DateTime expiration, string accountId) : base(awsAccessKeyId, awsSecretAccessKey, token)
5056
{
57+
if (string.IsNullOrEmpty(token)) throw new ArgumentNullException(nameof(token));
5158
AccountId = accountId;
5259
}
5360

@@ -57,12 +64,12 @@ public SSOImmutableCredentials(string awsAccessKeyId, string awsSecretAccessKey,
5764
/// <returns>A copy of this object.</returns>
5865
public new SSOImmutableCredentials Copy()
5966
{
60-
return new SSOImmutableCredentials(AccessKey, SecretKey, Token, Expiration);
67+
return new SSOImmutableCredentials(AccessKey, SecretKey, Token, Expiration, AccountId);
6168
}
6269

6370
public override int GetHashCode()
6471
{
65-
return Hashing.Hash(AccessKey, SecretKey, Token, Expiration);
72+
return Hashing.Hash(AccessKey, SecretKey, Token, Expiration, AccountId);
6673
}
6774

6875
public override bool Equals(object obj)

sdk/src/Core/Amazon.Util/AWSSDKUtils.cs

-26
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
using System.Threading;
3838
using Amazon.Runtime.Endpoints;
3939
using ThirdParty.RuntimeBackports;
40-
using System.CodeDom;
41-
4240

4341
#if AWS_ASYNC_API
4442
using System.Threading.Tasks;
@@ -829,30 +827,6 @@ public static void CopyStream(Stream source, Stream destination, int bufferSize)
829827
{
830828
source.CopyTo(destination, bufferSize);
831829
}
832-
833-
/// <summary>
834-
/// Utility method to get an account id from an assume role arn. For example
835-
/// arn:aws:sts::account_id:assumed-role/assume-role-integration-test-role
836-
/// </summary>
837-
/// <param name="assumeRoleArn"></param>
838-
/// <returns></returns>
839-
public static string GetAccountIdFromAssumeRoleArn(string assumeRoleArn)
840-
{
841-
if (string.IsNullOrEmpty(assumeRoleArn))
842-
throw new ArgumentNullException("assumeRoleArn");
843-
844-
// everything between the first :: and the next :
845-
int start = assumeRoleArn.IndexOf("::");
846-
if (start == 0)
847-
throw new InvalidDataException("Arn not in expected format. please pass in a properly formatted arn");
848-
849-
//all aws account id's are 12 digits
850-
string accountId = assumeRoleArn.Substring(start + 2, 12);
851-
//validate
852-
if (accountId.Any(x => (int)x < 48 || (int)x > 57 ))
853-
throw new InvalidDataException("account id's must only contain integers");
854-
return accountId;
855-
}
856830
#endregion
857831

858832
#region Public Methods and Properties

sdk/test/Services/SecurityToken/UnitTests/Custom/StaticCheckTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public void LookForAssumeRoleRequestChanges()
4343
[TestCategory("SecurityToken")]
4444
public void LookForProfileTypeChanges()
4545
{
46-
//1C76F6CC5D3B18FD76D4A811E5EB2FD96E97F4D4F202F38B5FBE5FAC56BE09FB
4746
var expectedHash = "1C76F6CC5D3B18FD76D4A811E5EB2FD96E97F4D4F202F38B5FBE5FAC56BE09FB";
4847
AssertExtensions.AssertEnumUnchanged(
4948
typeof(CredentialProfileType),

sdk/test/UnitTests/Custom/Util/AWSSDKUtilsTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
* express or implied. See the License for the specific language governing
1313
* permissions and limitations under the License.
1414
*/
15-
using Amazon.CloudFront.Model;
1615
using Amazon.Util;
1716
using Microsoft.VisualStudio.TestTools.UnitTesting;
1817
using System;
19-
using System.CodeDom;
2018
using System.IO;
2119
using System.Reflection;
2220
using System.Text;

0 commit comments

Comments
 (0)