| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | import boto3 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  | import pytest | 
					
						
							| 
									
										
										
										
											2023-09-01 07:07:54 +00:00
										 |  |  | from botocore.config import Config | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  | from botocore.exceptions import ClientError, ParamValidationError | 
					
						
							| 
									
										
										
										
											2023-11-30 07:55:51 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | from moto import mock_managedblockchain | 
					
						
							| 
									
										
										
										
											2023-11-30 07:55:51 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | from . import helpers | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_another_member(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network | 
					
						
							|  |  |  |     response = conn.create_network( | 
					
						
							|  |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Description="Test Network 1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     network_id = response["NetworkId"] | 
					
						
							|  |  |  |     member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create proposal | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     proposal_id = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         NetworkId=network_id, MemberId=member_id, Actions=helpers.default_policy_actions | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Get proposal details | 
					
						
							|  |  |  |     response = conn.get_proposal(NetworkId=network_id, ProposalId=proposal_id) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Proposal"]["NetworkId"] == network_id | 
					
						
							|  |  |  |     assert response["Proposal"]["Status"] == "IN_PROGRESS" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         ProposalId=proposal_id, | 
					
						
							|  |  |  |         VoterMemberId=member_id, | 
					
						
							|  |  |  |         Vote="YES", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Get the invitation | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Invitations"][0]["NetworkSummary"]["Id"] == network_id | 
					
						
							|  |  |  |     assert response["Invitations"][0]["Status"] == "PENDING" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |     invitation_id = response["Invitations"][0]["InvitationId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create the member | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     member_id2 = conn.create_member( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         InvitationId=invitation_id, | 
					
						
							|  |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.create_member_configuration( | 
					
						
							|  |  |  |             "testmember2", "admin", "Admin12345", False | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["MemberId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Check the invitation status | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Invitations"][0]["InvitationId"] == invitation_id | 
					
						
							|  |  |  |     assert response["Invitations"][0]["Status"] == "ACCEPTED" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Find member in full list | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     members = conn.list_members(NetworkId=network_id)["Members"] | 
					
						
							|  |  |  |     assert len(members) == 2 | 
					
						
							|  |  |  |     assert helpers.member_id_exist_in_list(members, member_id2) is True | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Get member 2 details | 
					
						
							|  |  |  |     response = conn.get_member(NetworkId=network_id, MemberId=member_id2) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Member"]["Name"] == "testmember2" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Update member | 
					
						
							|  |  |  |     logconfignewenabled = not helpers.default_memberconfiguration[ | 
					
						
							|  |  |  |         "LogPublishingConfiguration" | 
					
						
							|  |  |  |     ]["Fabric"]["CaLogs"]["Cloudwatch"]["Enabled"] | 
					
						
							|  |  |  |     logconfignew = { | 
					
						
							|  |  |  |         "Fabric": {"CaLogs": {"Cloudwatch": {"Enabled": logconfignewenabled}}} | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     conn.update_member( | 
					
						
							|  |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         MemberId=member_id2, | 
					
						
							|  |  |  |         LogPublishingConfiguration=logconfignew, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Get member 2 details | 
					
						
							|  |  |  |     response = conn.get_member(NetworkId=network_id, MemberId=member_id2) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     cloudwatch = response["Member"]["LogPublishingConfiguration"]["Fabric"]["CaLogs"][ | 
					
						
							|  |  |  |         "Cloudwatch" | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |     assert cloudwatch["Enabled"] == logconfignewenabled | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_another_member_withopts(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network | 
					
						
							|  |  |  |     response = conn.create_network( | 
					
						
							|  |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     network_id = response["NetworkId"] | 
					
						
							|  |  |  |     member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create proposal | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     proposal_id = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         NetworkId=network_id, MemberId=member_id, Actions=helpers.default_policy_actions | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Get proposal details | 
					
						
							|  |  |  |     response = conn.get_proposal(NetworkId=network_id, ProposalId=proposal_id) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Proposal"]["NetworkId"] == network_id | 
					
						
							|  |  |  |     assert response["Proposal"]["Status"] == "IN_PROGRESS" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         ProposalId=proposal_id, | 
					
						
							|  |  |  |         VoterMemberId=member_id, | 
					
						
							|  |  |  |         Vote="YES", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Get the invitation | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Invitations"][0]["NetworkSummary"]["Id"] == network_id | 
					
						
							|  |  |  |     assert response["Invitations"][0]["Status"] == "PENDING" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |     invitation_id = response["Invitations"][0]["InvitationId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create the member | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     member_id2 = conn.create_member( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         InvitationId=invitation_id, | 
					
						
							|  |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.create_member_configuration( | 
					
						
							|  |  |  |             "testmember2", "admin", "Admin12345", False, "Test Member 2" | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["MemberId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Check the invitation status | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Invitations"][0]["InvitationId"] == invitation_id | 
					
						
							|  |  |  |     assert response["Invitations"][0]["Status"] == "ACCEPTED" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Find member in full list | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     members = conn.list_members(NetworkId=network_id)["Members"] | 
					
						
							|  |  |  |     assert len(members) == 2 | 
					
						
							|  |  |  |     assert helpers.member_id_exist_in_list(members, member_id2) is True | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Get member 2 details | 
					
						
							|  |  |  |     response = conn.get_member(NetworkId=network_id, MemberId=member_id2) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Member"]["Description"] == "Test Member 2" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Try to create member with already used invitation | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "InvalidRequestException" | 
					
						
							|  |  |  |     assert f"Invitation {invitation_id} not valid" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Delete member 2 | 
					
						
							|  |  |  |     conn.delete_member(NetworkId=network_id, MemberId=member_id2) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Member is still in the list | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     members = conn.list_members(NetworkId=network_id)["Members"] | 
					
						
							|  |  |  |     assert len(members) == 2 | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # But cannot get | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.get_member(NetworkId=network_id, MemberId=member_id2) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert f"Member {member_id2} not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Delete member 1 | 
					
						
							|  |  |  |     conn.delete_member(NetworkId=network_id, MemberId=member_id) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Network should be gone | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     mbcnetworks = conn.list_networks()["Networks"] | 
					
						
							|  |  |  |     assert len(mbcnetworks) == 0 | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Verify the invitation network status is DELETED | 
					
						
							|  |  |  |     # Get the invitation | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert len(response["Invitations"]) == 1 | 
					
						
							|  |  |  |     assert response["Invitations"][0]["NetworkSummary"]["Id"] == network_id | 
					
						
							|  |  |  |     assert response["Invitations"][0]["NetworkSummary"]["Status"] == "DELETED" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							| 
									
										
										
										
											2020-05-15 19:38:19 -05:00
										 |  |  | def test_invite_and_remove_member(): | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network | 
					
						
							|  |  |  |     response = conn.create_network( | 
					
						
							|  |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     network_id = response["NetworkId"] | 
					
						
							|  |  |  |     member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create proposal (create additional member) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     proposal_id = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         NetworkId=network_id, MemberId=member_id, Actions=helpers.default_policy_actions | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         ProposalId=proposal_id, | 
					
						
							|  |  |  |         VoterMemberId=member_id, | 
					
						
							|  |  |  |         Vote="YES", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Get the invitation | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							|  |  |  |     invitation_id = response["Invitations"][0]["InvitationId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create the member | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     member_id2 = conn.create_member( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         InvitationId=invitation_id, | 
					
						
							|  |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.create_member_configuration( | 
					
						
							|  |  |  |             "testmember2", "admin", "Admin12345", False, "Test Member 2" | 
					
						
							|  |  |  |         ), | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["MemberId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     both_policy_actions = { | 
					
						
							|  |  |  |         "Invitations": [{"Principal": "123456789012"}], | 
					
						
							|  |  |  |         "Removals": [{"MemberId": member_id2}], | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create proposal (invite and remove member) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     proposal_id2 = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         NetworkId=network_id, MemberId=member_id, Actions=both_policy_actions | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Get proposal details | 
					
						
							|  |  |  |     response = conn.get_proposal(NetworkId=network_id, ProposalId=proposal_id2) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Proposal"]["NetworkId"] == network_id | 
					
						
							|  |  |  |     assert response["Proposal"]["Status"] == "IN_PROGRESS" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         ProposalId=proposal_id2, | 
					
						
							|  |  |  |         VoterMemberId=member_id, | 
					
						
							|  |  |  |         Vote="YES", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Check the invitation status | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							|  |  |  |     invitations = helpers.select_invitation_id_for_network( | 
					
						
							|  |  |  |         response["Invitations"], network_id, "PENDING" | 
					
						
							|  |  |  |     ) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert len(invitations) == 1 | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Member is still in the list | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     members = conn.list_members(NetworkId=network_id)["Members"] | 
					
						
							|  |  |  |     assert len(members) == 2 | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |     foundmember2 = False | 
					
						
							|  |  |  |     for member in members: | 
					
						
							|  |  |  |         if member["Id"] == member_id2 and member["Status"] == "DELETED": | 
					
						
							|  |  |  |             foundmember2 = True | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert foundmember2 is True | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_too_many_members(): | 
					
						
							| 
									
										
										
										
											2023-09-01 07:07:54 +00:00
										 |  |  |     # This test throws a ResourceLimitException, with HTTP status code 429 | 
					
						
							|  |  |  |     # Boto3 automatically retries a request with that status code up to 5 times | 
					
						
							|  |  |  |     # Retrying is not going to make a difference to the output though... | 
					
						
							|  |  |  |     config = Config(retries={"max_attempts": 1, "mode": "standard"}) | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1", config=config) | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Create network | 
					
						
							|  |  |  |     response = conn.create_network( | 
					
						
							|  |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     network_id = response["NetworkId"] | 
					
						
							|  |  |  |     member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create 4 more members - create invitations for 5 | 
					
						
							|  |  |  |     for counter in range(2, 7): | 
					
						
							|  |  |  |         # Create proposal | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         proposal_id = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             MemberId=member_id, | 
					
						
							|  |  |  |             Actions=helpers.default_policy_actions, | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             ProposalId=proposal_id, | 
					
						
							|  |  |  |             VoterMemberId=member_id, | 
					
						
							|  |  |  |             Vote="YES", | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for counter in range(2, 6): | 
					
						
							|  |  |  |         # Get the invitation | 
					
						
							|  |  |  |         response = conn.list_invitations() | 
					
						
							|  |  |  |         invitation_id = helpers.select_invitation_id_for_network( | 
					
						
							|  |  |  |             response["Invitations"], network_id, "PENDING" | 
					
						
							|  |  |  |         )[0] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Create the member | 
					
						
							|  |  |  |         response = conn.create_member( | 
					
						
							|  |  |  |             InvitationId=invitation_id, | 
					
						
							|  |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             MemberConfiguration=helpers.create_member_configuration( | 
					
						
							|  |  |  |                 "testmember" + str(counter), | 
					
						
							|  |  |  |                 "admin", | 
					
						
							|  |  |  |                 "Admin12345", | 
					
						
							|  |  |  |                 False, | 
					
						
							|  |  |  |                 "Test Member " + str(counter), | 
					
						
							|  |  |  |             ), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # Find member in full list | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         members = conn.list_members(NetworkId=network_id)["Members"] | 
					
						
							|  |  |  |         assert len(members) == counter | 
					
						
							|  |  |  |         assert helpers.member_id_exist_in_list(members, member_id) is True | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |         # Get member details | 
					
						
							|  |  |  |         response = conn.get_member(NetworkId=network_id, MemberId=member_id) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         assert response["Member"]["Description"] == "Test Member " + str(counter) | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Try to create the sixth | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							|  |  |  |     invitation_id = helpers.select_invitation_id_for_network( | 
					
						
							|  |  |  |         response["Invitations"], network_id, "PENDING" | 
					
						
							|  |  |  |     )[0] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-15 19:38:19 -05:00
										 |  |  |     # Try to create one too many members | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceLimitExceededException" | 
					
						
							|  |  |  |     assert "is the maximum number of members allowed in a" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_another_member_alreadyhave(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network | 
					
						
							|  |  |  |     response = conn.create_network( | 
					
						
							|  |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Description="Test Network 1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     network_id = response["NetworkId"] | 
					
						
							|  |  |  |     member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create proposal | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     proposal_id = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         NetworkId=network_id, MemberId=member_id, Actions=helpers.default_policy_actions | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         ProposalId=proposal_id, | 
					
						
							|  |  |  |         VoterMemberId=member_id, | 
					
						
							|  |  |  |         Vote="YES", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Get the invitation | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							|  |  |  |     invitation_id = response["Invitations"][0]["InvitationId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Should fail trying to create with same name | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "InvalidRequestException" | 
					
						
							|  |  |  |     assert ( | 
					
						
							| 
									
										
										
										
											2022-11-17 21:41:08 -01:00
										 |  |  |         f"Member name testmember1 already exists in network {network_id}" | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_another_member_badnetwork(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_another_member_badinvitation(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network - need a good network | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     network_id = conn.create_network( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["NetworkId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "InvalidRequestException" | 
					
						
							|  |  |  |     assert "Invitation in-ABCDEFGHIJKLMNOP0123456789 not valid" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_create_another_member_adminpassword(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network - need a good network | 
					
						
							|  |  |  |     response = conn.create_network( | 
					
						
							|  |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  |     network_id = response["NetworkId"] | 
					
						
							|  |  |  |     member_id = response["MemberId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create proposal | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     proposal_id = conn.create_proposal( | 
					
						
							| 
									
										
										
										
											2022-03-10 13:39:59 -01:00
										 |  |  |         NetworkId=network_id, MemberId=member_id, Actions=helpers.default_policy_actions | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["ProposalId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Get proposal details | 
					
						
							|  |  |  |     response = conn.get_proposal(NetworkId=network_id, ProposalId=proposal_id) | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert response["Proposal"]["NetworkId"] == network_id | 
					
						
							|  |  |  |     assert response["Proposal"]["Status"] == "IN_PROGRESS" | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Vote yes | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     conn.vote_on_proposal( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         NetworkId=network_id, | 
					
						
							|  |  |  |         ProposalId=proposal_id, | 
					
						
							|  |  |  |         VoterMemberId=member_id, | 
					
						
							|  |  |  |         Vote="YES", | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Get the invitation | 
					
						
							|  |  |  |     response = conn.list_invitations() | 
					
						
							|  |  |  |     invitation_id = response["Invitations"][0]["InvitationId"] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     badadminpassmemberconf = helpers.create_member_configuration( | 
					
						
							|  |  |  |         "testmember2", "admin", "Admin12345", False | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Too short | 
					
						
							|  |  |  |     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][ | 
					
						
							|  |  |  |         "AdminPassword" | 
					
						
							|  |  |  |     ] = "badap" | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ParamValidationError) as ex: | 
					
						
							|  |  |  |         conn.create_member( | 
					
						
							|  |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             InvitationId=invitation_id, | 
					
						
							|  |  |  |             MemberConfiguration=badadminpassmemberconf, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert ( | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |         "Invalid length for parameter MemberConfiguration.FrameworkConfiguration.Fabric.AdminPassword" | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |         in str(err) | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |     ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # No uppercase or numbers | 
					
						
							|  |  |  |     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][ | 
					
						
							|  |  |  |         "AdminPassword" | 
					
						
							|  |  |  |     ] = "badadminpwd" | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.create_member( | 
					
						
							|  |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             InvitationId=invitation_id, | 
					
						
							|  |  |  |             MemberConfiguration=badadminpassmemberconf, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "BadRequestException" | 
					
						
							|  |  |  |     assert "Invalid request body" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # No lowercase or numbers | 
					
						
							|  |  |  |     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][ | 
					
						
							|  |  |  |         "AdminPassword" | 
					
						
							|  |  |  |     ] = "BADADMINPWD" | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.create_member( | 
					
						
							|  |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             InvitationId=invitation_id, | 
					
						
							|  |  |  |             MemberConfiguration=badadminpassmemberconf, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "BadRequestException" | 
					
						
							|  |  |  |     assert "Invalid request body" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # No numbers | 
					
						
							|  |  |  |     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][ | 
					
						
							|  |  |  |         "AdminPassword" | 
					
						
							|  |  |  |     ] = "badAdminpwd" | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.create_member( | 
					
						
							|  |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             InvitationId=invitation_id, | 
					
						
							|  |  |  |             MemberConfiguration=badadminpassmemberconf, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "BadRequestException" | 
					
						
							|  |  |  |     assert "Invalid request body" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     # Invalid character | 
					
						
							|  |  |  |     badadminpassmemberconf["FrameworkConfiguration"]["Fabric"][ | 
					
						
							|  |  |  |         "AdminPassword" | 
					
						
							|  |  |  |     ] = "badAdmin@pwd1" | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.create_member( | 
					
						
							|  |  |  |             NetworkId=network_id, | 
					
						
							|  |  |  |             InvitationId=invitation_id, | 
					
						
							|  |  |  |             MemberConfiguration=badadminpassmemberconf, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "BadRequestException" | 
					
						
							|  |  |  |     assert "Invalid request body" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_list_members_badnetwork(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.list_members(NetworkId="n-ABCDEFGHIJKLMNOP0123456789") | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_get_member_badnetwork(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.get_member( | 
					
						
							|  |  |  |             NetworkId="n-ABCDEFGHIJKLMNOP0123456789", | 
					
						
							|  |  |  |             MemberId="m-ABCDEFGHIJKLMNOP0123456789", | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_get_member_badmember(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network - need a good network | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     network_id = conn.create_network( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["NetworkId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.get_member(NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789") | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_delete_member_badnetwork(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.delete_member( | 
					
						
							|  |  |  |             NetworkId="n-ABCDEFGHIJKLMNOP0123456789", | 
					
						
							|  |  |  |             MemberId="m-ABCDEFGHIJKLMNOP0123456789", | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_delete_member_badmember(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network - need a good network | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     network_id = conn.create_network( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["NetworkId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     with pytest.raises(ClientError) as ex: | 
					
						
							|  |  |  |         conn.delete_member( | 
					
						
							|  |  |  |             NetworkId=network_id, MemberId="m-ABCDEFGHIJKLMNOP0123456789" | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     err = ex.value.response["Error"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_update_member_badnetwork(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Network n-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @mock_managedblockchain | 
					
						
							|  |  |  | def test_update_member_badmember(): | 
					
						
							|  |  |  |     conn = boto3.client("managedblockchain", region_name="us-east-1") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     # Create network - need a good network | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     network_id = conn.create_network( | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  |         Name="testnetwork1", | 
					
						
							|  |  |  |         Framework="HYPERLEDGER_FABRIC", | 
					
						
							|  |  |  |         FrameworkVersion="1.2", | 
					
						
							|  |  |  |         FrameworkConfiguration=helpers.default_frameworkconfiguration, | 
					
						
							|  |  |  |         VotingPolicy=helpers.default_votingpolicy, | 
					
						
							|  |  |  |         MemberConfiguration=helpers.default_memberconfiguration, | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     )["NetworkId"] | 
					
						
							| 
									
										
										
										
											2020-05-13 06:28:22 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-13 10:36:56 +01:00
										 |  |  |     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"] | 
					
						
							| 
									
										
										
										
											2023-08-13 10:15:19 +00:00
										 |  |  |     assert err["Code"] == "ResourceNotFoundException" | 
					
						
							|  |  |  |     assert "Member m-ABCDEFGHIJKLMNOP0123456789 not found" in err["Message"] |