예제 #1
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            Debug.Log("Running ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()");
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "enigma", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest  = unitTest;

            string channel = "hello_my_channel";
            object message = new SecretCustomClass();

            messageObjectForEncryptPublish = new JsonFXDotNet().SerializeToJsonString(message);

            pubnub.Publish <string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
            mreEncryptObjectPublish.WaitOne(310 * 1000);
            Thread.Sleep(1000);

            if (!isEncryptObjectPublished)
            {
                UUnitAssert.True(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }
예제 #2
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "enigma", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";

            pubnub.PubnubUnitTest = unitTest;

            string channel = "my/channel";
            object message = new SecretCustomClass();

            messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

            pubnub.Publish <string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback);
            mreEncryptObjectPublish.WaitOne(310 * 1000);

            if (!isEncryptObjectPublished)
            {
                Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory <string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback);
                mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }
예제 #3
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "enigma", false);

            PubnubUnitTest unitTest = new PubnubUnitTest();

            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName  = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";

            pubnub.PubnubUnitTest = unitTest;

            string channel = "hello_my_channel";
            object message = new SecretCustomClass();

            messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

            pubnub.Publish <string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
            mreEncryptObjectPublish.WaitOne(manualResetEventsWaitTimeout);

            if (!isEncryptObjectPublished)
            {
                Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                Thread.Sleep(1000);
                pubnub.DetailedHistory <string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                mreEncryptObjectDetailedHistory.WaitOne(manualResetEventsWaitTimeout);
                Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }
예제 #4
0
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
			Debug.Log("Running ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()");
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub("demo", "demo", "", "enigma", false);
            
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";

            pubnub.PubnubUnitTest = unitTest;

            string channel = "my/channel";
            object message = new SecretCustomClass();
            messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);

            pubnub.Publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback);
            mreEncryptObjectPublish.WaitOne(310 * 1000);

            if (!isEncryptObjectPublished)
            {
                UUnitAssert.True(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback);
                mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }
예제 #5
0
        public static void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfoWithSSL()
        {
            server.ClearRequests();

            bool receivedPublishMessage = false;
            long publishTimetoken       = 0;

            string channel = "hello_my_channel";
            object message = new SecretCustomClass();

            PNConfiguration config = new PNConfiguration
            {
                PublishKey   = PubnubCommon.PublishKey,
                SubscribeKey = PubnubCommon.SubscribeKey,
                CipherKey    = "enigma",
                Uuid         = "mytestuuid",
                Secure       = true
            };

            server.RunOnHttps(true);

            pubnub = createPubNubInstance(config);

            string expected = "[1,\"Sent\",\"14715322883933786\"]";

            server.AddRequest(new Request()
                              .WithMethod("GET")
                              .WithPath(String.Format("/publish/{0}/{1}/0/{2}/0/{3}", PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, channel, "%22nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2%22"))
                              .WithParameter("pnsdk", PubnubCommon.EncodedSDK)
                              .WithParameter("requestid", "myRequestId")
                              .WithParameter("uuid", config.Uuid)
                              .WithResponse(expected)
                              .WithStatusCode(System.Net.HttpStatusCode.OK));

            manualResetEventWaitTimeout = 310 * 1000;

            ManualResetEvent publishManualEvent = new ManualResetEvent(false);

            pubnub.Publish().Channel(channel).Message(message)
            .Async(new PNPublishResultExt((r, s) =>
            {
                if (r != null && s.StatusCode == 200 && !s.Error)
                {
                    publishTimetoken       = r.Timetoken;
                    receivedPublishMessage = true;
                }
                publishManualEvent.Set();
            }));
            publishManualEvent.WaitOne(manualResetEventWaitTimeout);

            if (!receivedPublishMessage)
            {
                Assert.IsTrue(receivedPublishMessage, "Encrypt Object Publish Failed with SSL");
            }
            else
            {
                receivedPublishMessage = false;

                if (!PubnubCommon.EnableStubTest)
                {
                    Thread.Sleep(1000);
                }

                expected = "[[\"nQTUCOeyWWgWh5NRLhSlhIingu92WIQ6RFloD9rOZsTUjAhD7AkMaZJVgU7l28e2\"],14715325858469956,14715325858469956]";

                server.AddRequest(new Request()
                                  .WithMethod("GET")
                                  .WithPath(String.Format("/v2/history/sub-key/{0}/channel/{1}", PubnubCommon.SubscribeKey, channel))
                                  .WithParameter("count", "100")
                                  .WithParameter("end", "14715325228931129")
                                  .WithParameter("pnsdk", PubnubCommon.EncodedSDK)
                                  .WithParameter("requestid", "myRequestId")
                                  .WithParameter("uuid", config.Uuid)
                                  .WithResponse(expected)
                                  .WithStatusCode(System.Net.HttpStatusCode.OK));

                ManualResetEvent historyManualEvent = new ManualResetEvent(false);

                pubnub.History().Channel(channel)
                .End(PubnubCommon.EnableStubTest ? 14715325228931129 : publishTimetoken)
                .Count(100)
                .Reverse(false)
                .IncludeTimetoken(false)
                .Async(new PNHistoryResultExt(
                           (r, s) =>
                {
                    Console.WriteLine(pubnub.JsonPluggableLibrary.SerializeToJsonString(r));
                    receivedPublishMessage = true;
                    historyManualEvent.Set();
                }));

                historyManualEvent.WaitOne(manualResetEventWaitTimeout);

                Assert.IsTrue(receivedPublishMessage, "Unable to match the successful encrypt object Publish with SSL");
            }
            pubnub.Destroy();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
        }
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfoWithSSL()
        {
            isEncryptObjectPublished = false;
            isEncryptObjectDetailedHistory = false;

            pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "enigma", true);

            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";

            pubnub.PubnubUnitTest = unitTest;

            string channel = "hello_my_channel";
            object message = new SecretCustomClass();
            //messageObjectForEncryptPublish = JsonConvert.SerializeObject(message);
            messageObjectForEncryptPublish = pubnub.JsonPluggableLibrary.SerializeToJsonString(message);

            mreEncryptObjectPublish = new ManualResetEvent(false);
            pubnub.Publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
            manualResetEventsWaitTimeout = (unitTest.EnableStubTest) ? 1000 : 310 * 1000;
            mreEncryptObjectPublish.WaitOne(manualResetEventsWaitTimeout);

            if (!isEncryptObjectPublished)
            {
                Assert.IsTrue(isEncryptObjectPublished, "Encrypt Object Publish with SSL Failed");
            }
            else
            {
                Thread.Sleep(1000);
                mreEncryptObjectDetailedHistory = new ManualResetEvent(false);
                pubnub.DetailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                mreEncryptObjectDetailedHistory.WaitOne(manualResetEventsWaitTimeout);

                Assert.IsTrue(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish with SSL");
            }
            pubnub.EndPendingRequests();
            pubnub.PubnubUnitTest = null;
            pubnub = null;
        }
        public void ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()
        {
			Debug.Log("Running ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo()");
            isEncryptObjectPublished = false;
            Pubnub pubnub = new Pubnub(PubnubCommon.PublishKey, PubnubCommon.SubscribeKey, "", "enigma", false);
			
            PubnubUnitTest unitTest = new PubnubUnitTest();
            unitTest.TestClassName = "WhenAMessageIsPublished";
            unitTest.TestCaseName = "ThenEncryptObjectPublishShouldReturnSuccessCodeAndInfo";
            pubnub.PubnubUnitTest = unitTest;

            string channel = "hello_my_channel";
            object message = new SecretCustomClass();
            messageObjectForEncryptPublish = new JsonFXDotNet().SerializeToJsonString(message);

            pubnub.Publish<string>(channel, message, ReturnSuccessEncryptObjectPublishCodeCallback, DummyErrorCallback);
            mreEncryptObjectPublish.WaitOne(310 * 1000);
			Thread.Sleep(1000);

            if (!isEncryptObjectPublished)
            {
                UUnitAssert.True(isEncryptObjectPublished, "Encrypt Object Publish Failed");
            }
            else
            {
                pubnub.DetailedHistory<string>(channel, -1, encryptObjectPublishTimetoken, -1, false, CaptureEncryptObjectDetailedHistoryCallback, DummyErrorCallback);
                mreEncryptObjectDetailedHistory.WaitOne(310 * 1000);
                UUnitAssert.True(isEncryptObjectDetailedHistory, "Unable to match the successful encrypt object Publish");
            }
        }