Example #1
0
def revoc_reg_def_handler(db_manager):
    def lookup(cred_def_id, is_committed, with_proof):
        return True, None, None, None

    get_handler = FakeSomething()
    get_handler.lookup = lookup
    return RevocRegDefHandler(db_manager, get_handler)
Example #2
0
def test_update_state(revoc_reg_entry_handler, revoc_reg_entry_request,
                      revoc_reg_def_handler, revoc_reg_def_request):
    # create revoc_req_def
    seq_no = 1
    txn_time = 1560241030
    revoc_reg_def_request.operation[ISSUANCE_TYPE] = ISSUANCE_BY_DEFAULT
    txn = reqToTxn(revoc_reg_def_request)
    append_txn_metadata(txn, seq_no, txn_time)
    path = RevocRegDefHandler.prepare_revoc_def_for_state(txn, path_only=True)
    revoc_reg_def_handler.update_state(txn, None, revoc_reg_def_request)

    # create revoc_req_entry
    seq_no = 2
    txn_time = 1560241033
    revoc_reg_entry_request.operation[REVOC_REG_DEF_ID] = path.decode()
    txn = reqToTxn(revoc_reg_entry_request)
    append_txn_metadata(txn, seq_no, txn_time)
    revoc_reg_entry_handler.update_state(txn, None, revoc_reg_entry_request)

    # check state for revoc_reg_entry
    txn_data = get_payload_data(txn)
    txn_data[f.SEQ_NO.nm] = seq_no
    txn_data[TXN_TIME] = txn_time
    assert revoc_reg_entry_handler.get_from_state(
        RevocRegEntryHandler.prepare_revoc_reg_entry_for_state(
            txn, path_only=True)) == (txn_data, seq_no, txn_time)
    # check state for revoc_reg_entry
    txn_data[VALUE] = {ACCUM: txn_data[VALUE][ACCUM]}
    path, _ = RevocRegEntryHandler.prepare_revoc_reg_entry_accum_for_state(txn)
    assert revoc_reg_entry_handler.get_from_state(path) == (txn_data, seq_no,
                                                            txn_time)
Example #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)
Example #4
0
def test_update_state(revoc_reg_def_handler, revoc_reg_def_request):
    seq_no = 1
    txn_time = 1560241033
    txn = reqToTxn(revoc_reg_def_request)
    append_txn_metadata(txn, seq_no, txn_time)
    value = get_payload_data(txn)
    path = RevocRegDefHandler.prepare_revoc_def_for_state(txn, path_only=True)

    revoc_reg_def_handler.update_state(txn, None, revoc_reg_def_request)
    assert revoc_reg_def_handler.get_from_state(path) == (value, seq_no,
                                                          txn_time)
Example #5
0
def test_revoc_reg_def_dynamic_validation_fails_no_cred_def(revoc_reg_def_handler,
                                                            revoc_reg_def_request):
    operation = revoc_reg_def_request.operation
    cred_def_id = operation.get(CRED_DEF_ID)
    revoc_def_type = operation.get(REVOC_TYPE)
    revoc_def_tag = operation.get(TAG)
    assert cred_def_id
    assert revoc_def_tag
    assert revoc_def_type
    revoc_def_id = RevocRegDefHandler.make_state_path_for_revoc_def(revoc_reg_def_request.identifier,
                                                                    cred_def_id, revoc_def_type,
                                                                    revoc_def_tag)
    revoc_reg_def_handler.state.set(revoc_def_id, "{}")
    with pytest.raises(InvalidClientRequest,
                       match="There is no any CRED_DEF by path"):
        revoc_reg_def_handler.dynamic_validation(revoc_reg_def_request)
Example #6
0
def revoc_reg_def_handler(db_manager, write_auth_req_validator):
    return RevocRegDefHandler(db_manager, write_auth_req_validator)
Example #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)
Example #8
0
def revoc_reg_def_handler(db_manager):
    f = FakeSomething()
    f.validate = lambda request, action_list: True
    return RevocRegDefHandler(db_manager, f)