def run(self): self.ensure_logged_off() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_email1 = random_crap.randomEmail() inp_email2 = random_crap.randomEmail() inp_pass1 = random_crap.random_text(10) inp_pass2 = random_crap.random_text(10) inp_name1 = u"Вася " + random_crap.random_text(6) inp_name2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inp_login, email=inp_email1, password=inp_pass1, name=inp_name1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inp_login, email=inp_email2, password=inp_pass2, name=inp_name2, random=False, validate=False, ) self.assertBodyTextNotPresent(u"Пользователь '" + inp_login + u"' успешно создан") self.performLogout() self.logAdd("logging as created first user. ") if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogout() logging.info("try logging as created second user.") if self.perform_login(u2.login, u2.password): self.failTest( "I am able to login as 'second' user with duplicate login and new password. " )
def run(self): self.ensure_logged_off() # TODO(mvel): Add contest manager role self.perform_login_as_admin() self.gotoPage("/ctx") self.gotoUrlByLinkText(u"Добавить работу") inp_fio = u"Участник_Олимпиады_" + random_crap.random_text(6) inp_email = random_crap.randomEmail() inp_comment = random_crap.random_text(6) work_file = os.getcwd() + "/contest-work-sample.png" with open(work_file, 'w') as f: f.write('q' * 1024) inp_fio = self.fillElementByName("name", inp_fio) _ = self.fillElementByName("mail", inp_email) _ = self.fillElementByName("work", work_file, clear=False) # WTF??? Why 'status', not 'comment'? _ = self.fillElementByName("status", inp_comment) self.clickElementByName("ctx_add_or_edit_form_contestants_x") # check that work appears in the list self.gotoUrlByLinkText(u"Работы") self.assertBodyTextPresent(inp_fio)
def run(self): self.ensure_logged_off() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_email1 = random_crap.randomEmail() inp_email2 = random_crap.randomEmail() inp_pass1 = random_crap.random_text(10) inp_pass2 = random_crap.random_text(10) inp_name1 = u"Вася " + random_crap.random_text(6) inp_name2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inp_login, email=inp_email1, password=inp_pass1, name=inp_name1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inp_login, email=inp_email2, password=inp_pass2, name=inp_name2, random=False, validate=False, ) self.assertBodyTextNotPresent(u"Пользователь '" + inp_login + u"' успешно создан") self.performLogout() self.logAdd("logging as created first user. ") if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogout() logging.info("try logging as created second user.") if self.perform_login(u2.login, u2.password): self.failTest("I am able to login as 'second' user with duplicate login and new password. ")
def run(self): self.ensure_logged_off() inp_login1 = "dup_email_" + random_crap.random_text(8) inp_login2 = "dup_email_" + random_crap.random_text(8) inp_email = random_crap.randomEmail() inp_pass1 = random_crap.random_text(10) inp_pass2 = random_crap.random_text(10) inp_name1 = u"Вася " + random_crap.random_text(6) inp_name2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inp_login1, email=inp_email, password=inp_pass1, name=inp_name1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inp_login2, email=inp_email, password=inp_pass2, name=inp_name2, random=False, validate=False, ) self.assertBodyTextNotPresent( u"Пользователь '{}' успешно создан".format(u2.login), "We should get error about duplicate e-mails. ", ) self.performLogout() print "logging as first created user. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created first user. ") self.performLogout() print "try logging as second created user. " if self.perform_login(u2.login, u2.password): self.failTest("I was able to login as second user with duplicate e-mail. ")
def run(self): self.ensure_logged_off() self.goto_root() inp_email = self.m_conf.getValidEmail(1) self.removePreviousUsersWithTestEmail(inp_email) # create new user with ruined memory inp_login = "******" + random_crap.random_text(6) inp_pass = random_crap.random_text(10) inp_name = u"Ruined_Memory_" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, email=inp_email, password=inp_pass, name=inp_name, random=False, ) print "logging as created user. " if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogoutFromSite() # we navigate to root page, and see auth panel! self.logAdd("login again and press 'forgot password' button ") self.gotoAuthLink() self.fillElementById("reset-email-input", u.email) self.fillElementById("question-input", self.m_conf.getForgottenPasswordCaptcha()) self.clickElementById("reset_password-submit") if self.perform_login(u.login, u.password): self.failTest("Password was not reset. Old password works fine. ") # set random email to user to avoid problems with duplicate email (may occur only if test fails) self.setUserEmailByAdmin(u.login, random_crap.randomEmail())
def run(self): self.ensure_logged_off() #positive cases inp_login = "******" + ".user." u = user.User(self) u.create_new_user( login=inp_login, random=True, ) logging.info("Created a new user: "******".user" inp_email = random_crap.randomEmail() inp_name = random_crap.random_text(8) inp_pass = random_crap.random_text(8) u.create_new_user( login=inp_login, email=inp_email, password=inp_pass, name=inp_name, random=False, ) logging.info("Created a new user: "******"user." u.create_new_user( login=inp_login, random=True, ) logging.info("Created a new user: "******"Reached negative cases") inp_login = "******" u.create_new_user( login=inp_login, random=True, validate=False, ) self.assertBodyTextPresent(u"Имя пользователя должно начинаться с буквы или цифры") logging.info("Failed to create a new user: "******"@user" u.create_new_user( login=inp_login, random=True, validate=False, ) self.assertBodyTextPresent(u"Имя пользователя должно начинаться с буквы или цифры") logging.info("Failed to create a new user: "******"../usr/login" inp_email = random_crap.randomEmail() inp_name = random_crap.random_text(8) inp_pass = random_crap.random_text(8) u.create_new_user( login=inp_login, email=inp_email, password=inp_pass, name=inp_name, random=False, validate=False, ) self.assertBodyTextPresent(u"Имя пользователя должно начинаться с буквы или цифры") logging.info("Failed to create a new user: " + u.name) self.performLogout()
def run(self): self.ensure_logged_off() self.goto_root() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_name = u"Вася Пупкин" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) logging.info("logging as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogoutFromSite() # test wrong auth logging.info("logging in as created user with incorrect password ") if self.perform_login(u.login, "wrong_pass" + u.password): self.failTest("I'm able to login with incorrect password. Auth is broken. ") # and now, test bug with remaining cookies: # we navigate to root page, and see auth panel! logging.info("logging in again as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login again as newly created user. ") self.gotoCabinet() # let's try to change password. self.gotoUrlByLinkText(u"Сменить пароль") new_pass = u.password + "_new" self.fillElementById("old_passwd-input", u.password) new_pass1 = self.fillElementById("new_passwd-input", new_pass) new_pass2 = self.fillElementById("new_passwd_confirm-input", new_pass) if new_pass1 != new_pass2: raise RuntimeError("Unpredicted input behavior on password change") new_pass = new_pass1 self.clickElementByName("change_my_password") self.assertBodyTextPresent(u"Пароль успешно изменён") self.performLogoutFromAdminPanel() print "logging again as created user with new password" if not self.perform_login(u.login, new_pass): self.failTest("Cannot login again as newly created user with changed password. ") # logout self self.performLogoutFromSite() # and now let's edit user profile. print "now let's edit profile. Logging 3-rd time with new password" if not self.perform_login(u.login, new_pass): self.failTest("Cannot login again for profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login # TODO: BUG, make separate links self.gotoUrlByPartialLinkText(u.login) self.assertBodyTextPresent(self.getWelcomeMessage(u.login)) name_ele = "name-input" email_ele = "email-input" currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, u.name, "Display name in user profile does not match name entered on user creation. " ) currentEMail = self.getElementValueById(email_ele) self.assert_equal( currentEMail, u.email, "User e-mail in user profile does not match e-mail entered on user creation. " ) newName = u"Петя Иванов" + random_crap.random_text(6) newEMail = random_crap.randomEmail() newName = self.fillElementById(name_ele, newName) print "New user display name is ", newName newEMail = self.fillElementById(email_ele, newEMail) print "New user e-mail is ", newEMail self.clickElementById("update_me-submit") self.performLogoutFromAdminPanel() print "now let's login again and see updated profile." if not self.perform_login(u.login, new_pass): self.failTest("Cannot login after profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login self.gotoUrlByLinkText(u.login) self.assertBodyTextPresent(u"Привет, " + u.login) currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, newName, "Display name in user profile does not match changed user name. " ) currentEMail = self.getElementValueById(email_ele) self.assert_equal(currentEMail, newEMail, "User e-mail in user profile does not match changed user e-mail. ")
def run(self): self.ensure_logged_off() self.goto_root() # first, login as admin inp_login = "******" + random_crap.random_text(8) inp_name = u"Вася Пупкин" + random_crap.random_text(6) u = user.User(self) u.create_new_user( login=inp_login, name=inp_name, random=True, ) logging.info("logging as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login as newly created user. ") # logout self self.performLogoutFromSite() # test wrong auth logging.info("logging in as created user with incorrect password ") if self.perform_login(u.login, "wrong_pass" + u.password): self.failTest( "I'm able to login with incorrect password. Auth is broken. ") # and now, test bug with remaining cookies: # we navigate to root page, and see auth panel! logging.info("logging in again as created user. ") if not self.perform_login(u.login, u.password): self.failTest("Cannot login again as newly created user. ") self.gotoCabinet() # let's try to change password. self.gotoUrlByLinkText(u"Сменить пароль") new_pass = u.password + "_new" self.fillElementById("old_passwd-input", u.password) new_pass1 = self.fillElementById("new_passwd-input", new_pass) new_pass2 = self.fillElementById("new_passwd_confirm-input", new_pass) if new_pass1 != new_pass2: raise RuntimeError("Unpredicted input behavior on password change") new_pass = new_pass1 self.clickElementByName("change_my_password") self.assertBodyTextPresent(u"Пароль успешно изменён") self.performLogoutFromAdminPanel() print "logging again as created user with new password" if not self.perform_login(u.login, new_pass): self.failTest( "Cannot login again as newly created user with changed password. " ) # logout self self.performLogoutFromSite() # and now let's edit user profile. print "now let's edit profile. Logging 3-rd time with new password" if not self.perform_login(u.login, new_pass): self.failTest("Cannot login again for profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login # TODO: BUG, make separate links self.gotoUrlByPartialLinkText(u.login) self.assertBodyTextPresent(self.getWelcomeMessage(u.login)) name_ele = "name-input" email_ele = "email-input" currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, u.name, "Display name in user profile does not match name entered on user creation. " ) currentEMail = self.getElementValueById(email_ele) self.assert_equal( currentEMail, u.email, "User e-mail in user profile does not match e-mail entered on user creation. " ) newName = u"Петя Иванов" + random_crap.random_text(6) newEMail = random_crap.randomEmail() newName = self.fillElementById(name_ele, newName) print "New user display name is ", newName newEMail = self.fillElementById(email_ele, newEMail) print "New user e-mail is ", newEMail self.clickElementById("update_me-submit") self.performLogoutFromAdminPanel() print "now let's login again and see updated profile." if not self.perform_login(u.login, new_pass): self.failTest("Cannot login after profile info change. ") self.gotoCabinet() # navigate to user profile which is just user login self.gotoUrlByLinkText(u.login) self.assertBodyTextPresent(u"Привет, " + u.login) currentDisplayName = self.getElementValueById(name_ele) self.assert_equal( currentDisplayName, newName, "Display name in user profile does not match changed user name. ") currentEMail = self.getElementValueById(email_ele) self.assert_equal( currentEMail, newEMail, "User e-mail in user profile does not match changed user e-mail. ")
def run(self): self.ensure_logged_off() inpLogin1 = "cab_email_" + random_crap.random_text(6) inpLogin2 = "cab_email_" + random_crap.random_text(6) inpEMail1 = random_crap.randomEmail() inpEMail2 = random_crap.randomEmail() inpPass1 = random_crap.random_text(10) inpPass2 = random_crap.random_text(10) inpName1 = u"Вася " + random_crap.random_text(6) inpName2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inpLogin1, email=inpEMail1, password=inpPass1, name=inpName1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inpLogin2, email=inpEMail2, password=inpPass2, name=inpName2, random=False, ) print "logging as first created user. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created first user. ") self.gotoCabinet() print "test good email" newGoodEMail = self.m_conf.getValidEmail(2) self.fillElementById("email-input", newGoodEMail) self.clickElementById("update_me-submit") badMailMsg = u"пользователь с такой почтой" dataUpdatedMsg = u"Данные обновлены успешно" self.assertBodyTextNotPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextPresent(dataUpdatedMsg) print "Ok. Please check your mailbox for notification. " print "test another good random email" newGoodEMail = random_crap.randomEmail() newGoodEMail = self.fillElementById("email-input", newGoodEMail) self.clickElementById("update_me-submit") self.assertBodyTextNotPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextPresent(dataUpdatedMsg) print "And now test bad e-mail. " newBadEMail = u2.email self.fillElementById("email-input", newBadEMail) self.clickElementById("update_me-submit") self.assertBodyTextPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextNotPresent(dataUpdatedMsg) self.performLogoutFromAdminPanel() print "logging as first created user again. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login again as newly created first user. ") self.gotoCabinet() self.assertElementValueById("email-input", newGoodEMail, "Email should remain unchanged after 1st change") self.performLogoutFromAdminPanel() print "logging as second created user. " if not self.perform_login(u2.login, u2.password): self.failTest("I was not able to login as second user. ")
def run(self): self.ensure_logged_off() inpLogin1 = "cab_email_" + random_crap.random_text(6) inpLogin2 = "cab_email_" + random_crap.random_text(6) inpEMail1 = random_crap.randomEmail() inpEMail2 = random_crap.randomEmail() inpPass1 = random_crap.random_text(10) inpPass2 = random_crap.random_text(10) inpName1 = u"Вася " + random_crap.random_text(6) inpName2 = u"Петя " + random_crap.random_text(6) u1 = user.User(self) u1.create_new_user( login=inpLogin1, email=inpEMail1, password=inpPass1, name=inpName1, random=False, ) u2 = user.User(self) u2.create_new_user( login=inpLogin2, email=inpEMail2, password=inpPass2, name=inpName2, random=False, ) print "logging as first created user. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login as newly created first user. ") self.gotoCabinet() print "test good email" newGoodEMail = self.m_conf.getValidEmail(2) self.fillElementById("email-input", newGoodEMail) self.clickElementById("update_me-submit") badMailMsg = u"пользователь с такой почтой" dataUpdatedMsg = u"Данные обновлены успешно" self.assertBodyTextNotPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextPresent(dataUpdatedMsg) print "Ok. Please check your mailbox for notification. " print "test another good random email" newGoodEMail = random_crap.randomEmail() newGoodEMail = self.fillElementById("email-input", newGoodEMail) self.clickElementById("update_me-submit") self.assertBodyTextNotPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextPresent(dataUpdatedMsg) print "And now test bad e-mail. " newBadEMail = u2.email self.fillElementById("email-input", newBadEMail) self.clickElementById("update_me-submit") self.assertBodyTextPresent(badMailMsg) self.assertBodyTextNotPresent("exception") self.assertBodyTextNotPresent(dataUpdatedMsg) self.performLogoutFromAdminPanel() print "logging as first created user again. " if not self.perform_login(u1.login, u1.password): self.failTest("Cannot login again as newly created first user. ") self.gotoCabinet() self.assertElementValueById( "email-input", newGoodEMail, "Email should remain unchanged after 1st change") self.performLogoutFromAdminPanel() print "logging as second created user. " if not self.perform_login(u2.login, u2.password): self.failTest("I was not able to login as second user. ")
def create_new_user( self, login=str(), email=str(), password=str(), name=str(), random=False, validate=True, manager_rights=False, login_as_admin=True, logout_admin=True, ): if random: login += "_" + rc.random_text(6) email += "_" + rc.randomEmail() password += "_" + rc.random_text(6) name += "_" + rc.random_text(6) logging.info( "createNewUser(login: '******', email: '%s', password: '******', name: '%s')", login, email, password, name ) if login_as_admin: self.xtest.perform_login_as_admin() self.xtest.gotoAdminPanel() self.xtest.gotoUserList() self.xtest.gotoUrlByLinkText(["Create user", u"Создать пользователя"]) inp_login = self.xtest.fillElementById("login-input", login) logging.info("login = '******'") if inp_login == "": raise RuntimeError("Filled login value is empty!") inpEMail = self.xtest.fillElementById("email-input", email) inpPass1 = self.xtest.fillElementById("password-input", password) logging.info("original pass: '******'".format(password)) inpPass2 = self.xtest.fillElementById("password_confirm-input", password) if inpPass1 != inpPass2: raise RuntimeError("Unpredicted input behavior on password entering") inpPass = inpPass1 logging.info("actual pass: '******'") inpName = self.xtest.fillElementById("name-input", name) # set notify checkbox. # self.clickElementById("notify_user-checkbox") # send form if manager_rights: logging.info("Setting manager rights for user. ") # set manager access level self.xtest.clickElementById("group_ank-checkbox") self.xtest.clickElementByName("create_user") self.login = inp_login self.email = inpEMail self.name = inpName self.password = inpPass if not validate: logging.info("not validating created user, just click create button and shut up. ") return inp_login, inpEMail, inpPass, inpName logging.info("user created, going to user list again to refresh. ") self.xtest.assertBodyTextPresent(u"Пользователь '" + inp_login + u"' успешно создан") # refresh user list (re-navigate to user list) self.xtest.gotoUserList() # enter user profile logging.info("entering user profile. ") profileLink = inp_login # TODO, SITE BUG: make two separate links self.xtest.gotoUrlByPartialLinkText(profileLink) self.xtest.assertBodyTextPresent(u"Учётные данные") self.xtest.assertBodyTextPresent(u"Привилегии") # temporary check method # test user login self.xtest.assertTextPresent("//div[@class='user-ops']", inp_login) # test user creator (root) self.xtest.assertTextPresent("//div[@class='user-ops']", self.xtest.m_conf.get_admin_login()) self.xtest.assertElementValueById("name-input", inpName) self.xtest.assertElementValueById("email-input", inpEMail) # logoff root if logout_admin: self.xtest.performLogout() return inp_login, inpEMail, inpPass, inpName