예제 #1
0
def test_reject_auth_rules_transaction(looper,
                                       sdk_wallet_steward,
                                       sdk_pool_handle):
    with pytest.raises(RequestRejectedException) as e:
        sdk_send_and_check_auth_rules_request(looper,
                                              sdk_pool_handle,
                                              sdk_wallet_steward)
    e.match('Not enough TRUSTEE signatures')
예제 #2
0
def test_reqnack_auth_rules_transaction_with_wrong_key(looper,
                                                       sdk_wallet_trustee,
                                                       sdk_pool_handle):
    with pytest.raises(RequestNackedException) as e:
        sdk_send_and_check_auth_rules_request(
            looper, sdk_pool_handle, sdk_wallet_trustee,
            [generate_auth_rule(auth_type="*")])
    e.match("InvalidClientRequest")
    e.match("is not found in authorization map")
예제 #3
0
def test_auth_rules_transaction(looper, sdk_wallet_trustee, sdk_pool_handle):
    rule = generate_auth_rule()
    key = dict(rule)
    key.pop(CONSTRAINT)
    sdk_send_and_check_auth_rules_request(looper,
                                          sdk_pool_handle,
                                          sdk_wallet_trustee,
                                          rules=[rule])
    after_resp = _send_and_check_get_auth_rule(looper, sdk_pool_handle,
                                               sdk_wallet_trustee, key)
    assert [rule] == after_resp[0][1]["result"][DATA]
예제 #4
0
def test_reject_with_unacceptable_role_in_constraint(looper,
                                                     sdk_wallet_trustee,
                                                     sdk_pool_handle):
    rule = generate_auth_rule()
    unacceptable_role = 'olololo'
    rule[CONSTRAINT][ROLE] = unacceptable_role
    with pytest.raises(RequestNackedException) as e:
        sdk_send_and_check_auth_rules_request(looper,
                                              sdk_pool_handle,
                                              sdk_wallet_trustee,
                                              rules=[rule])
    e.match('client request invalid')
    e.match('Role {} is not acceptable'.format(unacceptable_role))
예제 #5
0
def test_auth_rules_transaction_without_changes(looper, sdk_wallet_trustee,
                                                sdk_pool_handle):
    before_resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee)
    sdk_send_and_check_auth_rules_request(
        looper,
        sdk_pool_handle,
        sdk_wallet_trustee,
        rules=before_resp[0][1][RESULT][DATA])
    after_resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee)
    assert before_resp[0][1]["result"][DATA] == after_resp[0][1]["result"][
        DATA]
예제 #6
0
def test_reject_all_rules_from_auth_rules_txn(looper, sdk_wallet_trustee,
                                              sdk_pool_handle):
    _, before_resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee)[0]
    rules = [
        generate_auth_rule(ADD_PREFIX, NYM, ROLE, "wrong_new_value"),
        generate_auth_rule(EDIT_PREFIX, NYM, ROLE, TRUST_ANCHOR, TRUSTEE)
    ]
    with pytest.raises(RequestNackedException):
        sdk_send_and_check_auth_rules_request(looper,
                                              sdk_pool_handle,
                                              sdk_wallet_trustee,
                                              rules=rules)
    _, after_resp = sdk_send_and_check_get_auth_rule_request(
        looper, sdk_pool_handle, sdk_wallet_trustee)[0]
    assert before_resp["result"][DATA] == after_resp["result"][DATA]
    def run(self):
        # Step 1. Check default auth rule
        sdk_send_and_check_auth_rules_request(self.looper,
                                              self.sdk_pool_handle,
                                              self.trustee_wallet)
        with pytest.raises(RequestRejectedException):
            sdk_send_and_check_auth_rules_request(self.looper,
                                                  self.sdk_pool_handle,
                                                  self.new_default_wallet)

        # Step 2. Change auth rule
        self.send_and_check(self.changed_auth_rule, self.trustee_wallet)

        # Step 3. Check, that we cannot send txn the old way
        with pytest.raises(RequestRejectedException):
            sdk_send_and_check_auth_rules_request(self.looper,
                                                  self.sdk_pool_handle,
                                                  self.trustee_wallet)

        # Step 4. Check, that new auth rule is used
        sdk_send_and_check_auth_rules_request(self.looper,
                                              self.sdk_pool_handle,
                                              self.new_default_wallet)

        # Step 5. Return default auth rule
        self.send_and_check(self.default_auth_rule, self.new_default_wallet)

        # Step 6. Check, that default auth rule works
        sdk_send_and_check_auth_rules_request(self.looper,
                                              self.sdk_pool_handle,
                                              self.trustee_wallet)
        with pytest.raises(RequestRejectedException):
            sdk_send_and_check_auth_rules_request(self.looper,
                                                  self.sdk_pool_handle,
                                                  self.new_default_wallet)