def test_check(self): check = BasicCheck(self.env) req = self.req # Inspector doesn't provide additional fields. field_res = check.render_registration_fields(req, {}) self.assertEqual(len(field_res), 2) self.assertEqual((Markup(field_res[0]), field_res[1]), (Markup(''), {})) # 1st attempt: No input. self.assertRaises(RegistrationError, check.validate_registration, req) # 2nd attempt: Illegal character. req.args['username'] = '******' self.assertRaises(RegistrationError, check.validate_registration, req) # 3rd attempt: All upper-case word. req.args['username'] = '******' self.assertRaises(RegistrationError, check.validate_registration, req) # 4th attempt: Reserved word. req.args['username'] = '******' self.assertRaises(RegistrationError, check.validate_registration, req) # 5th attempt: Existing user. req.args['username'] = '******' self.assertRaises(RegistrationError, check.validate_registration, req) # 6th attempt: Valid username, but no password. req.args['username'] = '******' self.assertRaises(RegistrationError, check.validate_registration, req) # 7th attempt: Valid username, no matching passwords. req.args['password'] = '******' self.assertRaises(RegistrationError, check.validate_registration, req) # 8th attempt: Finally some valid input. req.args['password_confirm'] = 'password' self.assertEqual(check.validate_registration(req), None)
def setUp(self): _BaseTestCase.setUp(self) self.cfg_panel_template = 'admin_accountsconfig.html' self.env.config.set('account-manager', 'password_store', 'SessionStore') self.admin = ConfigurationAdminPanel(self.env) self.bad_check = BadCheck(self.env) self.basic_check = BasicCheck(self.env) self.dummy_check = DummyCheck(self.env) self.store = SessionStore(self.env)
def setUp(self): _BaseTestCase.setUp(self) self.env = EnvironmentStub( enable=['trac.*', 'acct_mgr.api.*', 'acct_mgr.register.*']) self.env.path = tempfile.mkdtemp() self.reg_template = 'register.html' self.req.method = 'POST' self.acctmgr = AccountManager(self.env) self.check = BasicCheck(self.env) self.rmod = RegistrationModule(self.env)
def setUp(self): _BaseTestCase.setUp(self) self.env = EnvironmentStub(enable=[ 'trac.*', 'acct_mgr.api.*', 'acct_mgr.db.*', 'acct_mgr.register.*', 'acct_mgr.pwhash.HtDigestHashMethod' ]) self.env.path = tempfile.mkdtemp() self.reg_template = 'register.html' self.req.method = 'POST' self.env.config.set('account-manager', 'password_store', 'SessionStore') self.acctmgr = AccountManager(self.env) self.check = BasicCheck(self.env) self.rmod = RegistrationModule(self.env) self.store = SessionStore(self.env)