def test_auth_rule_after_get_auth_rule_as_is_using_sdk( looper, sdk_pool_handle, sdk_wallet_trustee ): # get all auth rules auth_rules_resp = sdk_send_and_check_get_auth_rule_request( looper, sdk_pool_handle, sdk_wallet_trustee ) auth_rules = auth_rules_resp[0][1][RESULT][DATA] for rule in auth_rules: # prepare action key dict_key = dict(rule) dict_key.pop(CONSTRAINT) # prepare AUTH_RULE request req_json = build_auth_rule_request_json( looper, sdk_wallet_trustee[1], **rule ) # send AUTH_RULE txn req = sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_trustee, req_json) sdk_get_and_check_replies(looper, [req]) # send GET_AUTH_RULE get_response = sdk_send_and_check_get_auth_rule_request( looper, sdk_pool_handle, sdk_wallet_trustee, **dict_key) # check response result = get_response[0][1]["result"][DATA] assert len(result) == 1 _check_key(dict_key, result[0]) assert rule[CONSTRAINT] == result[0][CONSTRAINT] assert get_response[0][1]["result"][STATE_PROOF]
def get_changed_auth_rule(self): constraint = AuthConstraint(role=TRUSTEE, sig_count=1, need_to_be_owner=False) params = self._generate_auth_rule_params(constraint) return build_auth_rule_request_json(self.looper, self.trustee_wallet[1], **params)
def test_auth_rule_transaction_for_edit(looper, txnPoolNodeSet, sdk_wallet_trustee, sdk_wallet_steward, sdk_pool_handle): constraint = AuthConstraint(role=STEWARD, sig_count=1, need_to_be_owner=False) req1 = build_auth_rule_request_json(looper, sdk_wallet_trustee[1], auth_action=ADD_PREFIX, auth_type=CLAIM_DEF, field='*', new_value='*', constraint=constraint.as_dict) send_and_check(looper, sdk_pool_handle, req1, wallet=sdk_wallet_trustee) constraint = AuthConstraint(role=TRUSTEE, sig_count=1, need_to_be_owner=False) req2 = build_auth_rule_request_json(looper, sdk_wallet_trustee[1], auth_action=EDIT_PREFIX, auth_type=CLAIM_DEF, field='*', old_value='*', new_value='*', constraint=constraint.as_dict) send_and_check(looper, sdk_pool_handle, req2, wallet=sdk_wallet_trustee) schema_json = get_schema_json(looper, sdk_pool_handle, sdk_wallet_trustee) reply = sdk_send_claim_def(looper, sdk_pool_handle, sdk_wallet_steward, 'tag_1', schema_json) req = reply[0][0] req[OPERATION][DATA]['primary']['n'] = 'abc' with pytest.raises(RequestRejectedException): resp = sdk_sign_and_submit_op(looper, sdk_pool_handle, sdk_wallet_steward, op=req[OPERATION]) sdk_get_and_check_replies(looper, [resp])
def change_auth_rule(looper, sdk_pool_handle, sdk_wallet_trustee, constraint): req = build_auth_rule_request_json(looper, sdk_wallet_trustee[1], auth_action=ADD_PREFIX, auth_type=NYM, field=ROLE, old_value=None, new_value=NEW_ROLE, constraint=constraint.as_dict) sdk_send_and_check_req_json(looper, sdk_pool_handle, sdk_wallet_trustee, req)
def get_default_auth_rule(self): constraint = auth_map.get(self.action_id) return build_auth_rule_request_json( self.looper, self.trustee_wallet[1], auth_action=self.action.prefix, auth_type=self.action.txn_type, field=self.action.field, old_value=self.action.old_value if self.action.prefix == EDIT_PREFIX else None, new_value=self.action.new_value, constraint=constraint.as_dict)
def get_changed_auth_rule(self): constraint = AuthConstraint(role=TRUSTEE, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.creator_wallet[1], auth_action=EDIT_PREFIX, auth_type=NYM, field=VERKEY, old_value='*', new_value='*', constraint=constraint.as_dict)
def get_changed_auth_rule(self): constraint = AuthConstraint(role=None, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.trustee_wallet[1], auth_action=EDIT_PREFIX, auth_type=AUTH_RULE, field='*', old_value='*', new_value='*', constraint=constraint.as_dict)
def get_changed_auth_rule(self): self.checker_wallet = self.env.role_to_wallet[TRUST_ANCHOR] constraint = AuthConstraint(role=TRUST_ANCHOR, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.creator_wallet[1], auth_action=ADD_PREFIX, auth_type=NYM, field=ROLE, new_value=self.role, constraint=constraint.as_dict)
def get_changed_auth_rule(self): self.new_default_wallet = sdk_add_new_nym(self.looper, self.sdk_pool_handle, self.trustee_wallet, role=IDENTITY_OWNER) constraint = AuthConstraint(role=IDENTITY_OWNER, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json( self.looper, self.trustee_wallet[1], auth_action=ADD_PREFIX, auth_type=POOL_UPGRADE, field='action', new_value='start', constraint=constraint.as_dict )
def prepare_request(looper, sdk_wallet_trustee): constraint = AuthConstraint(TRUSTEE, 1) action = AuthActionAdd(txn_type=NYM, field=ROLE, value=STEWARD) auth_params = { "constraint": constraint.as_dict, "auth_action": "ADD", "auth_type": NYM, 'field': ROLE, "new_value": STEWARD } req_json = build_auth_rule_request_json(looper, sdk_wallet_trustee[1], **auth_params) return action, constraint, Request(**json.loads(req_json))
def get_changed_auth_rule(self): self.new_default_wallet = self.add_revoc_reg_def.new_default_wallet constraint = AuthConstraint(role=IDENTITY_OWNER, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.trustee_wallet[1], auth_action=EDIT_PREFIX, auth_type=REVOC_REG_DEF, field='*', old_value='*', new_value='*', constraint=constraint.as_dict)
def get_default_auth_rule(self): action = AuthActionEdit(txn_type=AUTH_RULE, field='*', old_value='*', new_value='*') constraint = auth_map.auth_map.get(action.get_action_id()) return build_auth_rule_request_json(self.looper, self.new_default_wallet[1], auth_action=EDIT_PREFIX, auth_type=AUTH_RULE, field='*', old_value='*', new_value='*', constraint=constraint.as_dict)
def get_changed_auth_rule(self): new_role = random.choice(list(self.other_roles)) self.new_who_can_wallet = self.env.role_to_wallet[new_role] constraint = AuthConstraint(role=new_role, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.trustee_wallet[1], auth_action=self.action.prefix, auth_type=self.action.txn_type, field=self.action.field, old_value=self.action.old_value, new_value=self.action.new_value, constraint=constraint.as_dict)
def get_changed_auth_rule(self): sdk_add_new_nym(self.looper, self.sdk_pool_handle, self.trustee_wallet, role=IDENTITY_OWNER) constraint = AuthConstraint(role=TRUSTEE, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.trustee_wallet[1], auth_action=ADD_PREFIX, auth_type=ATTRIB, field='*', new_value='*', constraint=constraint.as_dict)
def get_changed_auth_rule(self): self.new_default_wallet = sdk_add_new_nym(self.looper, self.sdk_pool_handle, self.trustee_wallet, role=STEWARD) constraint = AuthConstraint(role=STEWARD, sig_count=1, need_to_be_owner=False) return build_auth_rule_request_json(self.looper, self.trustee_wallet[1], auth_action=EDIT_PREFIX, auth_type=LEDGERS_FREEZE, field='*', old_value='*', new_value='*', constraint=constraint.as_dict)
def change_auth_rule(looper, sdk_pool_handle, sdk_wallet_trustee, constraint): req = build_auth_rule_request_json(looper, sdk_wallet_trustee[1], auth_action=ADD_PREFIX, auth_type=NYM, field=ROLE, old_value=None, new_value=NEW_ROLE, constraint=constraint.as_dict) req = json.loads(req) req[OPERATION][CONSTRAINT][ OFF_LEDGER_SIGNATURE] = constraint.off_ledger_signature req = json.dumps(req) sdk_send_and_check_req_json(looper, sdk_pool_handle, sdk_wallet_trustee, req)
def changed_auth_rule(looper, sdk_pool_handle, sdk_wallet_trustee, fees_set): constraint = AuthConstraintOr(auth_constraints=[AuthConstraint(role='*', sig_count=1, off_ledger_signature=True, metadata={FEES_FIELD_NAME: txn_type_to_alias[NYM]}), AuthConstraint(role=TRUSTEE, sig_count=1) ]) req = build_auth_rule_request_json( looper, sdk_wallet_trustee[1], auth_action=ADD_PREFIX, auth_type=NYM, field=ROLE, old_value=None, new_value=NEW_ROLE, constraint=constraint.as_dict ) req = json.loads(req) req[OPERATION][CONSTRAINT]['auth_constraints'][0][OFF_LEDGER_SIGNATURE] = True req = json.dumps(req) sdk_send_and_check_req_json(looper, sdk_pool_handle, sdk_wallet_trustee, req)