예제 #1
0
        public async Task TestReplaceKeysDemoWorks()
        {
            // 1. Create My Did
            var result = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid    = result.Did;
            var myVerkey = result.VerKey;

            // 2. Create Their Did from Trustee1 seed
            var createTheirDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = createTheirDidResult.Did;

            // 3. Build and send Nym Request
            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest);

            // 4. Start replacing of keys
            var newVerkey = await Signus.ReplaceKeysStartAsync(wallet, myDid, "{}");

            // 5. Build and send Nym Request with new key
            nymRequest = await Ledger.BuildNymRequestAsync(myDid, myDid, newVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, nymRequest);

            // 6. Apply replacing of keys
            await Signus.ReplaceKeysApplyAsync(wallet, myDid);

            // 7. Send schema request
            var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, SCHEMA_DATA);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, schemaRequest);
        }
예제 #2
0
        private async Task CheckMessage(string senderVk, byte[] encryptedMsg)
        {
            await Wallet.CreateWalletAsync(POOL, "walletForCheck", TYPE, null, null);

            var localWallet = await Wallet.OpenWalletAsync("walletForCheck", null, null);

            var didJson = string.Format("{{\"seed\":\"{0}\",\"cid\":true}}", MY2_SEED);
            var result  = await Signus.CreateAndStoreMyDidAsync(localWallet, didJson);

            var recipientDid = result.Did;

            var decryptedMessageBytes = await Signus.DecryptSealedAsync(localWallet, recipientDid, encryptedMsg);

            var decryptedMessageJson = Encoding.UTF8.GetString(decryptedMessageBytes);
            var decryptedMsg         = JObject.Parse(decryptedMessageJson);


            Assert.IsTrue(decryptedMsg.Value <bool>("auth"));
            Assert.AreEqual(senderVk, decryptedMsg.Value <string>("sender"));
            Assert.IsNotNull(decryptedMsg.Value <string>("nonce"));
            Assert.IsNotNull(decryptedMsg.Value <string>("msg"));

            await localWallet.CloseAsync();

            await Wallet.DeleteWalletAsync("walletForCheck", null);
        }
예제 #3
0
        public async Task TestReplaceKeysWithoutNymTransaction()
        {
            // 1. Create My Did
            var result = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid    = result.Did;
            var myVerkey = result.VerKey;

            // 2. Create Their Did from Trustee1 seed
            var createTheirDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = createTheirDidResult.Did;

            // 3. Build and send Nym Request
            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest);

            // 4. Start replacing of keys
            await Signus.ReplaceKeysStartAsync(wallet, myDid, "{}");

            // 5. Apply replacing of keys
            await Signus.ReplaceKeysApplyAsync(wallet, myDid);

            // 6. Send schema request
            var schemaRequest = await Ledger.BuildSchemaRequestAsync(myDid, SCHEMA_DATA);

            var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() =>
                                                                                           Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, schemaRequest)
                                                                                           );
        }
예제 #4
0
        [TestMethod] //This test fails here and in the Java version.
        public async Task TestGetTxnRequestWorks()
        {
            var didResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var did = didResult.Did;

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, SCHEMA_DATA);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(pool, wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = schemaResponseObj["result"].Value <int>("seqNo");

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            var returnedSchemaData = getTxnResponseObj["result"]["data"]["data"];
            var expectedSchemaData = JToken.Parse(SCHEMA_DATA);

            Assert.IsTrue(JToken.DeepEquals(expectedSchemaData, returnedSchemaData));
        }
예제 #5
0
        public async Task TestReplaceKeysStartWorksForSeed()
        {
            var result = await Signus.ReplaceKeysStartAsync(wallet, _did, "{\"seed\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}");

            Assert.AreEqual("CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW", result);
            Assert.AreNotEqual(this._verkey, result);
        }
예제 #6
0
        public async Task Before()
        {
            var poolName = PoolUtils.CreatePoolLedgerConfig();

            _pool = await Pool.OpenPoolLedgerAsync(poolName, "{}");

            await Wallet.CreateWalletAsync(poolName, _walletName, "default", null, null);

            _wallet = await Wallet.OpenWalletAsync(_walletName, null, null);

            var trusteeJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var result      = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeJson);

            _trusteeDid    = result.Did;
            _trusteeVerkey = result.VerKey;

            var otherDid = "{\"seed\":\"00000000000000000000000000000My1\"}";
            var nym      = await Signus.CreateAndStoreMyDidAsync(_wallet, otherDid);

            _did    = nym.Did;
            _verkey = nym.VerKey;

            var nymRequest = await Ledger.BuildNymRequestAsync(_trusteeDid, _did, _verkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, _trusteeDid, nymRequest);
        }
예제 #7
0
        public async Task  TestAttribRequestWorks()
        {
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid    = myDidResult.Did;
            var myVerkey = myDidResult.VerKey;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest);

            var attribRequest = await Ledger.BuildAttribRequestAsync(myDid, myDid, null, _endpoint, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, myDid, attribRequest);

            var getAttribRequest = await Ledger.BuildGetAttribRequestAsync(myDid, myDid, "endpoint");

            var getAttribResponse = await Ledger.SubmitRequestAsync(pool, getAttribRequest);

            var jsonObject = JObject.Parse(getAttribResponse);

            Assert.AreEqual(_endpoint, jsonObject["result"]["data"]);
        }
예제 #8
0
        public async Task TestSignAndSubmitRequestWorksForIncompatibleWalletAndPool()
        {
            var walletName = "incompatibleWallet";

            await Wallet.CreateWalletAsync("otherPoolName", walletName, "default", null, null);

            var wallet = await Wallet.OpenWalletAsync(walletName, null, null);

            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid = myDidResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, null, null, null);

            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Ledger.SignAndSubmitRequestAsync(_pool, wallet, trusteeDid, nymRequest)
                                                                       );

            Assert.AreEqual(ErrorCode.WalletIncompatiblePoolError, ex.ErrorCode);
        }
예제 #9
0
        public async Task TestSendNodeRequestWorksForNewSteward()
        {
            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidJson   = "{}";
            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, myDidJson);

            var myDid    = myDidResult.Did;
            var myVerkey = myDidResult.VerKey;

            var role = "STEWARD";

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, role);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest);

            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 dest = "A5iWQVT3k8Zo9nXj4otmeqaUziPQPCiDqcydXkAJBk1Y";

            var nodeRequest = await Ledger.BuildNodeRequestAsync(myDid, dest, data);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, nodeRequest);
        }
예제 #10
0
        public async Task TestClaimDefRequestWorksWithoutSignature()
        {
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var myDid    = myDidResult.Did;
            var myVerkey = myDidResult.VerKey;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            await Ledger.SignAndSubmitRequestAsync(pool, wallet, trusteeDid, nymRequest);

            var claimDef = string.Format(_claimDefTemplate, _seqNo, myDid);

            var claimDefObj  = JObject.Parse(claimDef);
            var claimDefJson = claimDefObj["data"].ToString();

            var claimDefRequest = await Ledger.BuildClaimDefTxnAsync(myDid, _seqNo, _signatureType, claimDefJson);

            var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() =>
                                                                                           Ledger.SubmitRequestAsync(pool, claimDefRequest)
                                                                                           );
        }
예제 #11
0
        public async Task TestGetTxnRequestWorksForInvalidSeqNo()
        {
            var didJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, didJson);

            var did = didResult.Did;

            var schemaData = "{\"name\":\"gvt2\",\"version\":\"3.0\",\"attr_names\": [\"name\", \"male\"]}";

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, schemaData);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = (int)schemaResponseObj["result"]["seqNo"] + 1;

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(_pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            Assert.IsFalse(getTxnResponseObj["result"]["data"].HasValues);
        }
예제 #12
0
        public async Task TestSendNymRequestsWorksForWrongSignerRole()
        {
            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidJson   = "{}";
            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, myDidJson);

            var myDid = myDidResult.Did;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, null, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest);

            var myDidJson2   = "{}";
            var myDidResult2 = await Signus.CreateAndStoreMyDidAsync(_wallet, myDidJson2);

            var myDid2 = myDidResult2.Did;

            var nymRequest2 = await Ledger.BuildNymRequestAsync(myDid, myDid2, null, null, null);

            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Ledger.SignAndSubmitRequestAsync(_pool, _wallet, myDid, nymRequest2)
                                                                       );

            Assert.AreEqual(ErrorCode.LedgerInvalidTransaction, ex.ErrorCode);
        }
예제 #13
0
        [TestMethod] //This test fails here and in the Java version.
        public async Task TestGetTxnRequestWorks()
        {
            var didJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var didResult = await Signus.CreateAndStoreMyDidAsync(_wallet, didJson);

            var did = didResult.Did;

            var schemaData = "{\"name\":\"gvt2\",\"version\":\"3.0\",\"attr_names\": [\"name\", \"male\"]}";

            var schemaRequest = await Ledger.BuildSchemaRequestAsync(did, schemaData);

            var schemaResponse = await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, did, schemaRequest);

            var schemaResponseObj = JObject.Parse(schemaResponse);

            var seqNo = schemaResponseObj["result"].Value <int>("seqNo");

            var getTxnRequest = await Ledger.BuildGetTxnRequestAsync(did, seqNo);

            var getTxnResponse = await Ledger.SubmitRequestAsync(_pool, getTxnRequest);

            var getTxnResponseObj = JObject.Parse(getTxnResponse);

            var returnedSchemaData = getTxnResponseObj["result"]["data"]["data"];
            var expectedSchemaData = JToken.Parse(schemaData);

            Assert.IsTrue(JToken.DeepEquals(expectedSchemaData, returnedSchemaData));
        }
예제 #14
0
        public async Task TestAgentSendWorks()
        {
            var endpoint = "127.0.0.1:9609";

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, "{}");

            var identityJson = string.Format("{{\"did\":\"{0}\", \"pk\":\"{1}\", \"verkey\":\"{2}\", \"endpoint\":\"{3}\"}}",
                                             myDidResult.Did, myDidResult.Pk, myDidResult.VerKey, endpoint);
            await Signus.StoreTheirDidAsync(_wallet, identityJson);

            var activeListener = await Agent.AgentListenAsync(endpoint, _incomingConnectionObserver);

            await activeListener.AddIdentityAsync(_pool, _wallet, myDidResult.Did);

            var clientToServerConnection = await Agent.AgentConnectAsync(_pool, _wallet, myDidResult.Did, myDidResult.Did, _messageObserver);

            var clientToServerMessage = "msg_from_client";
            var serverToClientMessage = "msg_from_server";

            await clientToServerConnection.SendAsync(clientToServerMessage);

            Assert.AreEqual(clientToServerMessage, await clientToServerMsgFuture.Task);

            var serverToClientConnection = await serverToClientConnectionFuture.Task;
            await serverToClientConnection.SendAsync(serverToClientMessage);

            Assert.AreEqual(serverToClientMessage, await serverToClientMsgFuture.Task);
        }
예제 #15
0
        public async Task TestAgentCloseConnectionWorksForIncoming()
        {
            var endpoint = "127.0.0.1:9613";

            var myDid = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var identityJson = string.Format(AGENT_IDENTITY_JSON_TEMPLATE, myDid.Did, myDid.Pk, myDid.VerKey, endpoint);

            await Signus.StoreTheirDidAsync(wallet, identityJson);

            var activeListener = await AgentListener.ListenAsync(endpoint);

            await activeListener.AddIdentityAsync(pool, wallet, myDid.Did);

            var connection = await AgentConnection.ConnectAsync(pool, wallet, myDid.Did, myDid.Did);

            var connectionEvent = await activeListener.WaitForConnectionAsync();

            var serverToClientConnection = connectionEvent.Connection;

            await serverToClientConnection.CloseAsync();

            var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() =>
                                                                                   serverToClientConnection.SendAsync("msg")
                                                                                   );
        }
예제 #16
0
        public async Task PrepareForListener(string endpoint)
        {
            var myDidResult = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var identityJson = string.Format(AGENT_IDENTITY_JSON_TEMPLATE, myDidResult.Did, myDidResult.Pk, myDidResult.VerKey, endpoint);
            await Signus.StoreTheirDidAsync(wallet, identityJson);
        }
        public async Task TestAgentCloseConnectionWorksForIncoming()
        {
            var endpoint = "127.0.0.1:9613";

            var myDid = await Signus.CreateAndStoreMyDidAsync(_wallet, "{}");

            var identityJson = string.Format("{{\"did\":\"{0}\", \"pk\":\"{1}\", \"verkey\":\"{2}\", \"endpoint\":\"{3}\"}}",
                                             myDid.Did, myDid.Pk, myDid.VerKey, endpoint);

            await Signus.StoreTheirDidAsync(_wallet, identityJson);

            var activeListener = await Agent.AgentListenAsync(endpoint, _incomingConnectionObserver);

            await activeListener.AddIdentityAsync(_pool, _wallet, myDid.Did);

            var connection = await Agent.AgentConnectAsync(_pool, _wallet, myDid.Did, myDid.Did, _messageObserver);

            var serverToClientConnection = await _serverToClientConnectionTaskCompletionSource.Task;
            await serverToClientConnection.CloseAsync();


            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       serverToClientConnection.SendAsync("msg")
                                                                       );

            Assert.AreEqual(ErrorCode.CommonInvalidStructure, ex.ErrorCode);
        }
예제 #18
0
        public async Task TestReplaceKeysStartWorksForEmptyJson()
        {
            var result = await Signus.ReplaceKeysStartAsync(wallet, _did, "{}");

            Assert.IsNotNull(result);
            Assert.AreEqual(32, Base58CheckEncoding.DecodePlain(result).Length);
        }
예제 #19
0
        public async Task CreateWalletWithDid()
        {
            var result = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            _did    = result.Did;
            _verkey = result.VerKey;
        }
예제 #20
0
        public async Task TestNymRequestsWorks()
        {
            var trusteeDidJson   = "{\"seed\":\"000000000000000000000000Trustee1\"}";
            var trusteeDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, trusteeDidJson);

            var trusteeDid = trusteeDidResult.Did;

            var myDidResult = await Signus.CreateAndStoreMyDidAsync(_wallet, "{}");

            var myDid    = myDidResult.Did;
            var myVerKey = myDidResult.VerKey;

            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerKey, null, null);

            await Ledger.SignAndSubmitRequestAsync(_pool, _wallet, trusteeDid, nymRequest);

            var getNymRequest = await Ledger.BuildGetNymRequestAsync(myDid, myDid);

            var getNymResponse = await Ledger.SubmitRequestAsync(_pool, getNymRequest);

            var getNymResponseObj = JObject.Parse(getNymResponse);

            Assert.AreEqual("REPLY", (string)getNymResponseObj["op"]);
            Assert.AreEqual("105", (string)getNymResponseObj["result"]["type"]);
            Assert.AreEqual(myDid, (string)getNymResponseObj["result"]["dest"]);
        }
예제 #21
0
        public async Task TestLedgerDemo()
        {
            // 1. Create ledger config from genesis txn file
            var poolName = PoolUtils.CreatePoolLedgerConfig();

            var pool = await Pool.OpenPoolLedgerAsync(poolName, "{}");

            // 2. Create and Open My Wallet
            await Wallet.CreateWalletAsync(poolName, "myWallet", "default", null, null);

            var myWallet = await Wallet.OpenWalletAsync("myWallet", null, null);

            // 3. Create and Open Trustee Wallet
            await Wallet.CreateWalletAsync(poolName, "theirWallet", "default", null, null);

            var trusteeWallet = await Wallet.OpenWalletAsync("theirWallet", null, null);

            // 4. Create My Did
            var createMyDidResult = await Signus.CreateAndStoreMyDidAsync(myWallet, "{}");

            Assert.IsNotNull(createMyDidResult);
            var myDid    = createMyDidResult.Did;
            var myVerkey = createMyDidResult.VerKey;

            // 5. Create Did from Trustee1 seed
            var theirDidJson = "{\"seed\":\"000000000000000000000000Trustee1\"}";

            var createTheirDidResult = await Signus.CreateAndStoreMyDidAsync(trusteeWallet, theirDidJson);

            Assert.IsNotNull(createTheirDidResult);
            var trusteeDid = createTheirDidResult.Did;

            // 6. Build Nym Request
            var nymRequest = await Ledger.BuildNymRequestAsync(trusteeDid, myDid, myVerkey, null, null);

            Assert.IsNotNull(nymRequest);

            // 7. Trustee Sign Nym Request
            var nymResponseJson = await Ledger.SignAndSubmitRequestAsync(pool, trusteeWallet, trusteeDid, nymRequest);

            Assert.IsNotNull(nymResponseJson);

            var nymResponse = JObject.Parse(nymResponseJson);

            Assert.AreEqual(myDid, nymResponse["result"].Value <string>("dest"));
            Assert.AreEqual(myVerkey, nymResponse["result"].Value <string>("verkey"));

            // 8. Close and delete My Wallet
            await myWallet.CloseAsync();

            await Wallet.DeleteWalletAsync("myWallet", null);

            // 9. Close and delete Their Wallet
            await trusteeWallet.CloseAsync();

            await Wallet.DeleteWalletAsync("theirWallet", null);

            // 10. Close Pool
            await pool.CloseAsync();
        }
예제 #22
0
        public async Task TestDecryptWorksForNonceNotCorrespondMessage()
        {
            var nonce = (byte[])(Array) new sbyte[] { 46, 33, -4, 67, 1, 44, 57, -46, -91, 87, 14, 41, -39, 48, 42, -126, -121, 84, -58, 59, -27, 51, -32, -23 };

            var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() =>
                                                                                   Signus.DecryptAsync(wallet, _myDid, _trusteeDid, _encryptedMessage, nonce)
                                                                                   );
        }
예제 #23
0
        public async Task TestEncryptWorksForNotFoundNym()
        {
            var nym = await Signus.CreateAndStoreMyDidAsync(wallet, "{}");

            var ex = await Assert.ThrowsExceptionAsync <InvalidStateException>(() =>
                                                                               Signus.EncryptAsync(wallet, pool, _trusteeDid, DID1, MESSAGE)
                                                                               );
        }
예제 #24
0
        public async Task TestReplaceKeysApplyWorksForNotFoundDid()
        {
            await Signus.ReplaceKeysStartAsync(wallet, _did, "{}");

            var ex = await Assert.ThrowsExceptionAsync <WalletValueNotFoundException>(() =>
                                                                                      Signus.ReplaceKeysApplyAsync(wallet, DID1)
                                                                                      );
        }
예제 #25
0
        public async Task TestCreateMyDidWorksForInvalidCryptoType()
        {
            var json = string.Format("{{\"seed\":\"{0}\",\"crypto_type\":\"crypto_type\"}}", MY1_SEED);

            var ex = await Assert.ThrowsExceptionAsync <UnknownCryptoException>(() =>
                                                                                Signus.CreateAndStoreMyDidAsync(wallet, json)
                                                                                );
        }
예제 #26
0
        public async Task TestStoreTheirDidWorksForCorrectCryptoType()
        {
            var json = string.Format("{{\"did\":\"{0}\", " +
                                     "\"verkey\":\"{1}\", " +
                                     "\"crypto_type\": \"ed25519\"}}", _did, _verkey);

            await Signus.StoreTheirDidAsync(_wallet, json);
        }
예제 #27
0
        public async Task TestCreateMyDidWorksForInvalidIdentityJson()
        {
            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Signus.StoreTheirDidAsync(_wallet, "{\"field\":\"value\"}")
                                                                       );

            Assert.AreEqual(ErrorCode.CommonInvalidStructure, ex.ErrorCode);
        }
예제 #28
0
        public async Task TestVerifyWorksForGetVerkeyFromLedger()
        {
            await Signus.StoreTheirDidAsync(wallet, string.Format("{{\"did\":\"{0}\"}}", _myDid));

            var valid = await Signus.VerifySignatureAsync(wallet, pool, _myDid, MESSAGE, _signature);

            Assert.IsTrue(valid);
        }
예제 #29
0
        public async Task TestStoreTheirDidWorksWithoutDid()
        {
            var ex = await Assert.ThrowsExceptionAsync <IndyException>(() =>
                                                                       Signus.StoreTheirDidAsync(_wallet, string.Format("{{\"verkey\":\"{0}\"}}", _verkey))
                                                                       );

            Assert.AreEqual(ErrorCode.CommonInvalidStructure, ex.ErrorCode);
        }
예제 #30
0
        public async Task TestCreateMyDidWorksForInvalidSeed()
        {
            var json = "{\"seed\":\"aaaaaaaaaaa\"}";

            var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() =>
                                                                                   Signus.CreateAndStoreMyDidAsync(wallet, json)
                                                                                   );
        }