Make Moto (tests) compatible with flask/werkzeug 2.x (#3923)
* Dont fail if CodeCov fails - for now
* CI - Force cache rebuild
* Bump werkzeug to latest version
* CI - Enforce cache flush
* ManagedBlockchain - fix error format
* ManagedBlockchain - Fix tests to use pytest.raises paradigm
* Revert "Lock Flask (#3925)"
This reverts commit 8bb0feb956.
* CI - Enforce cache rebuild
This commit is contained in:
parent
8bb0feb956
commit
9e3faf7784
11 changed files with 599 additions and 317 deletions
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_managedblockchain
|
||||
from . import helpers
|
||||
|
||||
|
|
@ -136,6 +138,10 @@ def test_reject_invitation_badinvitation():
|
|||
Vote="YES",
|
||||
)
|
||||
|
||||
response = conn.reject_invitation.when.called_with(
|
||||
InvitationId="in-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "InvitationId in-ABCDEFGHIJKLMNOP0123456789 not found.")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.reject_invitation(InvitationId="in-ABCDEFGHIJKLMNOP0123456789")
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain(
|
||||
"InvitationId in-ABCDEFGHIJKLMNOP0123456789 not found."
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
from botocore.exceptions import ClientError, ParamValidationError
|
||||
from moto import mock_managedblockchain
|
||||
from . import helpers
|
||||
|
||||
|
|
@ -165,13 +167,17 @@ def test_create_another_member_withopts():
|
|||
response["Member"]["Description"].should.equal("Test Member 2")
|
||||
|
||||
# Try to create member with already used invitation
|
||||
response = conn.create_member.when.called_with(
|
||||
InvitationId=invitation_id,
|
||||
NetworkId=network_id,
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember2", "admin", "Admin12345", False, "Test Member 2 Duplicate"
|
||||
),
|
||||
).should.throw(Exception, "Invitation {0} not valid".format(invitation_id))
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
InvitationId=invitation_id,
|
||||
NetworkId=network_id,
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember2", "admin", "Admin12345", False, "Test Member 2 Duplicate"
|
||||
),
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("Invitation {0} not valid".format(invitation_id))
|
||||
|
||||
# Delete member 2
|
||||
conn.delete_member(NetworkId=network_id, MemberId=member_id2)
|
||||
|
|
@ -182,9 +188,11 @@ def test_create_another_member_withopts():
|
|||
members.should.have.length_of(2)
|
||||
|
||||
# But cannot get
|
||||
response = conn.get_member.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id2,
|
||||
).should.throw(Exception, "Member {0} not found".format(member_id2))
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_member(NetworkId=network_id, MemberId=member_id2)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member {0} not found".format(member_id2))
|
||||
|
||||
# Delete member 1
|
||||
conn.delete_member(NetworkId=network_id, MemberId=member_id)
|
||||
|
|
@ -362,13 +370,17 @@ def test_create_too_many_members():
|
|||
)[0]
|
||||
|
||||
# Try to create one too many members
|
||||
response = conn.create_member.when.called_with(
|
||||
InvitationId=invitation_id,
|
||||
NetworkId=network_id,
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember6", "admin", "Admin12345", False, "Test Member 6"
|
||||
),
|
||||
).should.throw(Exception, "is the maximum number of members allowed in a",)
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
InvitationId=invitation_id,
|
||||
NetworkId=network_id,
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember6", "admin", "Admin12345", False, "Test Member 6"
|
||||
),
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceLimitExceededException")
|
||||
err["Message"].should.contain("is the maximum number of members allowed in a")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -409,17 +421,20 @@ def test_create_another_member_alreadyhave():
|
|||
invitation_id = response["Invitations"][0]["InvitationId"]
|
||||
|
||||
# Should fail trying to create with same name
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember1", "admin", "Admin12345", False
|
||||
),
|
||||
).should.throw(
|
||||
Exception,
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember1", "admin", "Admin12345", False
|
||||
),
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain(
|
||||
"Member name {0} already exists in network {1}".format(
|
||||
"testmember1", network_id
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -427,13 +442,17 @@ def test_create_another_member_alreadyhave():
|
|||
def test_create_another_member_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
InvitationId="id-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember2", "admin", "Admin12345", False
|
||||
),
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
InvitationId="id-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember2", "admin", "Admin12345", False
|
||||
),
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -451,13 +470,17 @@ def test_create_another_member_badinvitation():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId="in-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember2", "admin", "Admin12345", False
|
||||
),
|
||||
).should.throw(Exception, "Invitation in-ABCDEFGHIJKLMNOP0123456789 not valid")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId="in-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberConfiguration=helpers.create_member_configuration(
|
||||
"testmember2", "admin", "Admin12345", False
|
||||
),
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("Invitation in-ABCDEFGHIJKLMNOP0123456789 not valid")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -509,73 +532,97 @@ def test_create_another_member_adminpassword():
|
|||
badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
|
||||
"AdminPassword"
|
||||
] = "badap"
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Invalid length for parameter MemberConfiguration.FrameworkConfiguration.Fabric.AdminPassword",
|
||||
with pytest.raises(ParamValidationError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
)
|
||||
err = ex.value
|
||||
str(err).should.contain(
|
||||
"Invalid length for parameter MemberConfiguration.FrameworkConfiguration.Fabric.AdminPassword"
|
||||
)
|
||||
|
||||
# No uppercase or numbers
|
||||
badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
|
||||
"AdminPassword"
|
||||
] = "badadminpwd"
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
# No lowercase or numbers
|
||||
badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
|
||||
"AdminPassword"
|
||||
] = "BADADMINPWD"
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
# No numbers
|
||||
badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
|
||||
"AdminPassword"
|
||||
] = "badAdminpwd"
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
# Invalid character
|
||||
badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][
|
||||
"AdminPassword"
|
||||
] = "badAdmin@pwd1"
|
||||
response = conn.create_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_member(
|
||||
NetworkId=network_id,
|
||||
InvitationId=invitation_id,
|
||||
MemberConfiguration=badadminpassmemberconf,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_list_members_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.list_members.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_members(NetworkId="n-ABCDEFGHIJKLMNOP0123456789")
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_get_member_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.get_member.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_member(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -593,19 +640,25 @@ def test_get_member_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.get_member.when.called_with(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_member(NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789")
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_delete_member_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.delete_member.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.delete_member(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -623,22 +676,30 @@ def test_delete_member_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.delete_member.when.called_with(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.delete_member(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789"
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_update_member_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.update_member.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_memberconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.update_member(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_memberconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -656,10 +717,14 @@ def test_update_member_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.update_member.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_memberconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.update_member(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_memberconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_managedblockchain
|
||||
from . import helpers
|
||||
|
||||
|
|
@ -68,31 +70,39 @@ def test_create_network_withopts():
|
|||
def test_create_network_noframework():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.create_network.when.called_with(
|
||||
Name="testnetwork1",
|
||||
Description="Test Network 1",
|
||||
Framework="HYPERLEDGER_VINYL",
|
||||
FrameworkVersion="1.2",
|
||||
FrameworkConfiguration=helpers.default_frameworkconfiguration,
|
||||
VotingPolicy=helpers.default_votingpolicy,
|
||||
MemberConfiguration=helpers.default_memberconfiguration,
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_network(
|
||||
Name="testnetwork1",
|
||||
Description="Test Network 1",
|
||||
Framework="HYPERLEDGER_VINYL",
|
||||
FrameworkVersion="1.2",
|
||||
FrameworkConfiguration=helpers.default_frameworkconfiguration,
|
||||
VotingPolicy=helpers.default_votingpolicy,
|
||||
MemberConfiguration=helpers.default_memberconfiguration,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_create_network_badframeworkver():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.create_network.when.called_with(
|
||||
Name="testnetwork1",
|
||||
Description="Test Network 1",
|
||||
Framework="HYPERLEDGER_FABRIC",
|
||||
FrameworkVersion="1.X",
|
||||
FrameworkConfiguration=helpers.default_frameworkconfiguration,
|
||||
VotingPolicy=helpers.default_votingpolicy,
|
||||
MemberConfiguration=helpers.default_memberconfiguration,
|
||||
).should.throw(
|
||||
Exception, "Invalid version 1.X requested for framework HYPERLEDGER_FABRIC"
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_network(
|
||||
Name="testnetwork1",
|
||||
Description="Test Network 1",
|
||||
Framework="HYPERLEDGER_FABRIC",
|
||||
FrameworkVersion="1.X",
|
||||
FrameworkConfiguration=helpers.default_frameworkconfiguration,
|
||||
VotingPolicy=helpers.default_votingpolicy,
|
||||
MemberConfiguration=helpers.default_memberconfiguration,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain(
|
||||
"Invalid version 1.X requested for framework HYPERLEDGER_FABRIC"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -102,21 +112,27 @@ def test_create_network_badedition():
|
|||
|
||||
frameworkconfiguration = {"Fabric": {"Edition": "SUPER"}}
|
||||
|
||||
response = conn.create_network.when.called_with(
|
||||
Name="testnetwork1",
|
||||
Description="Test Network 1",
|
||||
Framework="HYPERLEDGER_FABRIC",
|
||||
FrameworkVersion="1.2",
|
||||
FrameworkConfiguration=frameworkconfiguration,
|
||||
VotingPolicy=helpers.default_votingpolicy,
|
||||
MemberConfiguration=helpers.default_memberconfiguration,
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_network(
|
||||
Name="testnetwork1",
|
||||
Description="Test Network 1",
|
||||
Framework="HYPERLEDGER_FABRIC",
|
||||
FrameworkVersion="1.2",
|
||||
FrameworkConfiguration=frameworkconfiguration,
|
||||
VotingPolicy=helpers.default_votingpolicy,
|
||||
MemberConfiguration=helpers.default_memberconfiguration,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_get_network_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.get_network.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_network(NetworkId="n-ABCDEFGHIJKLMNOP0123456789")
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_managedblockchain
|
||||
from . import helpers
|
||||
|
||||
|
|
@ -76,9 +78,11 @@ def test_create_node():
|
|||
helpers.node_id_exist_in_list(nodes, node_id).should.equal(True)
|
||||
|
||||
# But cannot get
|
||||
response = conn.get_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeId=node_id,
|
||||
).should.throw(Exception, "Node {0} not found".format(node_id))
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_node(NetworkId=network_id, MemberId=member_id, NodeId=node_id)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Node {0} not found".format(node_id))
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -145,9 +149,11 @@ def test_create_node_standard_edition():
|
|||
conn.delete_member(NetworkId=network_id, MemberId=member_id)
|
||||
|
||||
# Should now be an exception
|
||||
response = conn.list_nodes.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id,
|
||||
).should.throw(Exception, "Member {0} not found".format(member_id))
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_nodes(NetworkId=network_id, MemberId=member_id)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member {0} not found".format(member_id))
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -187,12 +193,16 @@ def test_create_too_many_nodes():
|
|||
nodes.should.have.length_of(2)
|
||||
|
||||
# Try to create one too many nodes
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
).should.throw(
|
||||
Exception, "Maximum number of nodes exceeded in member {0}".format(member_id),
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_node(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceLimitExceededException")
|
||||
err["Message"].should.contain(
|
||||
"Maximum number of nodes exceeded in member {0}".format(member_id)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -200,11 +210,15 @@ def test_create_too_many_nodes():
|
|||
def test_create_node_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_node(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -222,11 +236,15 @@ def test_create_node_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_node(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeConfiguration=helpers.default_nodeconfiguration,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -248,36 +266,51 @@ def test_create_node_badnodeconfig():
|
|||
# Incorrect instance type
|
||||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["InstanceType"] = "foo"
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
).should.throw(Exception, "Requested instance foo isn't supported.")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_node(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("Requested instance foo isn't supported.")
|
||||
|
||||
# Incorrect instance type for edition
|
||||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["InstanceType"] = "bc.t3.large"
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Instance type bc.t3.large is not supported with STARTER Edition networks",
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_node(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain(
|
||||
"Instance type bc.t3.large is not supported with STARTER Edition networks."
|
||||
)
|
||||
|
||||
# Incorrect availability zone
|
||||
logconfigbad = dict(helpers.default_nodeconfiguration)
|
||||
logconfigbad["AvailabilityZone"] = "us-east-11"
|
||||
response = conn.create_node.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad,
|
||||
).should.throw(Exception, "Availability Zone is not valid")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_node(
|
||||
NetworkId=network_id, MemberId=member_id, NodeConfiguration=logconfigbad
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("Availability Zone is not valid")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_list_nodes_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.list_nodes.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_nodes(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -295,20 +328,28 @@ def test_list_nodes_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.list_nodes.when.called_with(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_nodes(
|
||||
NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_get_node_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.get_node.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_node(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -326,11 +367,15 @@ def test_get_node_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.get_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_node(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -349,22 +394,30 @@ def test_get_node_badnode():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.get_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_node(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_delete_node_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.delete_node.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.delete_node(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -382,11 +435,15 @@ def test_delete_node_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.delete_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.delete_node(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -405,25 +462,33 @@ def test_delete_node_badnode():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.delete_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.delete_node(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_update_node_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.update_node.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_nodeconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.update_node(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_nodeconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -441,14 +506,18 @@ def test_update_node_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.update_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_nodeconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.update_node(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_nodeconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -467,11 +536,15 @@ def test_update_node_badnode():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.update_node.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_nodeconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
).should.throw(Exception, "Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.update_node(
|
||||
NetworkId=network_id,
|
||||
MemberId=member_id,
|
||||
NodeId="nd-ABCDEFGHIJKLMNOP0123456789",
|
||||
LogPublishingConfiguration=helpers.default_nodeconfiguration[
|
||||
"LogPublishingConfiguration"
|
||||
],
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Node nd-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
|
||||
from botocore.exceptions import ClientError
|
||||
from moto import mock_managedblockchain
|
||||
from . import helpers
|
||||
|
||||
|
|
@ -82,11 +84,15 @@ def test_create_proposal_withopts():
|
|||
def test_create_proposal_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.create_proposal.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Actions=helpers.default_policy_actions,
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_proposal(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Actions=helpers.default_policy_actions,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -104,11 +110,15 @@ def test_create_proposal_badmember():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.create_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Actions=helpers.default_policy_actions,
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_proposal(
|
||||
NetworkId=network_id,
|
||||
MemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Actions=helpers.default_policy_actions,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -130,9 +140,15 @@ def test_create_proposal_badinvitationacctid():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.create_proposal.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=actions,
|
||||
).should.throw(Exception, "Account ID format specified in proposal is not valid")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_proposal(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=actions,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain(
|
||||
"Account ID format specified in proposal is not valid"
|
||||
)
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -154,28 +170,38 @@ def test_create_proposal_badremovalmemid():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.create_proposal.when.called_with(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=actions,
|
||||
).should.throw(Exception, "Member ID format specified in proposal is not valid")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.create_proposal(
|
||||
NetworkId=network_id, MemberId=member_id, Actions=actions,
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("Member ID format specified in proposal is not valid")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_list_proposal_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.list_proposals.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_proposals(NetworkId="n-ABCDEFGHIJKLMNOP0123456789",)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
def test_get_proposal_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.get_proposal.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_proposal(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -193,6 +219,10 @@ def test_get_proposal_badproposal():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.get_proposal.when.called_with(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.get_proposal(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ from __future__ import unicode_literals
|
|||
import os
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
import sure # noqa
|
||||
from botocore.exceptions import ClientError
|
||||
from freezegun import freeze_time
|
||||
from unittest import SkipTest
|
||||
|
||||
|
|
@ -321,14 +323,17 @@ def test_vote_on_proposal_expiredproposal():
|
|||
|
||||
with freeze_time("2015-02-01 12:00:00"):
|
||||
# Vote yes - should set status to expired
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Proposal {0} is expired and you cannot vote on it.".format(proposal_id),
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain(
|
||||
"Proposal {0} is expired and you cannot vote on it.".format(proposal_id)
|
||||
)
|
||||
|
||||
# Get proposal details - should be EXPIRED
|
||||
|
|
@ -438,12 +443,16 @@ def test_vote_on_proposal_status_check():
|
|||
pendinginvs.should.have.length_of(1)
|
||||
|
||||
# Vote with member 3 - should throw an exception and not create a new invitation
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=memberidlist[2],
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "and you cannot vote on it")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=memberidlist[2],
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("InvalidRequestException")
|
||||
err["Message"].should.contain("and you cannot vote on it")
|
||||
|
||||
# Should still be one pending invitation
|
||||
response = conn.list_invitations()
|
||||
|
|
@ -457,12 +466,16 @@ def test_vote_on_proposal_status_check():
|
|||
def test_vote_on_proposal_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -480,12 +493,16 @@ def test_vote_on_proposal_badproposal():
|
|||
)
|
||||
network_id = response["NetworkId"]
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -512,12 +529,16 @@ def test_vote_on_proposal_badmember():
|
|||
|
||||
proposal_id = response["ProposalId"]
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
).should.throw(Exception, "Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId="m-ABCDEFGHIJKLMNOP0123456789",
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Member m-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -544,12 +565,16 @@ def test_vote_on_proposal_badvote():
|
|||
|
||||
proposal_id = response["ProposalId"]
|
||||
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="FOO",
|
||||
).should.throw(Exception, "Invalid request body")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="FOO",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("BadRequestException")
|
||||
err["Message"].should.contain("Invalid request body")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -628,14 +653,17 @@ def test_vote_on_proposal_alreadyvoted():
|
|||
)
|
||||
|
||||
# Vote yes with member 1 again
|
||||
response = conn.vote_on_proposal.when.called_with(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
).should.throw(
|
||||
Exception,
|
||||
"Member {0} has already voted on proposal {1}.".format(member_id, proposal_id),
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.vote_on_proposal(
|
||||
NetworkId=network_id,
|
||||
ProposalId=proposal_id,
|
||||
VoterMemberId=member_id,
|
||||
Vote="YES",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceAlreadyExistsException")
|
||||
err["Message"].should.contain(
|
||||
"Member {0} has already voted on proposal {1}.".format(member_id, proposal_id)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -643,10 +671,14 @@ def test_vote_on_proposal_alreadyvoted():
|
|||
def test_list_proposal_votes_badnetwork():
|
||||
conn = boto3.client("managedblockchain", region_name="us-east-1")
|
||||
|
||||
response = conn.list_proposal_votes.when.called_with(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_proposal_votes(
|
||||
NetworkId="n-ABCDEFGHIJKLMNOP0123456789",
|
||||
ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Network n-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
||||
|
||||
@mock_managedblockchain
|
||||
|
|
@ -665,6 +697,10 @@ def test_list_proposal_votes_badproposal():
|
|||
network_id = response["NetworkId"]
|
||||
member_id = response["MemberId"]
|
||||
|
||||
response = conn.list_proposal_votes.when.called_with(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
).should.throw(Exception, "Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
with pytest.raises(ClientError) as ex:
|
||||
conn.list_proposal_votes(
|
||||
NetworkId=network_id, ProposalId="p-ABCDEFGHIJKLMNOP0123456789",
|
||||
)
|
||||
err = ex.value.response["Error"]
|
||||
err["Code"].should.equal("ResourceNotFoundException")
|
||||
err["Message"].should.contain("Proposal p-ABCDEFGHIJKLMNOP0123456789 not found")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue