Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: ashcherbakov <[email protected]>
  • Loading branch information
ashcherbakov committed Aug 8, 2019
1 parent 6431db9 commit 4d47b84
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions indy_common/test/auth/metadata/test_error_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest

from indy_common.authorize.auth_constraints import AuthConstraint, IDENTITY_OWNER, AuthConstraintOr
from indy_common.test.auth.metadata.helper import set_auth_constraint, PLUGIN_FIELD, build_req_and_action
from indy_common.test.auth.metadata.helper import set_auth_constraint, PLUGIN_FIELD, build_req_and_action, Action
from plenum.common.constants import TRUSTEE, STEWARD
from plenum.common.exceptions import UnauthorizedClientRequest

Expand All @@ -15,9 +15,11 @@ def test_plugin_simple_error_msg_no_plugin_field(write_auth_req_validator):
set_auth_constraint(write_auth_req_validator,
AuthConstraint(role=IDENTITY_OWNER, sig_count=1, need_to_be_owner=True,
metadata={PLUGIN_FIELD: 2}))
req, actions = build_req_and_action(signatures={IDENTITY_OWNER: 1},
need_to_be_owner=True,
amount=None)
req, actions = build_req_and_action(Action(author=IDENTITY_OWNER, endorser=None,
sigs={IDENTITY_OWNER: 1},
is_owner=True,
amount=None,
extra_sigs=False))

with pytest.raises(UnauthorizedClientRequest) as excinfo:
write_auth_req_validator.validate(req, actions)
Expand All @@ -27,9 +29,11 @@ def test_plugin_simple_error_msg_no_plugin_field(write_auth_req_validator):
def test_plugin_simple_error_msg_extra_plugin_field(write_auth_req_validator):
set_auth_constraint(write_auth_req_validator,
AuthConstraint(role=IDENTITY_OWNER, sig_count=1, need_to_be_owner=True))
req, actions = build_req_and_action(signatures={IDENTITY_OWNER: 1},
need_to_be_owner=True,
amount=5)
req, actions = build_req_and_action(Action(author=IDENTITY_OWNER, endorser=None,
sigs={IDENTITY_OWNER: 1},
is_owner=True,
amount=5,
extra_sigs=False))

with pytest.raises(UnauthorizedClientRequest) as excinfo:
write_auth_req_validator.validate(req, actions)
Expand All @@ -40,9 +44,11 @@ def test_plugin_simple_error_msg_not_enough_amount(write_auth_req_validator):
set_auth_constraint(write_auth_req_validator,
AuthConstraint(role=IDENTITY_OWNER, sig_count=1, need_to_be_owner=True,
metadata={PLUGIN_FIELD: 10}))
req, actions = build_req_and_action(signatures={IDENTITY_OWNER: 1},
need_to_be_owner=True,
amount=5)
req, actions = build_req_and_action(Action(author=IDENTITY_OWNER, endorser=None,
sigs={IDENTITY_OWNER: 1},
is_owner=True,
amount=5,
extra_sigs=False))

with pytest.raises(UnauthorizedClientRequest) as excinfo:
write_auth_req_validator.validate(req, actions)
Expand All @@ -57,9 +63,11 @@ def test_plugin_or_error_msg_not_enough_amount(write_auth_req_validator):
metadata={PLUGIN_FIELD: 10}),
]))

req, actions = build_req_and_action(signatures={STEWARD: 1},
need_to_be_owner=True,
amount=5)
req, actions = build_req_and_action(Action(author=STEWARD, endorser=None,
sigs={STEWARD: 1},
is_owner=True,
amount=5,
extra_sigs=False))

with pytest.raises(UnauthorizedClientRequest) as excinfo:
write_auth_req_validator.validate(req, actions)
Expand All @@ -82,10 +90,11 @@ def test_plugin_or_error_msg_not_enough_amount_multiple_metadata_fields(write_au
("aaa", "bbb")
]))
]))

req, actions = build_req_and_action(signatures={STEWARD: 1},
need_to_be_owner=True,
amount=5)
req, actions = build_req_and_action(Action(author=STEWARD, endorser=None,
sigs={STEWARD: 1},
is_owner=True,
amount=5,
extra_sigs=False))

with pytest.raises(UnauthorizedClientRequest) as excinfo:
write_auth_req_validator.validate(req, actions)
Expand Down

0 comments on commit 4d47b84

Please sign in to comment.