public async Task TestBuildNodeRequestWorksForMissedField() { var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"services\":[\"VALIDATOR\"]}"; var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() => Ledger.BuildNodeRequestAsync(DID1, _dest, data) ); }
public async Task TestSendNodeRequestWorksWithoutSignature() { var didResult = await Signus.CreateAndStoreMyDidAsync(wallet, _stewardDidJson); var did = didResult.Did; var nodeRequest = await Ledger.BuildNodeRequestAsync(did, did, _data); var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() => Ledger.SubmitRequestAsync(pool, nodeRequest) ); }
public async Task TestBuildNodeRequestWorks() { var expectedResult = string.Format("\"identifier\":\"{0}\"," + "\"operation\":{{" + "\"type\":\"0\"," + "\"dest\":\"{1}\"," + "\"data\":{2}" + "}}", DID, _dest, _data); var nodeRequest = await Ledger.BuildNodeRequestAsync(DID, _dest, _data); Assert.IsTrue(nodeRequest.Replace("\\", "").Contains(expectedResult)); }
public async Task TestBuildNodeRequestWorksForMissedField() { var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"services\":[\"VALIDATOR\"]}"; var ex = await Assert.ThrowsExceptionAsync <IndyException>(() => Ledger.BuildNodeRequestAsync(_identifier, _dest, data) ); Assert.AreEqual(ErrorCode.CommonInvalidStructure, ex.ErrorCode); }
public async Task TestBuildNodeRequestWorksForWrongServiceType() { var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"alias\":\"some\"," + "\"services\":[\"SERVICE\"]," + "\"blskey\":\"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW\"}"; var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() => Ledger.BuildNodeRequestAsync(DID1, _dest, data) ); }
public async Task TestBuildNodeRequestWorksForWrongServiceType() { var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"alias\":\"some\"," + "\"services\":[\"SERVICE\"]," + "\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\"," + "\"blskey_pop\":\"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1\"" + "}"; var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() => Ledger.BuildNodeRequestAsync(DID, _dest, data) ); }
public async Task TestBuildNodeRequestWorks() { var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"alias\":\"some\"," + "\"services\":[\"VALIDATOR\"]}"; var expectedResult = string.Format("\"identifier\":\"{0}\"," + "\"operation\":{{" + "\"type\":\"0\"," + "\"dest\":\"{1}\"," + "\"data\":{2}" + "}}", _identifier, _dest, data); var nodeRequest = await Ledger.BuildNodeRequestAsync(_identifier, _dest, data); Assert.IsTrue(nodeRequest.Replace("\\", "").Contains(expectedResult)); }
public async Task TestSendNodeRequestWorksForNewSteward() { var trusteeDidResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var trusteeDid = trusteeDidResult.Did; var myDidResult = await Did.CreateAndStoreMyDidAsync(wallet, "{}"); var myDid = myDidResult.Did; var myVerkey = myDidResult.VerKey; var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, "STEWARD"); await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest); var nodeRequest = await Ledger.BuildNodeRequestAsync(myDid, _dest, _data); await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, nodeRequest); }
public async Task TestSendNodeRequestWorksForWrongRole() { var didResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"alias\":\"some\"," + "\"services\":[\"VALIDATOR\"]," + "\"blskey\":\"CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW\"}"; var nodeRequest = await Ledger.BuildNodeRequestAsync(did, did, data); var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() => Ledger.SignAndSubmitRequestAsync(pool, wallet, did, nodeRequest) ); }
public async Task TestSendNodeRequestWorksWithoutSignature() { var didJson = "{\"seed\":\"000000000000000000000000Steward1\"}"; var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, didJson); var did = didResult.Did; var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":910," + "\"alias\":\"some\"," + "\"services\":[\"VALIDATOR\"]}"; var nodeRequest = await Ledger.BuildNodeRequestAsync(did, did, data); var ex = await Assert.ThrowsExceptionAsync <IndyException>(() => Ledger.SubmitRequestAsync(_pool, nodeRequest) ); Assert.AreEqual(ErrorCode.LedgerInvalidTransaction, ex.ErrorCode); }
public async Task TestSendNodeRequestReturnsReqNackForWrongRole() { var didResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON); var did = didResult.Did; var data = "{\"node_ip\":\"10.0.0.100\"," + "\"node_port\":910," + "\"client_ip\":\"10.0.0.100\"," + "\"client_port\":911," + "\"alias\":\"some\"," + "\"services\":[\"VALIDATOR\"]," + "\"blskey\":\"4N8aUNHSgjQVgkpm8nhNEfDf6txHznoYREg9kirmJrkivgL4oSEimFF6nsQ6M41QvhM2Z33nves5vfSn9n1UwNFJBYtWVnHYMATn76vLuL3zU88KyeAYcHfsih3He6UHcXDxcaecHVz6jhCYz1P2UZn2bDVruL5wXpehgBfBaLKm3Ba\"," + "\"blskey_pop\":\"RahHYiCvoNCtPTrVtP7nMC5eTYrsUA8WjXbdhNc8debh1agE9bGiJxWBXYNFbnJXoXhWFMvyqhqhRoq737YQemH5ik9oL7R4NTTCz2LEZhkgLJzB3QRQqJyBNyv7acbdHrAT8nQ9UkLbaVL9NBpnWXBTw4LEMePaSHEw66RzPNdAX1\"" + "}"; var nodeRequest = await Ledger.BuildNodeRequestAsync(did, did, data); var result = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, nodeRequest); Assert.IsTrue(result.Contains("\"op\":\"REJECT\"")); Assert.IsTrue(result.Contains("UnauthorizedClientRequest")); }