static private CreateTestUser ( |
||
client | ||
testPrefix | string | |
리턴 | string |
//[ExpectedException(typeof(NoSuchEntityException))] public void TestDeleteNonExistentAccessKeyException() { string username = IAMUtil.CreateTestUser(Client); try { CreateAccessKeyResponse response = Client.CreateAccessKeyAsync(new CreateAccessKeyRequest() { UserName = username }).Result; string keyId = response.AccessKey.AccessKeyId; Client.DeleteAccessKeyAsync(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }).Wait(); Client.DeleteAccessKeyAsync(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }).Wait(); } catch (AggregateException ae) { AssertExtensions.VerifyException <NoSuchEntityException>(ae); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
//[ExpectedException(typeof(LimitExceededException))] public void TestLimitExceedException() { string username = IAMUtil.CreateTestUser(Client); try { for (int i = 0; i < 3; i++) { Client.CreateAccessKeyAsync(new CreateAccessKeyRequest() { UserName = username }).Wait(); } } catch (AggregateException ae) { Assert.IsNotNull(ae); Assert.IsNotNull(ae.InnerExceptions); Assert.AreEqual(1, ae.InnerExceptions.Count); Assert.IsNotNull(ae.InnerExceptions[0] as LimitExceededException); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
//[ExpectedException(typeof(NoSuchEntityException))] public void TestDeleteLoginProfile() { string username = IAMUtil.CreateTestUser(Client); string password = "******"; try { Client.CreateLoginProfileAsync(new CreateLoginProfileRequest() { UserName = username, Password = password }).Wait(); UtilityMethods.Sleep(TimeSpan.FromSeconds(10)); Client.DeleteLoginProfileAsync(new DeleteLoginProfileRequest() { UserName = username }).Wait(); UtilityMethods.Sleep(TimeSpan.FromSeconds(10)); GetLoginProfileResponse getRes = Client.GetLoginProfileAsync(new GetLoginProfileRequest() { UserName = username }).Result; } catch (AggregateException ae) { AssertExtensions.VerifyException <NoSuchEntityException>(ae); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestPutGetUserPolicy() { string username = IAMUtil.CreateTestUser(Client); string policyName = "test-policy-" + DateTime.Now.Ticks; try { Client.PutUserPolicy( new PutUserPolicyRequest() { UserName = username, PolicyName = policyName, PolicyDocument = TEST_ALLOW_POLICY }); GetUserPolicyResponse response = Client.GetUserPolicy(new GetUserPolicyRequest() { UserName = username, PolicyName = policyName }); Assert.AreEqual(username, response.UserName); Assert.AreEqual(policyName, response.PolicyName); Assert.AreEqual(TEST_ALLOW_POLICY, HttpUtility.UrlDecode(response.PolicyDocument)); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestDeleteLoginProfile() { string username = IAMUtil.CreateTestUser(Client); string password = "******"; try { Client.CreateLoginProfile(new CreateLoginProfileRequest() { UserName = username, Password = password }); Thread.Sleep(3 * 3600); Client.DeleteLoginProfile(new DeleteLoginProfileRequest() { UserName = username }); Thread.Sleep(3 * 3600); GetLoginProfileResponse getRes = Client.GetLoginProfile(new GetLoginProfileRequest() { UserName = username }); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public string CreateTestUser() { var user = IAMUtil.CreateTestUser(_client, _testName); _users.Add(user); return(user); }
public void TestCreateAccessKey() { string username = IAMUtil.CreateTestUser(Client); string keyId = null; try { CreateAccessKeyResponse response = Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); keyId = response.AccessKey.AccessKeyId; Assert.IsTrue(response.AccessKey.CreateDate.Date.CompareTo(DateTime.Now.Date) == 0); } finally { if (keyId != null) { Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }); } IAMUtil.DeleteTestUsers(Client, username); } }
//[ExpectedException(typeof(EntityAlreadyExistsException))] public void TestCreateLoginProfileTwiceException() { string username = IAMUtil.CreateTestUser(Client); string password = "******"; try { Client.CreateLoginProfileAsync(new CreateLoginProfileRequest() { UserName = username, Password = password }).Wait(); UtilityMethods.Sleep(TimeSpan.FromSeconds(10)); Client.CreateLoginProfileAsync(new CreateLoginProfileRequest() { UserName = username, Password = password }).Wait(); } catch (AggregateException ae) { AssertExtensions.VerifyException <EntityAlreadyExistsException>(ae); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestDeleteNonExistentAccessKeyException() { string username = IAMUtil.CreateTestUser(Client); try { CreateAccessKeyResponse response = Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); string keyId = response.AccessKey.AccessKeyId; Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }); Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyId }); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestCreateGetLoginProfile() { string username = IAMUtil.CreateTestUser(Client); string password = "******"; try { CreateLoginProfileResponse createRes = Client.CreateLoginProfile(new CreateLoginProfileRequest { UserName = username, Password = password, PasswordResetRequired = true }); Thread.Sleep(3 * 3600); Assert.AreEqual(username, createRes.LoginProfile.UserName); GetLoginProfileResponse getRes = Client.GetLoginProfile(new GetLoginProfileRequest() { UserName = username }); Assert.AreNotEqual(DateTime.MinValue, getRes.LoginProfile.CreateDate); var login = getRes.LoginProfile; Assert.AreEqual(username, login.UserName); Assert.IsTrue(login.PasswordResetRequired); Client.UpdateLoginProfile(new UpdateLoginProfileRequest { UserName = username, Password = password, PasswordResetRequired = false }); Assert.AreEqual(username, createRes.LoginProfile.UserName); getRes = Client.GetLoginProfile(new GetLoginProfileRequest() { UserName = username }); Assert.AreNotEqual(DateTime.MinValue, getRes.LoginProfile.CreateDate); login = getRes.LoginProfile; Assert.AreEqual(username, login.UserName); Assert.IsFalse(login.PasswordResetRequired); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestGetNonExistentUserPolicyException() { string username = IAMUtil.CreateTestUser(Client); try { Client.GetUserPolicy(new GetUserPolicyRequest() { UserName = username, PolicyName = "test-policy-" + DateTime.Now.Ticks }); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestListUserPolicies() { string username = IAMUtil.CreateTestUser(Client); string[] policyNames = new string[3]; int nPolicies = 3; try { for (int i = 0; i < nPolicies; i++) { policyNames[i] = "test-policy-" + DateTime.Now.Ticks + i; Client.PutUserPolicy(new PutUserPolicyRequest() { UserName = username, PolicyName = policyNames[i], PolicyDocument = TEST_ALLOW_POLICY }); } ListUserPoliciesResponse response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); Assert.AreEqual(nPolicies, response.PolicyNames.Count()); int matches = 0; foreach (string name in response.PolicyNames) { for (int i = 0; i < nPolicies; i++) { if (name.Equals(policyNames[i])) { matches |= (1 << i); } } } Assert.AreEqual((1 << nPolicies) - 1, matches); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestGetNonExistantPolicy() { string username = IAMUtil.CreateTestUser(Client); string policyName = "test-policy-" + DateTime.Now.Ticks; try { GetUserPolicyResponse response = Client.GetUserPolicy(new GetUserPolicyRequest() { UserName = username, PolicyName = policyName }); } finally { IAMUtil.DeleteTestUsers(Client); } }
public void TestDeleteAccessKey() { string username = IAMUtil.CreateTestUser(Client); string[] keyIds = new string[2]; try { for (int i = 0; i < 2; i++) { CreateAccessKeyResponse response = Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); keyIds[i] = response.AccessKey.AccessKeyId; } ListAccessKeysResponse lakRes = Client.ListAccessKeys(new ListAccessKeysRequest() { UserName = username }); Assert.AreEqual(2, lakRes.AccessKeyMetadata.Count()); Client.DeleteAccessKey(new DeleteAccessKeyRequest() { UserName = username, AccessKeyId = keyIds[0] }); lakRes = Client.ListAccessKeys(new ListAccessKeysRequest() { UserName = username }); Assert.AreEqual(1, lakRes.AccessKeyMetadata.Count()); Assert.AreEqual(keyIds[1], lakRes.AccessKeyMetadata[0].AccessKeyId); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestPutUserPolicyMalformedPolicyDocumentException() { string username = IAMUtil.CreateTestUser(Client); string policyName = "test-policy-" + DateTime.Now.Ticks; try { Client.PutUserPolicy(new PutUserPolicyRequest() { UserName = username, PolicyName = policyName, PolicyDocument = "[" }); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestListAccessKeys() { string username = IAMUtil.CreateTestUser(Client); string[] keyIds = new string[2]; try { for (int i = 0; i < 2; i++) { CreateAccessKeyResponse response = Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); keyIds[i] = response.AccessKey.AccessKeyId; } ListAccessKeysResponse listRes = Client.ListAccessKeys(new ListAccessKeysRequest() { UserName = username }); int matches = 0; foreach (AccessKeyMetadata akm in listRes.AccessKeyMetadata) { if (akm.AccessKeyId.Equals(keyIds[0])) { matches |= 1; } if (akm.AccessKeyId.Equals(keyIds[1])) { matches |= 2; } } Assert.AreEqual(3, matches); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestLimitExceedException() { string username = IAMUtil.CreateTestUser(Client); try { for (int i = 0; i < 3; i++) { Client.CreateAccessKey(new CreateAccessKeyRequest() { UserName = username }); } } finally { IAMUtil.DeleteTestUsers(Client, username); } }
//[ExpectedException(typeof(NoSuchEntityException))] public void TestGetNonExistentUserPolicyException() { string username = IAMUtil.CreateTestUser(Client); try { Client.GetUserPolicyAsync(new GetUserPolicyRequest() { UserName = username, PolicyName = "test-policy-" + DateTime.Now.Ticks }).Wait(); } catch (AggregateException ae) { AssertExtensions.VerifyException <NoSuchEntityException>(ae); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestCreateLoginProfileTwiceException() { string username = IAMUtil.CreateTestUser(Client); string password = "******"; try { Client.CreateLoginProfile(new CreateLoginProfileRequest() { UserName = username, Password = password }); Thread.Sleep(3 * 3600); Client.CreateLoginProfile(new CreateLoginProfileRequest() { UserName = username, Password = password }); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestDeleteUserPolicy() { string username = IAMUtil.CreateTestUser(Client); string pName = "sdk-policy-" + DateTime.Now.Ticks; try { Client.PutUserPolicy(new PutUserPolicyRequest() { UserName = username, PolicyName = pName, PolicyDocument = TEST_ALLOW_POLICY }); ListUserPoliciesResponse response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); Assert.AreEqual(1, response.PolicyNames.Count()); Client.DeleteUserPolicy(new DeleteUserPolicyRequest() { UserName = username, PolicyName = pName }); response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username }); Assert.AreEqual(0, response.PolicyNames.Count()); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestListUsers() { string username1 = IAMUtil.CreateTestUser(Client); string username2 = IAMUtil.CreateTestUser(Client); string username3 = IAMUtil.CreateTestUser(Client); try { ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(3, response.Users.Count()); int matches = 0; foreach (User user in response.Users) { if (user.UserName.Equals(username1)) { matches |= 1; } if (user.UserName.Equals(username2)) { matches |= 2; } if (user.UserName.Equals(username3)) { matches |= 4; } } Assert.AreEqual(7, matches); } finally { IAMUtil.DeleteTestUsers(Client, username1, username2, username3); } }
public void TestAttachManagedPolicy() { string username = IAMUtil.CreateTestUser(Client); string policyName = "sdk-policy-" + DateTime.Now.Ticks; var policyArn = Client.CreatePolicy(new CreatePolicyRequest { PolicyName = policyName, PolicyDocument = TEST_VERSIONED_POLICY }).Policy.Arn; try { Client.AttachUserPolicy(new AttachUserPolicyRequest { UserName = username, PolicyArn = policyArn }); Client.DetachUserPolicy(new DetachUserPolicyRequest { UserName = username, PolicyArn = policyArn }); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
//[ExpectedException(typeof(MalformedPolicyDocumentException))] public void TestPutUserPolicyMalformedPolicyDocumentException() { string username = IAMUtil.CreateTestUser(Client); string policyName = "test-policy-" + DateTime.Now.Ticks; try { Client.PutUserPolicyAsync(new PutUserPolicyRequest() { UserName = username, PolicyName = policyName, PolicyDocument = "[" }).Wait(); } catch (AggregateException ae) { AssertExtensions.VerifyException <MalformedPolicyDocumentException>(ae); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestListUsersMaxResults() { string username1 = IAMUtil.CreateTestUser(Client); string username2 = IAMUtil.CreateTestUser(Client); string username3 = IAMUtil.CreateTestUser(Client); string username4 = IAMUtil.CreateTestUser(Client); try { ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { MaxItems = 2, PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(2, response.Users.Count()); Assert.AreEqual(true, response.IsTruncated); int matches = 0; foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { matches |= 1; } if (u.UserName.Equals(username2)) { matches |= 2; } if (u.UserName.Equals(username4)) { matches |= 3; } if (u.UserName.Equals(username3)) { matches |= 4; } } string marker = response.Marker; response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH, Marker = marker }); Assert.AreEqual(2, response.Users.Count()); Assert.AreEqual(false, response.IsTruncated); foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { matches |= 1; } if (u.UserName.Equals(username2)) { matches |= 2; } if (u.UserName.Equals(username4)) { matches |= 3; } if (u.UserName.Equals(username3)) { matches |= 4; } } Assert.AreEqual(7, matches); } finally { IAMUtil.DeleteTestUsers(Client, username1, username2, username3, username4); } }
public void TestListUserPoliciesPaging() { string username = IAMUtil.CreateTestUser(Client); int nPolicies = 4; string[] policyNames = new string[nPolicies]; try { for (int i = 0; i < nPolicies; i++) { policyNames[i] = "test-policy-" + DateTime.Now.Ticks + i; Client.PutUserPolicy(new PutUserPolicyRequest() { UserName = username, PolicyName = policyNames[i], PolicyDocument = TEST_ALLOW_POLICY }); } ListUserPoliciesResponse response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username, MaxItems = 2 }); Assert.AreEqual(2, response.PolicyNames.Count()); Assert.AreEqual(true, response.IsTruncated); string marker = response.Marker; int matches = 0; foreach (string name in response.PolicyNames) { for (int i = 0; i < nPolicies; i++) { if (name.Equals(policyNames[i])) { matches |= (1 << i); } } } response = Client.ListUserPolicies(new ListUserPoliciesRequest() { UserName = username, Marker = marker }); Assert.AreEqual(nPolicies - 2, response.PolicyNames.Count()); Assert.AreEqual(false, response.IsTruncated); foreach (string name in response.PolicyNames) { for (int i = 0; i < nPolicies; i++) { if (name.Equals(policyNames[i])) { matches |= (1 << i); } } } Assert.AreEqual((1 << nPolicies) - 1, matches); } finally { IAMUtil.DeleteTestUsers(Client, username); } }