Skip to content

Commit 68b87e8

Browse files
committed
Fix tests add cleanup for acct-id-tests
1 parent a029564 commit 68b87e8

File tree

6 files changed

+18
-58
lines changed

6 files changed

+18
-58
lines changed

sdk/src/Core/Amazon.Runtime/CredentialManagement/Internal/CredentialProfileTypeDetector.cs

-35
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ public static class CredentialProfileTypeDetector
101101
{
102102
new HashSet<string> { RoleArn, SourceProfile },
103103
new HashSet<string> { RoleArn, SourceProfile, AwsAccountId },
104-
new HashSet<string> { RoleArn, SourceProfile, AwsAccountId, Services },
105-
new HashSet<string> { RoleArn, SourceProfile, AwsAccountId, EndpointUrl },
106-
new HashSet<string> { RoleArn, SourceProfile, AwsAccountId, Services, EndpointUrl },
107104
}
108105
},
109106
{
@@ -118,9 +115,6 @@ public static class CredentialProfileTypeDetector
118115
{
119116
new HashSet<string> { ExternalID, RoleArn, SourceProfile },
120117
new HashSet<string> { ExternalID, RoleArn, SourceProfile, AwsAccountId },
121-
new HashSet<string> { ExternalID, RoleArn, SourceProfile, AwsAccountId, Services },
122-
new HashSet<string> { ExternalID, RoleArn, SourceProfile, AwsAccountId, EndpointUrl },
123-
new HashSet<string> { ExternalID, RoleArn, SourceProfile, AwsAccountId, EndpointUrl, Services }
124118
}
125119
},
126120
{ CredentialProfileType.AssumeRoleExternalMFA, new List<HashSet<string>>() { new HashSet<string> { ExternalID, RoleArn, SourceProfile, MfaSerial } } },
@@ -130,48 +124,33 @@ public static class CredentialProfileTypeDetector
130124
new HashSet<string> { RoleArn, WebIdentityTokenFile },
131125
new HashSet<string> { RoleArn, WebIdentityTokenFile, CredentialSource },
132126
new HashSet<string> { RoleArn, WebIdentityTokenFile, CredentialSource, AwsAccountId },
133-
new HashSet<string> { RoleArn, WebIdentityTokenFile, AwsAccountId, Services },
134-
new HashSet<string> { RoleArn, WebIdentityTokenFile, AwsAccountId, EndpointUrl },
135-
new HashSet<string> { RoleArn, WebIdentityTokenFile, AwsAccountId, EndpointUrl, Services },
136127
}
137128
},
138129
{
139130
CredentialProfileType.AssumeRoleWithWebIdentitySessionName, new List<HashSet<string>>()
140131
{
141132
new HashSet<string> { RoleArn, WebIdentityTokenFile, RoleSessionName },
142133
new HashSet<string> { RoleArn, WebIdentityTokenFile, RoleSessionName, AwsAccountId } ,
143-
new HashSet<string> { RoleArn, WebIdentityTokenFile, RoleSessionName, AwsAccountId, Services } ,
144-
new HashSet<string> { RoleArn, WebIdentityTokenFile, RoleSessionName, AwsAccountId, EndpointUrl } ,
145-
new HashSet<string> { RoleArn, WebIdentityTokenFile, RoleSessionName, AwsAccountId, Services, EndpointUrl } ,
146-
147134
}
148135
},
149136
{
150137
CredentialProfileType.AssumeRoleMFA, new List<HashSet<string>>()
151138
{
152139
new HashSet<string> { MfaSerial, RoleArn, SourceProfile },
153140
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, AwsAccountId },
154-
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, AwsAccountId, Services },
155-
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, AwsAccountId, Services, EndpointUrl},
156-
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, AwsAccountId, EndpointUrl }
157141
}
158142
},
159143
{ CredentialProfileType.Basic, new List<HashSet<string>>()
160144
{
161145
new HashSet<string> { AccessKey, SecretKey },
162146
new HashSet<string> { AccessKey, SecretKey, AwsAccountId },
163-
new HashSet<string> { AccessKey, SecretKey, AwsAccountId, EndpointUrl },
164-
new HashSet<string> { AccessKey, SecretKey, AwsAccountId, Services, EndpointUrl },
165-
new HashSet<string> { AccessKey, SecretKey, AwsAccountId, Services }
166147
}
167148
},
168149
{
169150
CredentialProfileType.SAMLRole, new List<HashSet<string>>()
170151
{
171152
new HashSet<string> { EndpointName, RoleArn },
172153
new HashSet<string> { EndpointName, RoleArn, AwsAccountId },
173-
new HashSet<string> { EndpointName, RoleArn, AwsAccountId, Services },
174-
new HashSet<string> { EndpointName, RoleArn, AwsAccountId, Services, EndpointUrl }
175154
}
176155
},
177156
{ CredentialProfileType.SAMLRoleUserIdentity, new List<HashSet<string>>() { new HashSet<string> { EndpointName, RoleArn, UserIdentity } } },
@@ -180,45 +159,34 @@ public static class CredentialProfileTypeDetector
180159
{
181160
new HashSet<string> { AccessKey, SecretKey, Token },
182161
new HashSet<string> { AccessKey, SecretKey, Token, AwsAccountId },
183-
new HashSet<string> { AccessKey, SecretKey, Token, AwsAccountId, EndpointUrl },
184-
new HashSet<string> { AccessKey, SecretKey, Token, AwsAccountId, Services, EndpointUrl }
185162
}
186163
},
187164
{
188165
CredentialProfileType.AssumeRoleSessionName, new List<HashSet<string>>()
189166
{
190167
new HashSet<string> { RoleArn, SourceProfile, RoleSessionName },
191168
new HashSet<string> { RoleArn, SourceProfile, RoleSessionName, AwsAccountId },
192-
new HashSet<string> { RoleArn, SourceProfile, RoleSessionName, AwsAccountId, Services },
193-
new HashSet<string> { RoleArn, SourceProfile, RoleSessionName, AwsAccountId, Services, EndpointUrl }
194169
}
195170
},
196171
{
197172
CredentialProfileType.AssumeRoleCredentialSourceSessionName, new List<HashSet<string>>()
198173
{
199174
new HashSet<string> { RoleArn, CredentialSource, RoleSessionName },
200175
new HashSet<string> { RoleArn, CredentialSource, RoleSessionName, AwsAccountId},
201-
new HashSet<string> { RoleArn, CredentialSource, RoleSessionName, AwsAccountId, Services},
202-
new HashSet<string> { RoleArn, CredentialSource, RoleSessionName, AwsAccountId, Services, EndpointUrl},
203176
}
204177
},
205178
{
206179
CredentialProfileType.AssumeRoleExternalSessionName, new List<HashSet<string>>()
207180
{
208181
new HashSet<string> { ExternalID, RoleArn, SourceProfile, RoleSessionName },
209182
new HashSet<string> { ExternalID, RoleArn, SourceProfile, RoleSessionName, AwsAccountId },
210-
new HashSet<string> { ExternalID, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, EndpointUrl },
211-
new HashSet<string> { ExternalID, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, EndpointUrl, Services },
212183
}
213184
},
214185
{
215186
CredentialProfileType.AssumeRoleExternalMFASessionName, new List<HashSet<string>>()
216187
{
217188
new HashSet<string> { ExternalID, MfaSerial, RoleArn, SourceProfile, RoleSessionName },
218189
new HashSet<string> { ExternalID, MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId },
219-
new HashSet<string> { ExternalID, MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, Services },
220-
new HashSet<string> { ExternalID, MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, EndpointUrl },
221-
new HashSet<string> { ExternalID, MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, Services, EndpointUrl },
222190
}
223191
},
224192
{ CredentialProfileType.SSO, new List<HashSet<string>>() { new HashSet<string> { SsoAccountId, SsoRegion, SsoRegistrationScopes, SsoRoleName, SsoStartUrl, SsoSession } } },
@@ -227,9 +195,6 @@ public static class CredentialProfileTypeDetector
227195
{
228196
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, RoleSessionName },
229197
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId },
230-
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, EndpointUrl },
231-
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, Services },
232-
new HashSet<string> { MfaSerial, RoleArn, SourceProfile, RoleSessionName, AwsAccountId, Services, EndpointUrl },
233198
}
234199
},
235200
};

sdk/src/Services/SecurityToken/Custom/SAML/SAMLAssertion.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public SAMLImmutableCredentials GetRoleCredentials(
119119
return new SAMLImmutableCredentials(response.Credentials.GetCredentials(),
120120
response.Credentials.Expiration.GetValueOrDefault().ToUniversalTime(),
121121
response.Subject,
122-
Arn.Parse(response.AssumedRoleUser.Arn).AccountId);
122+
response.AssumedRoleUser != null ? Arn.Parse(response.AssumedRoleUser.Arn).AccountId : null);
123123
}
124124

125125
/// <summary>

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

+9-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public void LookForAssumeRoleRequestChanges()
4343
[TestCategory("SecurityToken")]
4444
public void LookForProfileTypeChanges()
4545
{
46-
var expectedHash = "E15E66896846B0235881B8623AF005AA80B9DEDF4303348FC494290E0D6E2732";
46+
//1C76F6CC5D3B18FD76D4A811E5EB2FD96E97F4D4F202F38B5FBE5FAC56BE09FB
47+
var expectedHash = "1C76F6CC5D3B18FD76D4A811E5EB2FD96E97F4D4F202F38B5FBE5FAC56BE09FB";
4748
AssertExtensions.AssertEnumUnchanged(
4849
typeof(CredentialProfileType),
4950
expectedHash,
@@ -63,16 +64,19 @@ public void EnsureCredentialProfileDetectorSetup()
6364
// avoid making TypePropertyDictionary public just for unit testing
6465
var field = typeof(CredentialProfileTypeDetector).GetFields(BindingFlags.Static | BindingFlags.NonPublic).
6566
Where((fi) => fi.Name == "TypePropertyDictionary").First();
66-
var typePropertyDictionary = (Dictionary<CredentialProfileType, HashSet<string>>)field.GetValue(null);
67+
var typePropertyDictionary = (Dictionary<CredentialProfileType, List<HashSet<string>>>)field.GetValue(null);
6768

6869
foreach (var pair in typePropertyDictionary)
6970
{
7071
referencedProfileTypes.Add(pair.Key);
71-
foreach (var propertyName in pair.Value)
72+
foreach (var propertyType in pair.Value)
7273
{
73-
if (!referencedProfileOptionsProperties.Contains(propertyName))
74+
foreach (var propertyName in propertyType)
7475
{
75-
referencedProfileOptionsProperties.Add(propertyName);
76+
if (!referencedProfileOptionsProperties.Contains(propertyName))
77+
{
78+
referencedProfileOptionsProperties.Add(propertyName);
79+
}
7680
}
7781
}
7882
}

sdk/test/UnitTests/Custom/Runtime/Credentials/AccountIdEndpointTests/AccountIdBasedEndpointsTest.cs

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ static AccountIdBasedEndpointsTest()
5151
}
5252
}
5353

54+
[TestCleanup]
55+
public void Cleanup()
56+
{
57+
if (File.Exists(Executable))
58+
File.Delete(Executable);
59+
60+
}
61+
5462
//STS:1
5563
[TestMethod]
5664
public void StsAssumeRoleAccountId()

sdk/test/UnitTests/Custom/Util/get_credentials.bat

-8
This file was deleted.

sdk/test/UnitTests/Custom/Util/get_credentials.sh

-9
This file was deleted.

0 commit comments

Comments
 (0)