Ejemplo n.º 1
0
        public void toJson_0_2()
        {
            var env = new Env();

            Context context;

            using (TestWallet testWallet = new TestWallet(env.walletName, env.walletKey))
            {
                try
                {
                    JsonObject config = new JsonObject();
                    config.Add("walletName", env.walletName);
                    config.Add("walletKey", env.walletKey);
                    config.Add("verityUrl", env.verityUrl);
                    config.Add("verityPublicDID", testWallet.getVerityPublicDID());
                    config.Add("verityPublicVerKey", testWallet.getVerityPublicVerkey());
                    config.Add("domainDID", testWallet.getVerityPairwiseDID());
                    config.Add("verityAgentVerKey", testWallet.getVerityPairwiseVerkey());
                    config.Add("sdkVerKeyId", testWallet.getSdkPairwiseVerkey());
                    config.Add("sdkVerKey", testWallet.getSdkPairwiseVerkey());
                    config.Add("endpointUrl", env.endpointUrl);
                    config.Add("version", "0.2");
                    context = ContextBuilder.fromJson(config).build();
                    TestHelpers.assertEqualsJSONObject(withNewKeys(config), context.toJson());

                    context.CloseWallet();
                }
                catch (Exception e)
                {
                    Assert.Fail(e.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public void V01toV02Test()
        {
            var env = new Env();

            using (TestWallet ignored = new TestWallet(env.walletName, env.walletKey))
            {
                string v01Str = "{\n" +
                                "  \"verityPublicVerkey\": \"ETLgZKeQEKxBW7gXA6FBn7nBwYhXFoogZLCCn5EeRSQV\",\n" +
                                "  \"verityPairwiseDID\": \"NTvSuSXzygyxWrF3scrhdc\",\n" +
                                "  \"verityUrl\": \"https://vas-team1.pdev.evernym.com\",\n" +
                                "  \"verityPairwiseVerkey\": \"ChXRWjQdrrLyksbPQZfaS3JekA4xLgD5Jg7GzXhc9zqE\",\n" +
                                "  \"walletName\": \"" + env.walletName + "\",\n" +
                                "  \"walletKey\": \"" + env.walletKey + "\",\n" +
                                "  \"sdkPairwiseVerkey\": \"HZ3Ak6pj9ryFASKbA9fpwqjVh42F35UDiCLQ13J58Xoh\",\n" +
                                "  \"verityPublicDID\": \"Rgj7LVEonrMzcRC1rhkx76\",\n" +
                                "  \"sdkPairwiseDID\": \"XNRkA8tboikwHD3x1Yh7Uz\"\n" +
                                "}";
                Context ctx = ContextBuilder.fromJson(v01Str).build();
                ctx.CloseWallet();

                Assert.AreEqual("NTvSuSXzygyxWrF3scrhdc", ctx.DomainDID());
                Assert.AreEqual("ChXRWjQdrrLyksbPQZfaS3JekA4xLgD5Jg7GzXhc9zqE", ctx.VerityAgentVerKey());
                Assert.AreEqual("HZ3Ak6pj9ryFASKbA9fpwqjVh42F35UDiCLQ13J58Xoh", ctx.SdkVerKey());
                Assert.AreEqual("XNRkA8tboikwHD3x1Yh7Uz", ctx.SdkVerKeyId());
                Assert.AreEqual("0.2", ctx.Version());
            }
        }
Ejemplo n.º 3
0
        public void shouldCorrectlyParseConfig_0_2()
        {
            var env = new Env();

            Context context;

            using (TestWallet testWallet = new TestWallet(env.walletName, env.walletKey))
            {
                try
                {
                    JsonObject config = new JsonObject();
                    config.Add("walletName", env.walletName);
                    config.Add("walletKey", env.walletKey);
                    config.Add("endpointUrl", env.endpointUrl);
                    config.Add("verityUrl", env.verityUrl);
                    config.Add("verityPublicDID", testWallet.getVerityPublicDID());
                    config.Add("verityPublicVerKey", testWallet.getVerityPublicVerkey());
                    config.Add("domainDID", testWallet.getVerityPairwiseDID());
                    config.Add("verityAgentVerKey", testWallet.getVerityPairwiseVerkey());
                    config.Add("sdkVerKeyId", testWallet.getSdkPairwiseVerkey());
                    config.Add("sdkVerKey", testWallet.getSdkPairwiseVerkey());
                    config.Add("version", ContextConstants.V_0_2);
                    context = ContextBuilder.fromJson(config).build();

                    var cfg_s = "{\"id\":\"" + env.walletName + "\"}";
                    var cfg   = context.WalletConfig().config().Replace(" ", "");
                    Assert.AreEqual(cfg_s, cfg);

                    var cr_s = "{\"key\":\"" + env.walletKey + "\"}";
                    var cr   = context.WalletConfig().credential().Replace(" ", "");
                    Assert.AreEqual(cr_s, cr);

                    Assert.AreEqual(env.verityUrl, context.VerityUrl());
                    Assert.AreEqual(env.endpointUrl, context.EndpointUrl());
                    Assert.AreEqual(ContextConstants.V_0_2, context.Version());
                    Assert.AreEqual(testWallet.getVerityPublicVerkey(), context.VerityPublicVerKey());
                    Assert.AreEqual(testWallet.getVerityPairwiseVerkey(), context.VerityAgentVerKey());
                    Assert.AreEqual(testWallet.getVerityPairwiseDID(), context.DomainDID());
                    Assert.AreEqual(testWallet.getSdkPairwiseVerkey(), context.SdkVerKey());
                    Assert.IsNotNull(context.WalletHandle());

                    context.CloseWallet();
                }
                catch (Exception e)
                {
                    Assert.Fail(e.Message);
                }
            }
        }
Ejemplo n.º 4
0
        public void simpleBuild()
        {
            var env = new Env();

            using (TestWallet testWallet = new TestWallet(env.walletName, env.walletKey))
            {
                Context c = ContextBuilder
                            .blank()
                            .walletConfig(testWallet)
                            .sdkVerKey(env.verkey1)
                            .build();

                c.CloseWallet();

                Assert.AreEqual(env.verkey1, c.SdkVerKey());
            }
        }
Ejemplo n.º 5
0
        public static Context getContext(string seed)
        {
            var env = new Env();

            TestWallet testWallet = new TestWallet(env.walletName, env.walletKey, seed);

            return(ContextBuilder
                   .blank()
                   .walletConfig(testWallet)
                   .verityUrl(env.verityUrl)
                   .verityPublicDID(testWallet.getVerityPublicVerkey())
                   .verityPublicVerKey(testWallet.getVerityPublicVerkey())
                   .domainDID(testWallet.getVerityPairwiseDID())
                   .verityAgentVerKey(testWallet.getVerityPairwiseVerkey())
                   .sdkVerKeyId(testWallet.getSdkPairwiseDID())
                   .sdkVerKey(testWallet.getSdkPairwiseVerkey())
                   .endpointUrl(env.endpointUrl)
                   .build());
        }
Ejemplo n.º 6
0
        public void multiClosedBuild()
        {
            var env = new Env();

            using (TestWallet testWallet = new TestWallet(env.walletName, env.walletKey))
            {
                Context c = ContextBuilder
                            .blank()
                            .walletConfig(testWallet)
                            .build();

                Wallet test = c.WalletHandle();
                c.CloseWallet();

                Context c2 = c.ToContextBuilder()
                             .verityUrl("http://example.com")
                             .build();
                Assert.IsTrue(test != c2.WalletHandle()); // New wallet handle
                c2.CloseWallet();
            }
        }
Ejemplo n.º 7
0
        public void fromScratch()
        {
            var env = new Env();

            using (TestWallet testWallet = new TestWallet(env.walletName, env.walletKey))
            {
                Did testDid = new Did("CV65RFpeCtPu82hNF9i61G", "7G3LhXFKXKTMv7XGx1Qc9wqkMbwcU2iLBHL8x1JXWWC2");

                Context c = ContextBuilder.scratchContext(testWallet, "http://wwww.example.com", testDid, null);

                c.SdkVerKeyId();
                c.SdkVerKey();

                try
                {
                    c.DomainDID();
                    Assert.Fail("Should throw UndefinedContextException");
                }
                catch (UndefinedContextException ignored) {
                    var s = ignored.Message; // Fix build warning
                }

                try
                {
                    c.VerityAgentVerKey();
                    Assert.Fail("Should throw UndefinedContextException");
                }
                catch (UndefinedContextException ignored) {
                    var s = ignored.Message; // Fix build warning
                }

                Assert.AreEqual("7G3LhXFKXKTMv7XGx1Qc9wqkMbwcU2iLBHL8x1JXWWC2", c.VerityPublicVerKey());

                c.CloseWallet();
            }
        }