def test_dynamic_validation_without_permission( taa_request, txn_author_agreement_handler: TxnAuthorAgreementHandler, creator, set_aml): add_to_idr(txn_author_agreement_handler.database_manager.idr_cache, creator, STEWARD) with pytest.raises(UnauthorizedClientRequest, match="Not enough TRUSTEE signatures"): txn_author_agreement_handler.dynamic_validation(taa_request, 0)
def test_dynamic_validation(taa_request, txn_author_agreement_handler: TxnAuthorAgreementHandler, creator, set_aml): txn_author_agreement_handler.write_req_validator.validate = get_exception(False) add_to_idr(txn_author_agreement_handler.database_manager.idr_cache, creator, STEWARD) txn_author_agreement_handler.dynamic_validation(taa_request) txn_author_agreement_handler.write_req_validator.validate = get_exception(True) with pytest.raises(UnauthorizedClientRequest): txn_author_agreement_handler.dynamic_validation(taa_request)
def txn_author_agreement_handler(db_manager): f = FakeSomething() f.validate = lambda request, action_list: True handler = TxnAuthorAgreementHandler(db_manager, FakeSomething(), f) state = State() state.txn_list = {} state.get = lambda key, isCommitted=False: state.txn_list.get(key, None) state.set = lambda key, value, isCommitted=False: state.txn_list.update({key: value}) db_manager.register_new_database(handler.ledger_id, FakeSomething(), state) return handler
def _register_config_req_handlers(self): # Read handlers get_auth_rule_handler = GetAuthRuleHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) # Write handlers auth_rule_handler = AuthRuleHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) auth_rule_handler_1_9_1 = AuthRuleHandler191(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) auth_rules_handler = AuthRulesHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) pool_config_handler = PoolConfigHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator, pool_config=self.node.poolCfg) pool_upgrade_handler = PoolUpgradeHandler(database_manager=self.node.db_manager, upgrader=self.node.upgrader, write_req_validator=self.node.write_req_validator, pool_manager=self.node.poolManager) taa_aml_handler = TxnAuthorAgreementAmlHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) taa_handler = TxnAuthorAgreementHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) taa_handler_v1 = TxnAuthorAgreementHandlerV1(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) taa_disable_handler = TxnAuthorAgreementDisableHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) get_taa_aml_handler = GetTxnAuthorAgreementAmlHandler(database_manager=self.node.db_manager) get_taa_handler = GetTxnAuthorAgreementHandler(database_manager=self.node.db_manager) node_upgrade_handler = NodeUpgradeHandler(database_manager=self.node.db_manager) ledgers_freeze_handler = LedgersFreezeHandler(database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) get_frozen_ledgers_handler = GetFrozenLedgersHandler(database_manager=self.node.db_manager) # Register write handlers self.node.write_manager.register_req_handler(auth_rule_handler) self.node.write_manager.register_req_handler(auth_rules_handler) self.node.write_manager.register_req_handler(pool_config_handler) self.node.write_manager.register_req_handler(pool_upgrade_handler) self.node.write_manager.register_req_handler(taa_aml_handler) self.node.write_manager.register_req_handler(taa_handler) self.node.write_manager.register_req_handler(taa_disable_handler) self.node.write_manager.register_req_handler(node_upgrade_handler) self.node.write_manager.register_req_handler(ledgers_freeze_handler) # Register read handlers self.node.read_manager.register_req_handler(get_auth_rule_handler) self.node.read_manager.register_req_handler(get_taa_aml_handler) self.node.read_manager.register_req_handler(get_taa_handler) self.node.read_manager.register_req_handler(get_frozen_ledgers_handler) # Register write handlers for a version self.node.write_manager.register_req_handler_with_version(auth_rule_handler_1_9_1, version="1.9.1") self.node.write_manager.register_req_handler_with_version(taa_handler_v1, version="1")
def register_config_req_handlers(self): # Read handlers get_auth_rule_handler = GetAuthRuleHandler( database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) # Write handlers auth_rule_handler = AuthRuleHandler( database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) auth_rules_handler = AuthRulesHandler( database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator) pool_config_handler = PoolConfigHandler( database_manager=self.node.db_manager, write_req_validator=self.node.write_req_validator, pool_config=self.node.poolCfg) pool_upgrade_handler = PoolUpgradeHandler( database_manager=self.node.db_manager, upgrader=self.node.upgrader, write_req_validator=self.node.write_req_validator, pool_manager=self.node.poolManager) taa_aml_handler = TxnAuthorAgreementAmlHandler( database_manager=self.node.db_manager, bls_crypto_verifier=self.node.bls_bft.bls_crypto_verifier, write_req_validator=self.node.write_req_validator) taa_handler = TxnAuthorAgreementHandler( database_manager=self.node.db_manager, bls_crypto_verifier=self.node.bls_bft.bls_crypto_verifier, write_req_validator=self.node.write_req_validator) get_taa_aml_handler = GetTxnAuthorAgreementAmlHandler( database_manager=self.node.db_manager) get_taa_handler = GetTxnAuthorAgreementHandler( database_manager=self.node.db_manager) node_upgrade_handler = NodeUpgradeHandler( database_manager=self.node.db_manager) # Register write handlers self.node.write_manager.register_req_handler(auth_rule_handler) self.node.write_manager.register_req_handler(auth_rules_handler) self.node.write_manager.register_req_handler(pool_config_handler) self.node.write_manager.register_req_handler(pool_upgrade_handler) self.node.write_manager.register_req_handler(taa_aml_handler) self.node.write_manager.register_req_handler(taa_handler) self.node.write_manager.register_req_handler(node_upgrade_handler) # Register read handlers self.node.read_manager.register_req_handler(get_auth_rule_handler) self.node.read_manager.register_req_handler(get_taa_aml_handler) self.node.read_manager.register_req_handler(get_taa_handler)
def test_dynamic_validation( taa_request, txn_author_agreement_handler: TxnAuthorAgreementHandler, creator, set_aml): add_to_idr(txn_author_agreement_handler.database_manager.idr_cache, creator, TRUSTEE) txn_author_agreement_handler.dynamic_validation(taa_request, 0)
def txn_author_agreement_handler(db_manager, write_auth_req_validator): handler = TxnAuthorAgreementHandler(db_manager, write_auth_req_validator) return handler