|
|
|
@ -63,10 +63,14 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
new BigInteger( |
|
|
|
|
"853d7f0010fd86d0d7811c1f9d968ea89a24484a8127b4a483ddf5d2cfec766d", 16))); |
|
|
|
|
private static final String PRIVACY_GROUP_ID = "B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; |
|
|
|
|
private static final String ENCLAVE_KEY = "A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; |
|
|
|
|
private static final String KEY1 = "sgFkVOyFndZe/5SAZJO5UYbrl7pezHetveriBBWWnE8="; |
|
|
|
|
private static final String KEY2 = "R1kW75NQC9XX3kwNpyPjCBFflM29+XvnKKS9VLrUkzo="; |
|
|
|
|
private static final String KEY3 = "QzHuACXpfhoGAgrQriWJcDJ6MrUwcCvutKMoAn9KplQ="; |
|
|
|
|
private static final String PARTICIPANT_ENCLAVE_KEY0 = |
|
|
|
|
"A1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo="; |
|
|
|
|
private static final String PARTICIPANT_ENCLAVE_KEY1 = |
|
|
|
|
"sgFkVOyFndZe/5SAZJO5UYbrl7pezHetveriBBWWnE8="; |
|
|
|
|
private static final String PARTICIPANT_ENCLAVE_KEY2 = |
|
|
|
|
"R1kW75NQC9XX3kwNpyPjCBFflM29+XvnKKS9VLrUkzo="; |
|
|
|
|
private static final String PARTICIPANT_ENCLAVE_KEY3 = |
|
|
|
|
"QzHuACXpfhoGAgrQriWJcDJ6MrUwcCvutKMoAn9KplQ="; |
|
|
|
|
private final Address senderAddress = |
|
|
|
|
Address.wrap(Bytes.fromHexString(accounts.getPrimaryBenefactor().getAddress())); |
|
|
|
|
|
|
|
|
@ -108,7 +112,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
|
|
|
|
|
receiveEnclaveStub(validSignedPrivateTransaction); |
|
|
|
|
retrievePrivacyGroupEnclaveStub(); |
|
|
|
|
sendEnclaveStub(KEY1); |
|
|
|
|
sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); |
|
|
|
|
|
|
|
|
|
final Hash transactionHash = |
|
|
|
|
node.execute( |
|
|
|
@ -124,7 +128,10 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
|
|
|
|
|
node.verify( |
|
|
|
|
priv.createPrivacyGroup( |
|
|
|
|
List.of(KEY1, KEY2, KEY3), "GroupName", "Group description.", PRIVACY_GROUP_ID)); |
|
|
|
|
List.of(PARTICIPANT_ENCLAVE_KEY1, PARTICIPANT_ENCLAVE_KEY2, PARTICIPANT_ENCLAVE_KEY3), |
|
|
|
|
"GroupName", |
|
|
|
|
"Group description.", |
|
|
|
|
PRIVACY_GROUP_ID)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -140,13 +147,13 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
throws JsonProcessingException { |
|
|
|
|
final List<PrivacyGroup> groupMembership = |
|
|
|
|
List.of( |
|
|
|
|
testPrivacyGroup(singletonList(ENCLAVE_KEY), PrivacyGroup.Type.PANTHEON), |
|
|
|
|
testPrivacyGroup(singletonList(ENCLAVE_KEY), PrivacyGroup.Type.PANTHEON), |
|
|
|
|
testPrivacyGroup(singletonList(ENCLAVE_KEY), PrivacyGroup.Type.PANTHEON)); |
|
|
|
|
testPrivacyGroup(singletonList(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON), |
|
|
|
|
testPrivacyGroup(singletonList(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON), |
|
|
|
|
testPrivacyGroup(singletonList(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON)); |
|
|
|
|
|
|
|
|
|
findPrivacyGroupEnclaveStub(groupMembership); |
|
|
|
|
|
|
|
|
|
node.verify(priv.findPrivacyGroup(groupMembership.size(), ENCLAVE_KEY)); |
|
|
|
|
node.verify(priv.findPrivacyGroup(groupMembership.size(), PARTICIPANT_ENCLAVE_KEY0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@ -156,7 +163,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
getValidSignedPrivateTransaction(senderAddress); |
|
|
|
|
|
|
|
|
|
retrievePrivacyGroupEnclaveStub(); |
|
|
|
|
sendEnclaveStub(KEY1); |
|
|
|
|
sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); |
|
|
|
|
receiveEnclaveStub(validSignedPrivateTransaction); |
|
|
|
|
|
|
|
|
|
node.verify( |
|
|
|
@ -173,7 +180,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); |
|
|
|
|
|
|
|
|
|
retrievePrivacyGroupEnclaveStub(); |
|
|
|
|
sendEnclaveStub(KEY1); |
|
|
|
|
sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); |
|
|
|
|
receiveEnclaveStub(validSignedPrivateTransaction); |
|
|
|
|
|
|
|
|
|
node.verify(priv.getTransactionCount(accountAddress, PRIVACY_GROUP_ID, 0)); |
|
|
|
@ -187,10 +194,11 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
@Test |
|
|
|
|
public void privDistributeRawTransactionSuccessShouldReturnEnclaveKey() |
|
|
|
|
throws JsonProcessingException { |
|
|
|
|
final String enclaveResponseKeyBytes = Bytes.wrap(Bytes.fromBase64String(KEY1)).toString(); |
|
|
|
|
final String enclaveResponseKeyBytes = |
|
|
|
|
Bytes.wrap(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY1)).toString(); |
|
|
|
|
|
|
|
|
|
retrievePrivacyGroupEnclaveStub(); |
|
|
|
|
sendEnclaveStub(KEY1); |
|
|
|
|
sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); |
|
|
|
|
|
|
|
|
|
node.verify( |
|
|
|
|
priv.distributeRawTransaction( |
|
|
|
@ -206,7 +214,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
final BytesValueRLPOutput rlpOutput = getRLPOutput(validSignedPrivateTransaction); |
|
|
|
|
|
|
|
|
|
retrievePrivacyGroupEnclaveStub(); |
|
|
|
|
sendEnclaveStub(KEY1); |
|
|
|
|
sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); |
|
|
|
|
receiveEnclaveStub(validSignedPrivateTransaction); |
|
|
|
|
|
|
|
|
|
final Hash transactionReceipt = |
|
|
|
@ -227,7 +235,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
List.of(testPrivacyGroup(emptyList(), PrivacyGroup.Type.LEGACY)); |
|
|
|
|
|
|
|
|
|
retrievePrivacyGroupEnclaveStub(); |
|
|
|
|
sendEnclaveStub(KEY1); |
|
|
|
|
sendEnclaveStub(PARTICIPANT_ENCLAVE_KEY1); |
|
|
|
|
receiveEnclaveStub(validSignedPrivateTransaction); |
|
|
|
|
findPrivacyGroupEnclaveStub(groupMembership); |
|
|
|
|
|
|
|
|
@ -237,7 +245,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
|
|
|
|
|
node.verify(priv.getSuccessfulTransactionReceipt(transactionHash)); |
|
|
|
|
|
|
|
|
|
final String privateFrom = ENCLAVE_KEY; |
|
|
|
|
final String privateFrom = PARTICIPANT_ENCLAVE_KEY0; |
|
|
|
|
final String[] privateFor = {senderAddressBase64}; |
|
|
|
|
node.verify(priv.getEeaTransactionCount(accountAddress, privateFrom, privateFor, 1)); |
|
|
|
|
} |
|
|
|
@ -262,7 +270,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
private void retrievePrivacyGroupEnclaveStub() throws JsonProcessingException { |
|
|
|
|
final String retrieveGroupResponse = |
|
|
|
|
mapper.writeValueAsString( |
|
|
|
|
testPrivacyGroup(List.of(ENCLAVE_KEY), PrivacyGroup.Type.PANTHEON)); |
|
|
|
|
testPrivacyGroup(List.of(PARTICIPANT_ENCLAVE_KEY0), PrivacyGroup.Type.PANTHEON)); |
|
|
|
|
stubFor(post("/retrievePrivacyGroup").willReturn(ok(retrieveGroupResponse))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -309,7 +317,7 @@ public class MultiTenancyAcceptanceTest extends AcceptanceTestBase { |
|
|
|
|
.payload(Bytes.wrap(new byte[] {})) |
|
|
|
|
.sender(senderAddress) |
|
|
|
|
.chainId(BigInteger.valueOf(2018)) |
|
|
|
|
.privateFrom(Bytes.fromBase64String(ENCLAVE_KEY)) |
|
|
|
|
.privateFrom(Bytes.fromBase64String(PARTICIPANT_ENCLAVE_KEY0)) |
|
|
|
|
.restriction(Restriction.RESTRICTED) |
|
|
|
|
.privacyGroupId(Bytes.fromBase64String(PRIVACY_GROUP_ID)) |
|
|
|
|
.signAndBuild(TEST_KEY); |
|
|
|
|