Ejemplo n.º 1
0
 def test_exception_permission_error(self):
     authorizor.add_permission("paint")
     with self.assertRaises(PermissionError):
         authorizor.add_permission("paint")
     authenticator.login("frank", "thetank")
     with self.assertRaises(PermissionError):
         authorizor.permit_user("doesntexist", "frank")
Ejemplo n.º 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")
Ejemplo n.º 3
0
 def test_exception_permission_error(self):
     authorizor.add_permission("paint")
     with self.assertRaises(PermissionError):
         authorizor.add_permission("paint")
     authenticator.login("frank", "thetank")
     with self.assertRaises(PermissionError):
         authorizor.permit_user("doesntexist", "frank")
Ejemplo n.º 4
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")
Ejemplo n.º 5
0
 def test_permit_user_with_invalid_username(self):
     with self.assertRaises(InvalidUsername):
         authorizor.permit_user('test', 'inv_user')
Ejemplo n.º 6
0
 def test_permit_user_invalid_permission(self):
     with self.assertRaises(PermissionError):
         authorizor.permit_user('inv_perm', 'user')
Ejemplo n.º 7
0
 def test_exception_invalid_username(self):
     with self.assertRaises(InvalidUsername):
         authenticator.login("tom", "")
     authorizor.add_permission("paint")
     with self.assertRaises(InvalidUsername):
         authorizor.permit_user("paint", "fran")
Ejemplo n.º 8
0
 def test_exception_invalid_username(self):
     with self.assertRaises(InvalidUsername):
         authenticator.login("tom", "")
     authorizor.add_permission("paint")
     with self.assertRaises(InvalidUsername):
         authorizor.permit_user("paint", "fran")