public void AssertWriteProfile( string profileName, CredentialProfileOptions profileOptions, Dictionary <string, string> properties, RegionEndpoint region, Guid?uniqueKey, bool?endpointDiscoveryEnabled, RequestRetryMode?retryMode, int?maxAttempts, string expectedFileContents) { CredentialsFile.RegisterProfile( CredentialProfileTestHelper.GetCredentialProfile( uniqueKey: uniqueKey, profileName: profileName, options: profileOptions, properties: properties, defaultConfigurationModeName: null, region: region, endpointDiscoveryEnabled: endpointDiscoveryEnabled, retryMode: retryMode, maxAttempts: maxAttempts)); AssertCredentialsFileContents(expectedFileContents); }
public CredentialProfile ReadAndAssertProfile(string profileName, CredentialProfileOptions expectedProfileOptions, Dictionary <string, string> expectedProperties, RegionEndpoint expectedRegion, Guid?expectedUniqueKey) { var expectedProfile = CredentialProfileTestHelper.GetCredentialProfile(expectedUniqueKey, profileName, expectedProfileOptions, expectedProperties, expectedRegion); var actualProfile = TestTryGetProfile(profileName, true, expectedProfile.CanCreateAWSCredentials); Assert.AreEqual(expectedProfile, actualProfile); return(actualProfile); }
public void ListProfilesExcludeInvalid() { using (var tester = new NetSDKCredentialsFileTestFixture(InvalidProfileText)) { tester.ProfileStore.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile( Guid.NewGuid(), "SessionProfile", CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.Session))); var profiles = tester.ProfileStore.ListProfiles(); Assert.AreEqual(1, profiles.Count); Assert.AreEqual("SessionProfile", profiles[0].Name); } }
public void ListProfileNames() { using (var tester = new NetSDKCredentialsFileTestFixture()) { tester.ProfileStore.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(Guid.NewGuid(), "SessionProfile", CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.Session))); var profileNames = tester.ProfileStore.ListProfileNames(); Assert.AreEqual(1, profileNames.Count); Assert.IsTrue(profileNames.Contains("SessionProfile")); } }
public void AssertWriteProfileMaxAttempts(string profileName, CredentialProfileOptions profileOptions, int maxAttempts, string expectedFileContents) { CredentialsFile.RegisterProfile( CredentialProfileTestHelper.GetCredentialProfile( uniqueKey: null, profileName: profileName, options: profileOptions, properties: null, defaultConfigurationModeName: null, region: null, endpointDiscoveryEnabled: null, retryMode: null, maxAttempts: maxAttempts)); AssertCredentialsFileContents(expectedFileContents); }
public void UnregisterProfile() { using (var tester = new NetSDKCredentialsFileTestFixture()) { // register tester.ProfileStore.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(Guid.NewGuid(), CredentialProfileType.Basic.ToString(), CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.Basic))); // check that it's there tester.TestTryGetProfile(CredentialProfileType.Basic.ToString(), true, true); // unregister tester.ProfileStore.UnregisterProfile(CredentialProfileType.Basic.ToString()); // check that it's not there tester.TestTryGetProfile(CredentialProfileType.Basic.ToString(), false, false); } }
public void TestWriteCompatibilityBasic() { using (var tester = new NetSDKCredentialsFileTestFixture()) { // write with new NetSDKCredentialsFile CredentialProfile profile = CredentialProfileTestHelper.GetCredentialProfile( Guid.NewGuid(), "BasicProfile", CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.Basic)); tester.ProfileStore.RegisterProfile(profile); // read with old ProfileManager AWSCredentials credentials; Assert.IsTrue(ProfileManager.TryGetAWSCredentials("BasicProfile", out credentials)); Assert.IsNotNull(credentials); var immutableCredentials = credentials.GetCredentials(); Assert.AreEqual(profile.Options.AccessKey, immutableCredentials.AccessKey); Assert.AreEqual(profile.Options.SecretKey, immutableCredentials.SecretKey); } }
public void TestWriteCompatibilitySession() { using (var tester = new NetSDKCredentialsFileTestFixture()) { // write a type that's not supported by ProfileManager tester.ProfileStore.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile( Guid.NewGuid(), "SessionProfile", CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.Session))); // make sure profile manager can't read it as a basic profile, and that there aren't any errors. AWSCredentials credentials; Assert.IsFalse(ProfileManager.TryGetAWSCredentials("SessionProfile", out credentials)); Assert.IsNull(credentials); // make sure profile manager can't read it as a SAML profile, and that there aren't any errors. SAMLRoleProfile samlProfile; Assert.IsFalse(ProfileManager.TryGetProfile("SessionProfile", out samlProfile)); Assert.IsNull(samlProfile); } }
public void TestWriteCompatibilitySAML() { using (var tester = new NetSDKCredentialsFileTestFixture()) { // write with new NetSDKCredentialsFile CredentialProfile profile = CredentialProfileTestHelper.GetCredentialProfile( Guid.NewGuid(), "SAMLProfile", CredentialProfileTestHelper.GetRandomOptions(CredentialProfileType.SAMLRoleUserIdentity)); tester.ProfileStore.RegisterProfile(profile); // TODO do this with the new SAML Endpoint Manager ProfileManager.RegisterSAMLEndpoint(profile.Options.EndpointName, new Uri("https://somesamlendpoint/"), null); // read with old ProfileManager SAMLRoleProfile samlProfile; Assert.IsTrue(ProfileManager.TryGetProfile("SAMLProfile", out samlProfile)); Assert.IsNotNull(samlProfile); Assert.AreEqual(profile.Options.EndpointName, samlProfile.EndpointSettings.Name); Assert.AreEqual(profile.Options.RoleArn, samlProfile.RoleArn); Assert.AreEqual(profile.Options.UserIdentity, samlProfile.UserIdentity); } }
public void AssertWriteProfile( string profileName, CredentialProfileOptions profileOptions, Dictionary <string, string> properties, RegionEndpoint region, string expectedFileContents) { CredentialsFile.RegisterProfile( CredentialProfileTestHelper.GetCredentialProfile( uniqueKey: null, profileName: profileName, options: profileOptions, properties: properties, defaultConfigurationModeName: null, region: region, endpointDiscoveryEnabled: null, retryMode: null, maxAttempts: null)); AssertWriteProfile(profileName, profileOptions, properties, null, null, expectedFileContents); }
public CredentialProfile ReadAndAssertProfile( string profileName, CredentialProfileOptions expectedProfileOptions, Dictionary <string, string> expectedProperties, RegionEndpoint expectedRegion, Guid?expectedUniqueKey) { var expectedProfile = CredentialProfileTestHelper.GetCredentialProfile( uniqueKey: expectedUniqueKey, profileName: profileName, options: expectedProfileOptions, properties: expectedProperties, defaultConfigurationModeName: null, region: expectedRegion, endpointDiscoveryEnabled: null, retryMode: null, maxAttempts: null); var actualProfile = TestTryGetProfile(profileName, true, expectedProfile.CanCreateAWSCredentials); Assert.AreEqual(expectedProfile, actualProfile); return(actualProfile); }
public void AssertWriteProfile(string profileName, CredentialProfileOptions profileOptions, Dictionary <string, string> properties, RegionEndpoint region, Guid?uniqueKey, string expectedFileContents) { CredentialsFile.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(uniqueKey, profileName, profileOptions, properties, region)); AssertCredentialsFileContents(expectedFileContents); }
public void AssertWriteProfileMaxAttempts(string profileName, CredentialProfileOptions profileOptions, int maxAttempts, string expectedFileContents) { CredentialsFile.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(null, profileName, profileOptions, null, null, null, null, maxAttempts)); AssertCredentialsFileContents(expectedFileContents); }
public void AssertWriteProfileRetryMode(string profileName, CredentialProfileOptions profileOptions, RequestRetryMode retryMode, string expectedFileContents) { CredentialsFile.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(null, profileName, profileOptions, null, null, null, retryMode, null)); AssertCredentialsFileContents(expectedFileContents); }
public void AssertWriteProfile(string profileName, CredentialProfileOptions profileOptions, Dictionary <string, string> properties, RegionEndpoint region, string expectedFileContents) { CredentialsFile.RegisterProfile(CredentialProfileTestHelper.GetCredentialProfile(null, profileName, profileOptions, properties, region, null, null, null)); AssertWriteProfile(profileName, profileOptions, properties, null, null, expectedFileContents); }