예제 #1
0
 def test_check_permission(self):
     authenticator.login("frank", "thetank")
     authorizor.add_permission("paint")
     authorizor.permit_user("paint", "frank")
     self.assertTrue(authorizor.check_permission("paint", "frank"))
     with self.assertRaises(PermissionError):
         authorizor.check_permission("doesntexist", "frank")
예제 #2
0
 def test_check_permission(self):
     authenticator.login("frank", "thetank")
     authorizor.add_permission("paint")
     authorizor.permit_user("paint", "frank")
     self.assertTrue(authorizor.check_permission("paint", "frank"))
     with self.assertRaises(PermissionError):
         authorizor.check_permission("doesntexist", "frank")
예제 #3
0
 def test_check_permission_not_permitted_user(self):
     authenticator.add_user('user_2', 'user2pwd')
     authenticator.login('user_2', 'user2pwd')
     with self.assertRaises(NotPermittedError):
         authorizor.check_permission('test', 'user_2')
예제 #4
0
 def test_check_permission_invalid_permission(self):
     with self.assertRaises(PermissionError):
         authorizor.check_permission('inv_perm', 'user')
예제 #5
0
 def test_check_permission_not_logged_in_user(self):
     with self.assertRaises(NotLoggedInError):
         authorizor.check_permission('test', 'inv_user')
예제 #6
0
 def test_exception_not_permitted(self):
     authenticator.login("frank", "thetank")
     authorizor.add_permission("paint")
     with self.assertRaises(NotPermittedError):
         authorizor.check_permission("paint", "frank")
예제 #7
0
 def test_exception_not_logged_in(self):
     authorizor.add_permission("paint")
     with self.assertRaises(NotLoggedInError):
         authorizor.check_permission("paint", "frank")
예제 #8
0
 def test_exception_not_permitted(self):
     authenticator.login("frank", "thetank")
     authorizor.add_permission("paint")
     with self.assertRaises(NotPermittedError):
         authorizor.check_permission("paint", "frank")
예제 #9
0
 def test_exception_not_logged_in(self):
     authorizor.add_permission("paint")
     with self.assertRaises(NotLoggedInError):
         authorizor.check_permission("paint", "frank")