Beispiel #1
0
def make_schema_exist(schema_request, schema_handler):
    identifier, req_id, operation = get_request_data(schema_request)
    schema_name = get_write_schema_name(schema_request)
    schema_version = get_write_schema_version(schema_request)
    path = SchemaHandler.make_state_path_for_schema(identifier, schema_name,
                                                    schema_version)
    schema_handler.state.set(path,
                             encode_state_value("value", "seqNo", "txnTime"))
Beispiel #2
0
def test_update_state(schema_request, schema_handler):
    seq_no = 1
    txn_time = 1560241033
    txn = reqToTxn(schema_request)
    append_txn_metadata(txn, seq_no, txn_time)
    path, value_bytes = SchemaHandler.prepare_schema_for_state(txn)
    value = {SCHEMA_ATTR_NAMES: get_txn_schema_attr_names(txn)}

    schema_handler.update_state(txn, None, schema_request)
    assert schema_handler.get_from_state(path) == (value, seq_no, txn_time)
Beispiel #3
0
 def _register_domain_req_handlers(self):
     # Read handlers
     get_nym_handler = GetNymHandler(database_manager=self.node.db_manager)
     get_attribute_handler = GetAttributeHandler(
         database_manager=self.node.db_manager)
     get_schema_handler = GetSchemaHandler(
         database_manager=self.node.db_manager)
     get_claim_def_handler = GetClaimDefHandler(
         database_manager=self.node.db_manager)
     get_revoc_reg_def_handler = GetRevocRegDefHandler(
         database_manager=self.node.db_manager)
     get_revoc_reg_handler = GetRevocRegHandler(
         database_manager=self.node.db_manager)
     get_revoc_reg_delta_handler = GetRevocRegDeltaHandler(
         database_manager=self.node.db_manager,
         get_revocation_strategy=RevocRegDefHandler.get_revocation_strategy)
     # Write handlers
     nym_handler = NymHandler(
         config=self.node.config,
         database_manager=self.node.db_manager,
         write_req_validator=self.node.write_req_validator)
     attrib_handler = AttributeHandler(
         database_manager=self.node.db_manager,
         write_req_validator=self.node.write_req_validator)
     schema_handler = SchemaHandler(
         database_manager=self.node.db_manager,
         write_req_validator=self.node.write_req_validator)
     claim_def_handler = ClaimDefHandler(
         database_manager=self.node.db_manager,
         write_req_validator=self.node.write_req_validator)
     revoc_reg_def_handler = RevocRegDefHandler(
         database_manager=self.node.db_manager,
         write_req_validator=self.node.write_req_validator)
     revoc_reg_entry_handler = RevocRegEntryHandler(
         database_manager=self.node.db_manager,
         write_req_validator=self.node.write_req_validator,
         get_revocation_strategy=RevocRegDefHandler.get_revocation_strategy)
     # Register write handlers
     self.node.write_manager.register_req_handler(nym_handler)
     self.node.write_manager.register_req_handler(attrib_handler)
     self.node.write_manager.register_req_handler(schema_handler)
     self.node.write_manager.register_req_handler(claim_def_handler)
     self.node.write_manager.register_req_handler(revoc_reg_def_handler)
     self.node.write_manager.register_req_handler(revoc_reg_entry_handler)
     # Additional handler for idCache
     self.register_idr_cache_nym_handler()
     # Register read handlers
     self.node.read_manager.register_req_handler(get_nym_handler)
     self.node.read_manager.register_req_handler(get_attribute_handler)
     self.node.read_manager.register_req_handler(get_schema_handler)
     self.node.read_manager.register_req_handler(get_claim_def_handler)
     self.node.read_manager.register_req_handler(get_revoc_reg_def_handler)
     self.node.read_manager.register_req_handler(get_revoc_reg_handler)
     self.node.read_manager.register_req_handler(
         get_revoc_reg_delta_handler)
Beispiel #4
0
 def get_schema(self,
                author: str,
                schema_name: str,
                schema_version: str,
                is_committed=True,
                with_proof=True) -> (str, int, int, list):
     assert author is not None
     assert schema_name is not None
     assert schema_version is not None
     path = SchemaHandler.make_state_path_for_schema(
         author, schema_name, schema_version)
     try:
         keys, seq_no, last_update_time, proof = self.lookup(
             path, is_committed, with_proof=with_proof)
         return keys, seq_no, last_update_time, proof
     except KeyError:
         return None, None, None, None
Beispiel #5
0
def schema_handler(db_manager, write_auth_req_validator):
    return SchemaHandler(db_manager, write_auth_req_validator)
Beispiel #6
0
def schema_handler(db_manager):
    f_validator = FakeSomething()
    f_validator.validate = lambda request, action_list: True
    return SchemaHandler(db_manager, f_validator)
Beispiel #7
0
    def _register_domain_req_handlers(self):
        # Read handlers
        get_nym_handler = GetNymHandler(database_manager=self.node.db_manager)
        get_attribute_handler = GetAttributeHandler(
            database_manager=self.node.db_manager)
        get_schema_handler = GetSchemaHandler(
            database_manager=self.node.db_manager)
        get_claim_def_handler = GetClaimDefHandler(
            database_manager=self.node.db_manager)
        get_revoc_reg_def_handler = GetRevocRegDefHandler(
            database_manager=self.node.db_manager)
        get_revoc_reg_handler = GetRevocRegHandler(
            database_manager=self.node.db_manager)
        get_revoc_reg_delta_handler = GetRevocRegDeltaHandler(
            database_manager=self.node.db_manager,
            get_revocation_strategy=RevocRegDefHandler.get_revocation_strategy)
        # Write handlers
        nym_handler = NymHandler(
            config=self.node.config,
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        attrib_handler = AttributeHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        schema_handler = SchemaHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        claim_def_handler = ClaimDefHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        revoc_reg_def_handler = RevocRegDefHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        revoc_reg_entry_handler = RevocRegEntryHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator,
            get_revocation_strategy=RevocRegDefHandler.get_revocation_strategy)
        json_ld_context_handler = JsonLdContextHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        rich_schema_handler = RichSchemaHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        rich_schema_encoding_handler = RichSchemaEncodingHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        rich_schema_mapping_handler = RichSchemaMappingHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        rich_schema_cred_def_handler = RichSchemaCredDefHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        rich_schema_pres_def_handler = RichSchemaPresDefHandler(
            database_manager=self.node.db_manager,
            write_req_validator=self.node.write_req_validator)
        get_rich_schema_obj_by_id_handler = GetRichSchemaObjectByIdHandler(
            database_manager=self.node.db_manager)
        get_rich_schema_obj_by_metadata_handler = GetRichSchemaObjectByMetadataHandler(
            database_manager=self.node.db_manager)

        # Register write handlers
        self.node.write_manager.register_req_handler(nym_handler)
        self.node.write_manager.register_req_handler(attrib_handler)
        self.node.write_manager.register_req_handler(schema_handler)
        self.node.write_manager.register_req_handler(claim_def_handler)
        self.node.write_manager.register_req_handler(revoc_reg_def_handler)
        self.node.write_manager.register_req_handler(revoc_reg_entry_handler)
        self.node.write_manager.register_req_handler(json_ld_context_handler)
        self.node.write_manager.register_req_handler(rich_schema_handler)
        self.node.write_manager.register_req_handler(
            rich_schema_encoding_handler)
        self.node.write_manager.register_req_handler(
            rich_schema_mapping_handler)
        self.node.write_manager.register_req_handler(
            rich_schema_cred_def_handler)
        self.node.write_manager.register_req_handler(
            rich_schema_pres_def_handler)
        # Additional handler for idCache
        self.register_idr_cache_nym_handler()
        # Register read handlers
        self.node.read_manager.register_req_handler(get_nym_handler)
        self.node.read_manager.register_req_handler(get_attribute_handler)
        self.node.read_manager.register_req_handler(get_schema_handler)
        self.node.read_manager.register_req_handler(get_claim_def_handler)
        self.node.read_manager.register_req_handler(get_revoc_reg_def_handler)
        self.node.read_manager.register_req_handler(get_revoc_reg_handler)
        self.node.read_manager.register_req_handler(
            get_revoc_reg_delta_handler)
        self.node.read_manager.register_req_handler(
            get_rich_schema_obj_by_id_handler)
        self.node.read_manager.register_req_handler(
            get_rich_schema_obj_by_metadata_handler)
Beispiel #8
0
def schema_handler(db_manager):
    f = FakeSomething()
    make_schema_exist(f, False)
    return SchemaHandler(db_manager, f)