def do_off_chain_transactor_batch_signer(): policy = make_policy( "policy1", ["PERMIT_KEY " + testPermissionVerifier.public_key]) testPermissionVerifier.permissions["transactor.batch_signer"] = policy batch = testPermissionVerifier._create_batches(1, 1)[0] allowed = testPermissionVerifier.permission_verifier.check_off_chain_batch_roles( batch) # assert allowed == True policy = make_policy("policy1", ["PERMIT_KEY other"]) testPermissionVerifier.permissions["transactor.batch_signer"] = policy batch = testPermissionVerifier._create_batches(1, 1)[0] allowed = testPermissionVerifier.permission_verifier.check_off_chain_batch_roles( batch)
def test_off_chain_transactor(self): """ Test that role:"transactor" is checked properly if in permissions. 1. Set policy to permit signing key. Batch should be allowed. 2. Set policy to permit some other key. Batch should be rejected. """ policy = make_policy("policy1", ["PERMIT_KEY " + self.public_key]) self.permissions["transactor"] = policy batch = self._create_batches(1, 1)[0] allowed = self.permission_verifier.check_off_chain_batch_roles(batch) self.assertTrue(allowed) policy = make_policy("policy1", ["PERMIT_KEY other"]) self.permissions["transactor"] = policy batch = self._create_batches(1, 1)[0] allowed = self.permission_verifier.check_off_chain_batch_roles(batch) self.assertFalse(allowed)
def test_off_chain_transactor_transaction_signer_family(): """ Test that role:"transactor.transaction_signer.intkey" is checked properly if in permissions. 1. Set policy to permit signing key. Batch should be allowed. 2. Set policy to permit some other key. Batch should be rejected. """ testPermissionVerifier = TestPermissionVerifier() policy = make_policy( "policy1", ["PERMIT_KEY " + testPermissionVerifier.public_key]) testPermissionVerifier.permissions["transactor.transaction_signer.intkey"] = policy batch = testPermissionVerifier._create_batches(1, 1)[0] allowed = testPermissionVerifier.permission_verifier.check_off_chain_batch_roles( batch) policy = make_policy("policy1", ["PERMIT_KEY other"]) testPermissionVerifier.permissions["transactor.transaction_signer.intkey"] = policy batch = testPermissionVerifier._create_batches(1, 1)[0] allowed = testPermissionVerifier.permission_verifier.check_off_chain_batch_roles( batch)