def dynamic_validation(self, request: Request, req_pp_time: Optional[int]): # we can not add a Claim Def with existent ISSUER_DID # sine a Claim Def needs to be identified by seqNo self._validate_request_type(request) identifier, req_id, operation = get_request_data(request) ref = operation[REF] try: txn = self.ledger.get_by_seq_no_uncommitted(ref) except KeyError: raise InvalidClientRequest(identifier, req_id, "Mentioned seqNo ({}) doesn't exist.".format(ref)) if txn['txn']['type'] != SCHEMA: raise InvalidClientRequest(identifier, req_id, "Mentioned seqNo ({}) isn't seqNo of the schema.".format(ref)) signature_type = get_write_claim_def_signature_type(request) schema_ref = get_write_claim_def_schema_ref(request) tag = get_write_claim_def_tag(request) path = self.make_state_path_for_claim_def(identifier, schema_ref, signature_type, tag) claim_def, _, _ = self.get_from_state(path, is_committed=False) if claim_def: self.write_req_validator.validate(request, [AuthActionEdit(txn_type=CLAIM_DEF, field='*', old_value='*', new_value='*')]) else: self.write_req_validator.validate(request, [AuthActionAdd(txn_type=CLAIM_DEF, field='*', value='*')])
def _validate_claim_def(self, req: Request): # we can not add a Claim Def with existent ISSUER_DID # sine a Claim Def needs to be identified by seqNo ref = req.operation[REF] try: txn = self.ledger.get_by_seq_no_uncommitted(ref) except KeyError: raise InvalidClientRequest( req.identifier, req.reqId, "Mentioned seqNo ({}) doesn't exist.".format(ref)) if txn['txn']['type'] != SCHEMA: raise InvalidClientRequest( req.identifier, req.reqId, "Mentioned seqNo ({}) isn't seqNo of the schema.".format(ref)) frm = req.identifier signature_type = get_write_claim_def_signature_type(req) schema_ref = get_write_claim_def_schema_ref(req) tag = get_write_claim_def_tag(req) keys, last_seq_no, _, _ = self.getClaimDef( author=frm, schemaSeqNo=schema_ref, signatureType=signature_type, tag=tag, isCommitted=False) if last_seq_no: self.write_req_validator.validate(req, [ AuthActionEdit(txn_type=CLAIM_DEF, field='*', old_value='*', new_value='*') ]) else: self.write_req_validator.validate( req, [AuthActionAdd(txn_type=CLAIM_DEF, field='*', value='*')])
def test_get_write_claim_def_schema_ref(write_claim_def_request): assert 18 == get_write_claim_def_schema_ref(write_claim_def_request)