public void TestUpdateUser() { string username = "******" + DateTime.Now.Ticks, newusername = "******" + DateTime.Now.Ticks; string firstPath = IAMUtil.MakePath("first"), secondPath = IAMUtil.MakePath("second"); try { Client.CreateUser(new CreateUserRequest() { UserName = username, Path = firstPath }); GetUserResponse response = Client.GetUser(new GetUserRequest() { UserName = username }); Assert.AreEqual(firstPath, response.User.Path); string id = response.User.UserId; Client.UpdateUser(new UpdateUserRequest() { UserName = username, NewPath = secondPath, NewUserName = newusername }); response = Client.GetUser(new GetUserRequest() { UserName = newusername }); Assert.AreEqual(newusername, response.User.UserName); Assert.AreEqual(secondPath, response.User.Path); Assert.AreEqual(id, response.User.UserId); } finally { Client.DeleteUser(new DeleteUserRequest() { UserName = newusername }); } }
public void TestUserWithPath() { string username = "******" + DateTime.Now.Ticks; string path = IAMUtil.MakePath("one", "two", "three"); try { Client.CreateUser(new CreateUserRequest() { UserName = username, Path = path }); GetUserResponse response = Client.GetUser(new GetUserRequest() { UserName = username }); Assert.AreEqual(username, response.User.UserName); Assert.AreEqual(path, response.User.Path); } finally { IAMUtil.DeleteTestUsers(Client, username); } }
public void TestListGroupWithPaths() { string groupname1 = "group1" + DateTime.Now.Ticks, groupname2 = "group2" + DateTime.Now.Ticks, groupname3 = "group3" + DateTime.Now.Ticks, groupname4 = "group4" + DateTime.Now.Ticks; string pathA = IAMUtil.MakePath("A"), pathB = IAMUtil.MakePath("B"); try { Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname1, Path = pathA }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname2, Path = pathA }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname3, Path = pathB }); Client.CreateGroup(new CreateGroupRequest() { GroupName = groupname4, Path = pathB }); ListGroupsResponse response = Client.ListGroups(new ListGroupsRequest() { PathPrefix = pathA }); Assert.AreEqual(2, response.Groups.Count()); int matches = 0; foreach (Group g in response.Groups) { if (g.GroupName.Equals(groupname1)) { matches |= 1; } if (g.GroupName.Equals(groupname2)) { matches |= 2; } if (g.GroupName.Equals(groupname3)) { Assert.Fail(); } if (g.GroupName.Equals(groupname4)) { Assert.Fail(); } } response = Client.ListGroups(new ListGroupsRequest() { PathPrefix = pathB }); Assert.AreEqual(2, response.Groups.Count()); foreach (Group g in response.Groups) { if (g.GroupName.Equals(groupname1)) { Assert.Fail(); } if (g.GroupName.Equals(groupname2)) { Assert.Fail(); } if (g.GroupName.Equals(groupname3)) { matches |= 4; } if (g.GroupName.Equals(groupname4)) { matches |= 8; } } Assert.AreEqual(15, matches); } finally { Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname1 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname2 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname3 }); Client.DeleteGroup(new DeleteGroupRequest() { GroupName = groupname4 }); } }
public void TestListUsersByPath() { string username1 = "sdk-testuser1-" + DateTime.Now.Ticks; string username2 = "sdk-testuser2-" + DateTime.Now.Ticks; string username3 = "sdk-testuser3-" + DateTime.Now.Ticks; string username4 = "sdk-testuser4-" + DateTime.Now.Ticks; string pathA = IAMUtil.MakePath("A"); string pathB = IAMUtil.MakePath("B"); try { Client.CreateUser(new CreateUserRequest() { UserName = username1, Path = pathA }); Client.CreateUser(new CreateUserRequest() { UserName = username2, Path = pathA }); Client.CreateUser(new CreateUserRequest() { UserName = username3, Path = pathB }); Client.CreateUser(new CreateUserRequest() { UserName = username4, Path = pathA }); ListUsersResponse response = Client.ListUsers(new ListUsersRequest() { PathPrefix = pathA }); Assert.AreEqual(3, response.Users.Count()); 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 |= 4; } if (u.UserName.Equals(username3)) { Assert.Fail(); } } Assert.AreEqual(7, matches); response = Client.ListUsers(new ListUsersRequest() { PathPrefix = pathB }); Assert.AreEqual(1, response.Users.Count()); matches = 0; foreach (User u in response.Users) { if (u.UserName.Equals(username1)) { Assert.Fail(); } if (u.UserName.Equals(username2)) { Assert.Fail(); } if (u.UserName.Equals(username4)) { Assert.Fail(); } if (u.UserName.Equals(username3)) { matches = 1; } } Assert.AreEqual(1, matches); response = Client.ListUsers(new ListUsersRequest() { PathPrefix = IAMUtil.TEST_PATH }); Assert.AreEqual(4, response.Users.Count()); } finally { IAMUtil.DeleteTestUsers(Client, username1, username2, username3, username4); } }
public IAMTestSession(string testName, AmazonIdentityManagementServiceClient client) { Prefix = IAMUtil.MakePath(testName); _testName = testName; _client = client; }