コード例 #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")