public void RemoveMemberCmdlet(bool globalGroup) { var user = GetAbritraryUser(); var group = DoAddGroup(_testGroupName, globalGroup, true).Data; var addRequest = GroupMemberRequestFactory.CreateAddGroupMemberRequest(group.Name, globalGroup, user.Id); var addResponse = RequestHandler.Execute <DataspaceResponse>(addRequest); var scope = globalGroup ? ODSGroupCommandBase.GroupScope.Global : ODSGroupCommandBase.GroupScope.Private; Assert.True(addResponse.Success, addResponse.Message); string[] commands = new string[] { SimpleConnectCommand(DefaultLoginData), String.Join(" ", new string[] { CmdletName(typeof(RemoveODSGroupMemberCommand)), "-Scope", scope.ToString(), "-GroupName", SingleQuote(group.Name), "-Id", user.Id.ToString() }) }; Shell.Execute(commands); // would throw an exception on failure var request = GroupMemberRequestFactory.CreateGetGroupMembersRequest(0, 30, _testGroupName, globalGroup); var members = RequestHandler.ExecuteAndUnpack <List <NamedObject> >(request); Assert.AreEqual(0, members.Count); }
public void GetMemberCmdlet(bool globalGroup) { var user = GetAbritraryUser(); var group = DoAddGroup(_testGroupName, globalGroup, true).Data; var addRequest = GroupMemberRequestFactory.CreateAddGroupMemberRequest(group.Name, globalGroup, user.Id); var addResponse = RequestHandler.Execute <DataspaceResponse>(addRequest); Assert.True(addResponse.Success, addResponse.Message); var scope = globalGroup ? ODSGroupCommandBase.GroupScope.Global : ODSGroupCommandBase.GroupScope.Private; string[] commands = new string[] { SimpleConnectCommand(DefaultLoginData), String.Join(" ", new string[] { CmdletName(typeof(GetODSGroupMemberCommand)), "-Scope", scope.ToString(), "-GroupName", SingleQuote(group.Name) }) }; var members = Shell.Execute(commands); // would throw an exception on failure Assert.AreEqual(1, members.Count); var member = members[0] as NamedObject; Assert.NotNull(member); Assert.AreEqual(user.Id, member.Id); Assert.AreEqual(user.UserName, member.Name); }
protected override void ProcessRecord() { foreach (var curId in Id) { try { var request = GroupMemberRequestFactory.CreateAddGroupMemberRequest(GroupName, Scope.Equals(GroupScope.Global), curId); if (ShouldProcess(curId.ToString())) { RequestHandler.ExecuteSuccessfully(request); } } catch (ReportableException e) { WriteError(e.ErrorRecord); } } }
public void AddAndRemoveMember(bool globalGroup) { var user = GetAbritraryUser(); var group = DoAddGroup(_testGroupName, globalGroup, true).Data; var addRequest = GroupMemberRequestFactory.CreateAddGroupMemberRequest(group.Name, globalGroup, user.Id); var addResponse = RequestHandler.Execute <DataspaceResponse>(addRequest); Assert.True(addResponse.Success, addResponse.Message); var removeRequest = GroupMemberRequestFactory.CreateRemoveGroupMemberRequest(group.Name, globalGroup, user.Id); var removeResponse = RequestHandler.Execute <DataspaceResponse>(removeRequest); Assert.True(removeResponse.Success); var request = GroupMemberRequestFactory.CreateGetGroupMembersRequest(0, 30, _testGroupName, globalGroup); var members = RequestHandler.ExecuteAndUnpack <List <NamedObject> >(request); Assert.AreEqual(0, members.Count); }