public void GetPrivateAccountGroupPicturesTest() { WebGroupService.TransitAccountGroup t_group = new WebGroupService.TransitAccountGroup(); t_group.Name = GetNewString(); t_group.IsPrivate = true; t_group.Description = GetNewString(); t_group.Id = EndPoint.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group); WebGroupService.TransitAccountGroupPicture t_instance = new WebGroupService.TransitAccountGroupPicture(); t_instance.AccountGroupId = t_group.Id; t_instance.AccountId = GetAdminAccount().Id; t_instance.Bitmap = GetNewBitmap(); t_instance.Description = GetNewString(); t_instance.Name = GetNewString(); t_instance.Id = Create(GetAdminTicket(), t_instance); try { WebGroupService.TransitAccountGroupPicture[] pictures = EndPoint.GetAccountGroupPictures( _user.ticket, t_group.Id, null); Assert.IsTrue(false, "Expected Access Denied exception."); } catch (Exception ex) { Console.WriteLine("Exception: {0}", ex.Message); Assert.AreEqual("System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> SnCore.Services.ManagedAccount+AccessDeniedException: Access denied", ex.Message.Split("\n".ToCharArray(), 2)[0], string.Format("Unexpected exception: {0}", ex.Message)); } Delete(GetAdminTicket(), t_instance.Id); EndPoint.DeleteAccountGroup(GetAdminTicket(), t_group.Id); }
public void CreateAccountGroupInvitationTest() { WebGroupService.TransitAccountGroup t_group = new WebGroupService.TransitAccountGroup(); t_group.Description = GetNewString(); t_group.Name = GetNewString(); t_group.IsPrivate = false; WebGroupService.WebGroupService groupService = new WebGroupService.WebGroupService(); t_group.Id = groupService.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group); // create an invitation from admin to a new user with a group WebAccountService.TransitAccountInvitation t_instance = GetTransitInstance(); t_instance.AccountGroupId = t_group.Id; t_instance.Id = Create(GetAdminTicket(), t_instance); // sign-up with this invitation WebAccountService.TransitAccount t_account = new WebAccountService.TransitAccount(); t_account.Name = GetNewString(); t_account.Password = GetNewString(); t_account.Birthday = DateTime.UtcNow.AddYears(-10); string ticket = EndPoint.CreateAccountWithInvitationAndLogin(t_instance.Id, t_instance.Code, t_account); Assert.IsFalse(string.IsNullOrEmpty(ticket)); int id = EndPoint.GetAccountId(ticket); Assert.IsTrue(id > 0); Console.WriteLine("New account: {0}", id); // account must also be a member of the group WebGroupService.TransitAccountGroupAccount[] groupAccounts = groupService.GetAccountGroupAccountsByAccountId( ticket, id, null); Assert.IsNotEmpty(groupAccounts); Assert.AreEqual(1, groupAccounts.Length); Assert.AreEqual(t_group.Id, groupAccounts[0].AccountGroupId); Assert.AreEqual(id, groupAccounts[0].AccountId); EndPoint.DeleteAccount(ticket, id); groupService.DeleteAccountGroup(GetAdminTicket(), t_group.Id); }
public void RejectAccountGroupAccountInvitationTest() { // update the group to private WebGroupService.TransitAccountGroup t_group = EndPoint.GetAccountGroupById(GetAdminTicket(), _group_id); t_group.IsPrivate = true; EndPoint.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group); Console.WriteLine("Updated group to private: {0}", _group_id); // create an invitatoin for user WebGroupService.TransitAccountGroupAccountInvitation t_instance = new WebGroupService.TransitAccountGroupAccountInvitation(); t_instance.AccountGroupId = _group_id; t_instance.AccountId = _user.id; t_instance.RequesterId = GetAdminAccount().Id; t_instance.Message = GetNewString(); t_instance.Id = EndPoint.CreateOrUpdateAccountGroupAccountInvitation(GetAdminTicket(), t_instance); Console.WriteLine("Created invitation: {0}", t_instance.Id); // make sure the user isn't member of the group Assert.IsNull(EndPoint.GetAccountGroupAccountByAccountGroupId(GetAdminTicket(), _user.id, _group_id)); // get the pending group membership requests WebGroupService.TransitAccountGroupAccountRequest[] requests1 = EndPoint.GetAccountGroupAccountRequests( GetAdminTicket(), _group_id, null); Console.WriteLine("Pending requests: {0}", requests1.Length); // accept invitation EndPoint.RejectAccountGroupAccountInvitation(_user.ticket, t_instance.Id, GetNewString()); // make sure the invitation was deleted Assert.IsNull(EndPoint.GetAccountGroupAccountInvitationById(_user.ticket, t_instance.Id)); // this has not created a new request on the group, it should be = WebGroupService.TransitAccountGroupAccountRequest[] requests2 = EndPoint.GetAccountGroupAccountRequests( GetAdminTicket(), _group_id, null); Console.WriteLine("Pending requests: {0}", requests2.Length); Assert.AreEqual(requests1.Length, requests2.Length); }
public void GetAccountGroupAccountInvitationsByAccountIdTest() { // get the pending account's invitations WebGroupService.TransitAccountGroupAccountInvitation[] invitations1 = EndPoint.GetAccountGroupAccountInvitationsByAccountId( _user.ticket, _user.id, null); Assert.IsNotNull(invitations1); // update the group to private WebGroupService.TransitAccountGroup t_group = EndPoint.GetAccountGroupById(GetAdminTicket(), _group_id); t_group.IsPrivate = true; EndPoint.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group); Console.WriteLine("Updated group to private: {0}", _group_id); // create an invitatoin for user WebGroupService.TransitAccountGroupAccountInvitation t_instance = new WebGroupService.TransitAccountGroupAccountInvitation(); t_instance.AccountGroupId = _group_id; t_instance.AccountId = _user.id; t_instance.RequesterId = GetAdminAccount().Id; t_instance.Message = GetNewString(); t_instance.Id = EndPoint.CreateOrUpdateAccountGroupAccountInvitation(GetAdminTicket(), t_instance); Console.WriteLine("Created invitation: {0}", t_instance.Id); // make sure the user isn't member of the group Assert.IsNull(EndPoint.GetAccountGroupAccountByAccountGroupId(GetAdminTicket(), _user.id, _group_id)); // get the pending account's invitations WebGroupService.TransitAccountGroupAccountInvitation[] invitations2 = EndPoint.GetAccountGroupAccountInvitationsByAccountId( _user.ticket, _user.id, null); Assert.IsNotNull(invitations2); Assert.AreEqual(invitations1.Length + 1, invitations2.Length); Assert.IsTrue(new TransitServiceCollection <WebGroupService.TransitAccountGroupAccountInvitation>(invitations2).ContainsId( t_instance.Id)); }
public void AcceptAccountGroupAccountInvitationTest() { // login user string email = GetNewEmailAddress(); AccountTest _account = new AccountTest(); WebAccountService.TransitAccount t_user = _account.GetTransitInstance(); t_user.Id = _account.EndPoint.CreateAccount(string.Empty, email, t_user); Assert.AreNotEqual(0, t_user.Id); Console.WriteLine("Created account: {0}", t_user.Id); string userticket = _account.Login(email, t_user.Password); // join user to group WebGroupService.TransitAccountGroupAccount t_account = new WebGroupService.TransitAccountGroupAccount(); t_account.AccountGroupId = _group_id; t_account.AccountId = t_user.Id; t_account.IsAdministrator = false; t_account.Id = EndPoint.CreateOrUpdateAccountGroupAccount(userticket, t_account); Assert.AreNotEqual(0, t_account.Id); Console.WriteLine("Joined user: {0}", t_account.Id); // update the group to private WebGroupService.TransitAccountGroup t_group = EndPoint.GetAccountGroupById(GetAdminTicket(), _group_id); t_group.IsPrivate = true; EndPoint.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group); Console.WriteLine("Updated group to private: {0}", _group_id); // create an invitatoin for user WebGroupService.TransitAccountGroupAccountInvitation t_instance = new WebGroupService.TransitAccountGroupAccountInvitation(); t_instance.AccountGroupId = _group_id; t_instance.AccountId = _user.id; t_instance.RequesterId = t_account.AccountId; t_instance.Message = GetNewString(); t_instance.Id = EndPoint.CreateOrUpdateAccountGroupAccountInvitation(GetAdminTicket(), t_instance); Console.WriteLine("Created invitation: {0}", t_instance.Id); // make sure the user isn't member of the group Assert.IsNull(EndPoint.GetAccountGroupAccountByAccountGroupId(GetAdminTicket(), _user.id, _group_id)); // get the pending group membership requests WebGroupService.TransitAccountGroupAccountRequest[] requests1 = EndPoint.GetAccountGroupAccountRequests( GetAdminTicket(), _group_id, null); Console.WriteLine("Pending requests: {0}", requests1.Length); // accept invitation EndPoint.AcceptAccountGroupAccountInvitation(_user.ticket, t_instance.Id, GetNewString()); // this has created a new request on the group, it should be +1 WebGroupService.TransitAccountGroupAccountRequest[] requests2 = EndPoint.GetAccountGroupAccountRequests( GetAdminTicket(), _group_id, null); Console.WriteLine("Pending requests: {0}", requests2.Length); Assert.AreEqual(requests1.Length + 1, requests2.Length); // make sure there's an AccountId in the requests for the user WebGroupService.TransitAccountGroupAccountRequest request = null; Assert.IsTrue(new TransitServiceCollection <WebGroupService.TransitAccountGroupAccountRequest>(requests2).ContainsId( _user.id, "AccountId", out request)); Assert.IsNotNull(request); Console.WriteLine("New request: {0}", request.Id); // accept the request by admin EndPoint.AcceptAccountGroupAccountRequest(GetAdminTicket(), request.Id, GetNewString()); // make sure the invitation was deleted Assert.IsNull(EndPoint.GetAccountGroupAccountInvitationById(_user.ticket, t_instance.Id)); // make sure the request cannot be found any more WebGroupService.TransitAccountGroupAccountRequest[] requests3 = EndPoint.GetAccountGroupAccountRequests( GetAdminTicket(), _group_id, null); Console.WriteLine("Pending requests: {0}", requests3.Length); Assert.AreEqual(requests1.Length, requests3.Length); // make sure the user is member of the group WebGroupService.TransitAccountGroupAccount t_groupaccount = EndPoint.GetAccountGroupAccountByAccountGroupId( GetAdminTicket(), _user.id, _group_id); Assert.IsNotNull(t_groupaccount); Console.WriteLine("Account: {0}", t_groupaccount.Id); Assert.AreEqual(t_groupaccount.AccountId, _user.id); _account.Delete(GetAdminTicket(), t_user.Id); }