Esempio n. 1
0
        public void testSMSOutOfBandIInvitationMsg()
        {
            RelationshipV1_0 relationship = Relationship.v1_0(forRelationship, "thread-id");
            JsonObject       msg          = relationship.smsOutOfBandInvitationMsg(TestHelpers.getContext());

            testSMSOutOfBandInvitationMsg(msg, GoalCode.P2P_MESSAGING);
        }
Esempio n. 2
0
        public void testCreateMsg()
        {
            RelationshipV1_0 relationship = Relationship.v1_0();
            JsonObject       msg          = relationship.createMsg(TestHelpers.getContext());

            testCreateMsg(msg, false, false, false);

            RelationshipV1_0 relationship1 = Relationship.v1_0(label);
            JsonObject       msg1          = relationship1.createMsg(TestHelpers.getContext());

            testCreateMsg(msg1, true, false, false);

            RelationshipV1_0 relationship2 = Relationship.v1_0(null, logoUrl);
            JsonObject       msg2          = relationship2.createMsg(TestHelpers.getContext());

            testCreateMsg(msg2, false, true, false);

            RelationshipV1_0 relationship3 = Relationship.v1_0(label, logoUrl);
            JsonObject       msg3          = relationship3.createMsg(TestHelpers.getContext());

            testCreateMsg(msg3, true, true, false);

            RelationshipV1_0 relationship4 = Relationship.v1_0(label, logoUrl, phoneNumber);
            JsonObject       msg4          = relationship4.createMsg(TestHelpers.getContext());

            testCreateMsg(msg4, true, true, true);
        }
Esempio n. 3
0
        public void testOutOfBandIInvitationMsgWithShortInvite()
        {
            RelationshipV1_0 relationship = Relationship.v1_0(forRelationship, "thread-id");
            JsonObject       msg          = relationship.outOfBandInvitationMsg(TestHelpers.getContext(), shortInvite);

            testOutOfBandInvitationMsg(msg, true, GoalCode.P2P_MESSAGING);
        }
Esempio n. 4
0
        public void testSMSConnectionInvitationMsg()
        {
            RelationshipV1_0 relationship = Relationship.v1_0(forRelationship, "thread-id");
            JsonObject       msg          = relationship.smsConnectionInvitationMsg(TestHelpers.getContext());

            testSMSConnectionInvitationMsg(msg);
        }
Esempio n. 5
0
        public void testConnectionInvitationMsgWithShortInvite()
        {
            RelationshipV1_0 relationship = Relationship.v1_0(forRelationship, "thread-id");
            JsonObject       msg          = relationship.connectionInvitationMsg(TestHelpers.getContext(), shortInvite);

            testConnectionInvitationMsg(msg, true);
        }
Esempio n. 6
0
        public void testConnectionInvitationMsg()
        {
            RelationshipV1_0 relationship = Relationship.v1_0(forRelationship, "thread-id");
            JsonObject       msg          = relationship.connectionInvitationMsg(TestHelpers.getContext(), null);

            testConnectionInvitationMsg(msg, false);
        }
Esempio n. 7
0
        void relationshipHandler(RelationshipV1_0 handler)
        {
            // handler for current issuer identifier message
            handlers.addHandler(
                handler,
                (msgName, message) =>
            {
                if ("created".Equals(msgName))
                {
                    App.consolePrintMessage(msgName, message);

                    var json_thread = message.GetValue("~thread")["thid"];

                    _threadId = json_thread;
                    _relDID   = message.GetValue("did");

                    startRelationshipComplete = true;
                }
                else if ("invitation".Equals(msgName))
                {
                    App.consolePrintMessage(msgName, message);

                    string inviteURL = message.GetValue("inviteURL");

                    try
                    {
                        QRCodeGenerator qrGenerator = new QRCodeGenerator();
                        QRCodeData qrCodeData       = qrGenerator.CreateQrCode(inviteURL, QRCodeGenerator.ECCLevel.L);
                        QRCode qrCode      = new QRCode(qrCodeData);
                        Bitmap qrCodeImage = qrCode.GetGraphic(4);
                        qrCodeImage.Save("qrcode.png", ImageFormat.Png);
                    }
                    catch (FileNotFoundException e)
                    {
                        App.consoleOutput(e.Message);
                    }

                    if (!(Environment.GetEnvironmentVariable("HTTP_SERVER_URL") == null))
                    {
                        App.consoleOutput("Open the following URL in your browser and scan presented QR code");
                        App.coloredConsoleOutput(Environment.GetEnvironmentVariable("HTTP_SERVER_URL") + "/dotnet-example-app/qrcode.html");
                    }
                    else
                    {
                        App.consoleOutput("QR code generated at: qrcode.png");
                        App.consoleOutput("Open this file and scan QR code to establish a connection");
                    }

                    invitationComplete = true;
                }
                else
                {
                    nonHandled(msgName, message);
                }
            }
                );
        }
Esempio n. 8
0
        public void testSMSOutOfBandIInvitationMsgWithGoalCode()
        {
            RelationshipV1_0 relationship = Relationship.v1_0(forRelationship, "thread-id");
            JsonObject       msg          = relationship.smsOutOfBandInvitationMsg(
                TestHelpers.getContext(),
                GoalCode.REQUEST_PROOF
                );

            testSMSOutOfBandInvitationMsg(msg, GoalCode.REQUEST_PROOF);
        }
Esempio n. 9
0
        public void testGetMessageType()
        {
            RelationshipV1_0 relationshipProvisioning = Relationship.v1_0(
                "forRelationship",
                "threadId"
                );
            string msgName = "msg name";

            Assert.AreEqual(
                Util.getMessageType(
                    Util.EVERNYM_MSG_QUALIFIER,
                    "relationship",
                    "1.0",
                    msgName
                    ),
                relationshipProvisioning.messageType(msgName)
                );
        }
Esempio n. 10
0
        void DoCreateRelationship()
        {
            // Relationship protocol has two steps
            // 1. create relationship key
            // 2. create invitation

            RelationshipV1_0 relProvisioning = Relationship.v1_0("Faber College");

            // handler for the response to the request to start the Connecting protocol.
            relationshipHandler(relProvisioning);

            relProvisioning.create(context);
            WaitFor(ref startRelationshipComplete, "Waiting to start relationship");

            RelationshipV1_0 relationship = Relationship.v1_0(_relDID, _threadId);

            relationship.connectionInvitation(context);
            WaitFor(ref invitationComplete, "Waiting for invite");
        }
Esempio n. 11
0
        public void testGetThreadId()
        {
            RelationshipV1_0 testProtocol = Relationship.v1_0(label);

            Assert.IsNotNull(testProtocol.getThreadId());
        }