Esempio n. 1
0
        public void VerifyFailedEmailTest()
        {
            // create a user
            string email    = GetNewEmailAddress();
            string password = GetNewString();
            int    user_id  = CreateUser(email, password);

            Assert.IsTrue(user_id > 0);
            string ticket = Login(email, password);

            Assert.IsNotEmpty(ticket);
            // verify e-mail
            WebAccountService.TransitAccountEmailConfirmation[] confirmations = EndPoint.GetAccountEmailConfirmations(GetAdminTicket(), user_id, null);
            string verifiedemail = EndPoint.VerifyAccountEmail(confirmations[0].Id, confirmations[0].Code);

            Console.WriteLine("Verified e-mail: {0}", verifiedemail);
            Assert.AreEqual(verifiedemail, email);
            // fail e-mail
            int email_id = confirmations[0].AccountEmail.Id;

            Console.WriteLine("Email id: {0}", email_id);
            WebAccountService.TransitAccountEmail t_email_before = EndPoint.GetAccountEmailById(ticket, email_id);
            Assert.IsFalse(t_email_before.Failed);
            Assert.IsTrue(string.IsNullOrEmpty(t_email_before.LastError));
            t_email_before.Failed    = true;
            t_email_before.LastError = GetNewString();
            EndPoint.CreateOrUpdateAccountEmail(ticket, t_email_before);
            // verify that the e-mail was failed
            WebAccountService.TransitAccountEmail t_email_after = EndPoint.GetAccountEmailById(ticket, email_id);
            Console.WriteLine("Email failure: {0}", t_email_after.LastError);
            Assert.IsTrue(t_email_after.Failed);
            Assert.IsFalse(string.IsNullOrEmpty(t_email_after.LastError));
            Assert.AreEqual(t_email_after.LastError, t_email_before.LastError);
            // resend e-mail confirmation
            EndPoint.ConfirmAccountEmail(ticket, t_email_after.Id);
            // verify e-mail again, the same confirmation is going to be resent on a failed e-mail
            string verifiedemail_after = EndPoint.VerifyAccountEmail(confirmations[0].Id, confirmations[0].Code);

            Console.WriteLine("Verified e-mail: {0}", verifiedemail_after);
            Assert.AreEqual(verifiedemail_after, email);
            // verify that failure was cleared
            WebAccountService.TransitAccountEmail t_email_final = EndPoint.GetAccountEmailById(ticket, email_id);
            Assert.IsFalse(t_email_final.Failed);
            Assert.IsTrue(string.IsNullOrEmpty(t_email_final.LastError));
            // delete user
            DeleteUser(user_id);
        }
Esempio n. 2
0
        public void ConfirmAccountEmailTest()
        {
            // create a user
            string email    = GetNewEmailAddress();
            string password = GetNewString();
            int    user_id  = CreateUser(email, password);

            Assert.IsTrue(user_id > 0);
            string ticket = Login(email, password);

            Assert.IsNotEmpty(ticket);
            // get the e-mail that needs to be re-confirmed
            WebAccountService.TransitAccountEmail[] emails = EndPoint.GetAccountEmails(ticket, user_id, null);
            Console.WriteLine("Emails: {0}", emails.Length);
            Assert.AreEqual(1, emails.Length);
            Assert.AreEqual(emails[0].Address, email);
            // verify that there's one confirmation pending
            WebAccountService.TransitAccountEmailConfirmation[] confirmations1 = EndPoint.GetAccountEmailConfirmations(GetAdminTicket(), user_id, null);
            Console.WriteLine("Confirmations: {0}", confirmations1.Length);
            Assert.AreEqual(1, confirmations1.Length);
            Assert.AreEqual(confirmations1[0].AccountEmail.Address, email);
            // resend a confirmation
            EndPoint.ConfirmAccountEmail(ticket, emails[0].Id);
            // verify that there's still one confirmation pending
            WebAccountService.TransitAccountEmailConfirmation[] confirmations2 = EndPoint.GetAccountEmailConfirmations(GetAdminTicket(), user_id, null);
            Console.WriteLine("Confirmations: {0}", confirmations2.Length);
            Assert.AreEqual(1, confirmations2.Length);
            Assert.AreEqual(confirmations2[0].AccountEmail.Address, email);
            // add an e-mail
            WebAccountService.TransitAccountEmail t_email = new WebAccountService.TransitAccountEmail();
            t_email.AccountId = user_id;
            t_email.Address   = GetNewEmailAddress();
            t_email.Id        = EndPoint.CreateOrUpdateAccountEmail(ticket, t_email);
            // verify that there're two confirmations pending
            WebAccountService.TransitAccountEmailConfirmation[] confirmations3 = EndPoint.GetAccountEmailConfirmations(GetAdminTicket(), user_id, null);
            Console.WriteLine("Confirmations: {0}", confirmations3.Length);
            Assert.AreEqual(2, confirmations3.Length);
            // resend a confirmation
            EndPoint.ConfirmAccountEmail(ticket, emails[0].Id);
            // verify that there's still two confirmation pending
            WebAccountService.TransitAccountEmailConfirmation[] confirmations4 = EndPoint.GetAccountEmailConfirmations(GetAdminTicket(), user_id, null);
            Console.WriteLine("Confirmations: {0}", confirmations4.Length);
            Assert.AreEqual(2, confirmations4.Length);
            DeleteUser(user_id);
        }