def test_create_err(self): self.log_user() username = '******' password = '' name = 'name' lastname = 'lastname' email = 'errmail.com' response = self.app.post(url('users'), {'username': username, 'password': password, 'name': name, 'active': False, 'lastname': lastname, 'email': email}) msg = validators.ValidUsername(False, {})._messages['system_invalid_username'] msg = h.html_escape(msg % {'username': '******'}) response.mustcontain("""<span class="error-message">%s</span>""" % msg) response.mustcontain("""<span class="error-message">Please enter a value</span>""") response.mustcontain("""<span class="error-message">An email address must contain a single @</span>""") def get_user(): Session().query(User).filter(User.username == username).one() self.assertRaises(NoResultFound, get_user), 'found user in database'
def test_forgot_password_wrong_mail(self): bad_email = '*****@*****.**' response = self.app.post( url(controller='login', action='password_reset'), { 'email': bad_email, }) msg = validators.ValidSystemEmail()._messages['non_existing_email'] msg = h.html_escape(msg % {'email': bad_email}) response.mustcontain()
def test_forgot_password_wrong_mail(self): bad_email = '*****@*****.**' response = self.app.post( url(controller='login', action='password_reset'), {'email': bad_email, } ) msg = validators.ValidSystemEmail()._messages['non_existing_email'] msg = h.html_escape(msg % {'email': bad_email}) response.mustcontain()
def test_register_err_same_username(self): uname = 'test_admin' response = self.app.post(url(controller='login', action='register'), {'username': uname, 'password': '******', 'password_confirmation': 'test12', 'email': '*****@*****.**', 'firstname': 'test', 'lastname': 'test'}) msg = validators.ValidUsername()._messages['username_exists'] msg = h.html_escape(msg % {'username': uname}) response.mustcontain(msg)
def test_register_err_case_sensitive(self): usr = '******' response = self.app.post(url(controller='login', action='register'), {'username': usr, 'password': '******', 'password_confirmation': 'test12', 'email': 'goodmailm', 'firstname': 'test', 'lastname': 'test'}) response.mustcontain('An email address must contain a single @') msg = validators.ValidUsername()._messages['username_exists'] msg = h.html_escape(msg % {'username': usr}) response.mustcontain(msg)
def test_register_err_same_username(self): uname = 'test_admin' response = self.app.post( url(controller='login', action='register'), { 'username': uname, 'password': '******', 'password_confirmation': 'test12', 'email': '*****@*****.**', 'firstname': 'test', 'lastname': 'test' }) msg = validators.ValidUsername()._messages['username_exists'] msg = h.html_escape(msg % {'username': uname}) response.mustcontain(msg)
def test_register_err_same_username(self): uname = base.TEST_USER_ADMIN_LOGIN response = self.app.post(base.url(controller='login', action='register'), {'username': uname, 'password': '******', 'password_confirmation': 'test12', 'email': '*****@*****.**', 'firstname': 'test', 'lastname': 'test', '_session_csrf_secret_token': self.session_csrf_secret_token()}) with test_context(self.app): msg = validators.ValidUsername()._messages['username_exists'] msg = h.html_escape(msg % {'username': uname}) response.mustcontain(msg)
def test_register_err_case_sensitive(self): usr = '******' response = self.app.post( url(controller='login', action='register'), { 'username': usr, 'password': '******', 'password_confirmation': 'test12', 'email': 'goodmailm', 'firstname': 'test', 'lastname': 'test' }) response.mustcontain('An email address must contain a single @') msg = validators.ValidUsername()._messages['username_exists'] msg = h.html_escape(msg % {'username': usr}) response.mustcontain(msg)
def test_register_err_case_sensitive(self): usr = base.TEST_USER_ADMIN_LOGIN.title() response = self.app.post(base.url(controller='login', action='register'), {'username': usr, 'password': '******', 'password_confirmation': 'test12', 'email': 'goodmailm', 'firstname': 'test', 'lastname': 'test', '_session_csrf_secret_token': self.session_csrf_secret_token()}) response.mustcontain('An email address must contain a single @') with test_context(self.app): msg = validators.ValidUsername()._messages['username_exists'] msg = h.html_escape(msg % {'username': usr}) response.mustcontain(msg)
def test_my_account_update_err(self): self.log_user('test_regular2', 'test12') new_email = 'newmail.pl' response = self.app.post(url('my_account'), params=dict( username='******', new_password='******', password_confirmation='test122', firstname='NewName', lastname='NewLastname', email=new_email,)) response.mustcontain('An email address must contain a single @') from kallithea.model import validators msg = validators.ValidUsername(edit=False, old_data={})\ ._messages['username_exists'] msg = h.html_escape(msg % {'username': '******'}) response.mustcontain(u"%s" % msg)
def test_my_account_update_err(self): self.log_user('test_regular2', 'test12') new_email = 'newmail.pl' response = self.app.post(url('my_account'), params=dict( username='******', new_password='******', password_confirmation='test122', firstname='NewName', lastname='NewLastname', email=new_email, )) response.mustcontain('An email address must contain a single @') from kallithea.model import validators msg = validators.ValidUsername(edit=False, old_data={})\ ._messages['username_exists'] msg = h.html_escape(msg % {'username': '******'}) response.mustcontain(u"%s" % msg)
def test_my_account_update_err(self): self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) new_email = 'newmail.pl' response = self.app.post(url('my_account'), params=dict( username=TEST_USER_ADMIN_LOGIN, new_password=TEST_USER_ADMIN_PASS, password_confirmation='test122', firstname=u'NewName', lastname=u'NewLastname', email=new_email, _authentication_token=self.authentication_token())) response.mustcontain('An email address must contain a single @') from kallithea.model import validators msg = validators.ValidUsername(edit=False, old_data={}) \ ._messages['username_exists'] msg = h.html_escape(msg % {'username': TEST_USER_ADMIN_LOGIN}) response.mustcontain(msg)
def test_my_account_update_err(self): self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) new_email = 'newmail.pl' response = self.app.post( url('my_account'), params=dict(username=TEST_USER_ADMIN_LOGIN, new_password=TEST_USER_ADMIN_PASS, password_confirmation='test122', firstname=u'NewName', lastname=u'NewLastname', email=new_email, _authentication_token=self.authentication_token())) response.mustcontain('An email address must contain a single @') from kallithea.model import validators with test_context(self.app): msg = validators.ValidUsername(edit=False, old_data={}) \ ._messages['username_exists'] msg = h.html_escape(msg % {'username': TEST_USER_ADMIN_LOGIN}) response.mustcontain(msg)