Ejemplo n.º 1
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"]);
        }
Ejemplo n.º 2
0
        public async Task TestAttribRequestWorksForEncValue()
        {
            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, null);

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

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

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

            var getAttribRequest = await Ledger.BuildGetAttribRequestAsync(myDid, myDid, null, null, enc);

            var getAttribResponse = await PoolUtils.EnsurePreviousRequestAppliedAsync(pool, getAttribRequest, response => {
                var getAttribResponseObject = JObject.Parse(response);
                return(enc == getAttribResponseObject["result"]["data"].ToString());
            });

            Assert.IsNotNull(getAttribResponse);
        }
Ejemplo n.º 3
0
        public async Task  TestBuildGetAttribRequestWorks()
        {
            string raw = "endpoint";

            string expectedResult = string.Format("\"identifier\":\"{0}\"," +
                                                  "\"operation\":{{" +
                                                  "\"type\":\"104\"," +
                                                  "\"dest\":\"{1}\"," +
                                                  "\"raw\":\"{2}\"", _identifier, _dest, raw);

            string attribRequest = await Ledger.BuildGetAttribRequestAsync(_identifier, _dest, raw, string.Empty, string.Empty);

            /*
             * BuildGetAttribRequestAsync returns
             *  {
             *      "reqId":1536952084743836000,
             *      "identifier":"Th7MpTaRZVRYnPiabds81Y",
             *      "operation":
             *      {
             *          "type":"104",
             *          "dest":"FYmoFw55GeQH7SRFa37dkx1d2dZ3zUF8ckg7wmL7ofN4",
             *          "raw":"endpoint",
             *          "hash":"",
             *          "enc":""
             *      },
             *      "protocolVersion":2
             *  }
             *
             */


            Assert.IsTrue(attribRequest.Contains(expectedResult));
        }
        /// <inheritdoc />
        public virtual async Task <string> LookupAttributeAsync(Pool pool, string targetDid, string attributeName)
        {
            var req = await Ledger.BuildGetAttribRequestAsync(null, targetDid, attributeName, null, null);

            var res = await Ledger.SubmitRequestAsync(pool, req);

            return(null);
        }
Ejemplo n.º 5
0
        public async Task  TestBuildGetAttribRequestWorks()
        {
            string raw = "endpoint";

            string expectedResult = string.Format("\"identifier\":\"{0}\"," +
                                                  "\"operation\":{{" +
                                                  "\"type\":\"104\"," +
                                                  "\"dest\":\"{1}\"," +
                                                  "\"raw\":\"{2}\"" +
                                                  "}}", _identifier, _dest, raw);

            string attribRequest = await Ledger.BuildGetAttribRequestAsync(_identifier, _dest, raw);

            Assert.IsTrue(attribRequest.Contains(expectedResult));
        }
Ejemplo n.º 6
0
        public async Task TestBuildGetAttribRequestWorksForHashValue()
        {
            string raw = "endpoint";

            string expectedResult = string.Format("\"identifier\":\"{0}\"," +
                                                  "\"operation\":{{" +
                                                  "\"type\":\"104\"," +
                                                  "\"dest\":\"{1}\"," +
                                                  "\"hash\":\"{2}\"" +
                                                  "}}", DID_TRUSTEE, DID_TRUSTEE, hash);

            string attribRequest = await Ledger.BuildGetAttribRequestAsync(DID_TRUSTEE, DID_TRUSTEE, null, hash, null);

            Assert.IsTrue(attribRequest.Contains(expectedResult));
        }
Ejemplo n.º 7
0
 public async Task TestBuildGetAttribRequestWorksForDefaultSubmitter()
 {
     await Ledger.BuildGetAttribRequestAsync(null, DID_TRUSTEE, "endpoint", null, null);
 }