def testValidateRequestedAccess(self):
    access_manager = access_control.BasicAccessControlManager()
    access_manager.ValidateRequestedAccess("r", "aff4:/C.0000000000000001")

    with self.assertRaises(access_control.UnauthorizedAccess):
      access_manager.ValidateRequestedAccess("", "aff4:/C.0000000000000001")

    with self.assertRaises(access_control.UnauthorizedAccess):
      access_manager.ValidateRequestedAccess("q", "aff4:/C.0000000000000001")
Beispiel #2
0
    def testValidateToken(self):
        token = access_control.ACLToken(username="******", reason="For testing")
        access_manager = access_control.BasicAccessControlManager()
        access_manager.ValidateToken(token, "aff4:/C.0000000000000001")

        with self.assertRaises(access_control.UnauthorizedAccess):
            access_manager.ValidateToken(None, "aff4:/C.0000000000000001")

        token = access_control.ACLToken(reason="For testing")
        with self.assertRaises(access_control.UnauthorizedAccess):
            access_manager.ValidateToken(token, "aff4:/C.0000000000000001")