Пример #1
0
 def test_check_authorization(self):
     logger = FakeLogger()
     environ = make_environ('gustavo',
                            permissions=['watch-tv', 'party', 'eat'])
     environ['repoze.who.logger'] = logger
     p = has_any_permission('party', 'scream')
     check_authorization(p, environ)
     info = logger.messages['info']
     assert "Authorization granted" == info[0]
Пример #2
0
 def test_check_authorization(self):
     logger = FakeLogger()
     environ = make_environ('gustavo', permissions=['watch-tv', 'party',
                                                    'eat'])
     environ['repoze.who.logger'] = logger
     p = has_any_permission('party', 'scream')
     check_authorization(p, environ)
     info = logger.messages['info']
     assert "Authorization granted" == info[0]
Пример #3
0
 def test_check_authorization_granted_with_predicates_booleanized(self):
     """Authorization must be granted as usual."""
     logger = FakeLogger()
     environ = make_environ('gustavo',
                            permissions=['watch-tv', 'party', 'eat'])
     environ['repoze.who.logger'] = logger
     p = self._get_booleanized_has_permission('party', environ)
     assert bool(p), "Predicate isn't booleanized"
     check_authorization(p, environ)
     info = logger.messages['info']
     assert "Authorization granted" == info[0]
Пример #4
0
 def test_check_authorization_granted_with_predicates_booleanized(self):
     """Authorization must be granted as usual."""
     logger = FakeLogger()
     environ = make_environ('gustavo', permissions=['watch-tv', 'party',
                                                    'eat'])
     environ['repoze.who.logger'] = logger
     p = self._get_booleanized_has_permission('party', environ)
     assert bool(p), "Predicate isn't booleanized"
     check_authorization(p, environ)
     info = logger.messages['info']
     assert "Authorization granted" == info[0]
Пример #5
0
 def test_check_authorization_denies_with_predicates_booleanized(self):
     """Authorization must be denied as usual."""
     logger = FakeLogger()
     environ = make_environ('gustavo')
     environ['repoze.who.logger'] = logger
     p = self._get_booleanized_has_permission('party', environ)
     assert not bool(p), "Predicate isn't booleanized"
     try:
         check_authorization(p, environ)
         self.fail('Authorization must have been rejected')
     except NotAuthorizedError, e:
         error_msg = 'The user must have the "party" permission'
         self.assertEqual(str(e), error_msg)
         # Testing the logs:
         info = logger.messages['info']
         assert "Authorization denied: %s" % error_msg == info[0]
Пример #6
0
 def test_check_authorization_denies_with_predicates_booleanized(self):
     """Authorization must be denied as usual."""
     logger = FakeLogger()
     environ = make_environ('gustavo')
     environ['repoze.who.logger'] = logger
     p = self._get_booleanized_has_permission('party', environ)
     assert not bool(p), "Predicate isn't booleanized"
     try:
         check_authorization(p, environ)
         self.fail('Authorization must have been rejected')
     except NotAuthorizedError, e:
         error_msg = 'The user must have the "party" permission'
         self.assertEqual(str(e), error_msg)
         # Testing the logs:
         info = logger.messages['info']
         assert "Authorization denied: %s" % error_msg == info[0]