331 req.form['__password'] = origcnx.password |
331 req.form['__password'] = origcnx.password |
332 self._test_auth_succeed(req, origcnx) |
332 self._test_auth_succeed(req, origcnx) |
333 self.assertRaises(AuthenticationError, self.publish, req, 'logout') |
333 self.assertRaises(AuthenticationError, self.publish, req, 'logout') |
334 self.assertEquals(len(self.open_sessions), 0) |
334 self.assertEquals(len(self.open_sessions), 0) |
335 |
335 |
|
336 def test_cookie_auth_no_anon_login_by_email(self): |
|
337 login = self.request().user.login |
|
338 address = login + u'@localhost' |
|
339 self.execute('INSERT EmailAddress X: X address %(address)s, U primary_email X ' |
|
340 'WHERE U login %(login)s', {'address': address, 'login': login}) |
|
341 self.commit() |
|
342 req, origcnx = self._init_auth('cookie') |
|
343 req.form['__login'] = address |
|
344 req.form['__password'] = origcnx.password |
|
345 self._test_auth_succeed(req, origcnx) |
|
346 self.assertRaises(AuthenticationError, self.publish, req, 'logout') |
|
347 self.assertEquals(len(self.open_sessions), 0) |
|
348 |
336 def _test_auth_anon(self, req): |
349 def _test_auth_anon(self, req): |
337 self.app.connect(req) |
350 self.app.connect(req) |
338 acnx = req.cnx |
351 acnx = req.cnx |
339 self.assertEquals(len(self.open_sessions), 1) |
352 self.assertEquals(len(self.open_sessions), 1) |
340 self.assertEquals(acnx.login, 'anon') |
353 self.assertEquals(acnx.login, 'anon') |
382 req.form['__password'] = origcnx.password |
395 req.form['__password'] = origcnx.password |
383 self._test_auth_succeed(req, origcnx) |
396 self._test_auth_succeed(req, origcnx) |
384 self.assertRaises(AuthenticationError, self.publish, req, 'logout') |
397 self.assertRaises(AuthenticationError, self.publish, req, 'logout') |
385 self.assertEquals(len(self.open_sessions), 0) |
398 self.assertEquals(len(self.open_sessions), 0) |
386 |
399 |
387 |
400 |
388 |
|
389 |
|
390 if __name__ == '__main__': |
401 if __name__ == '__main__': |
391 unittest_main() |
402 unittest_main() |