public void TestObjectEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //create an object Object obj = new Object(); //serialize string strObj = Common.Serialize(obj); //encrypt string encrypted = pubnubCrypto.Encrypt(strObj); Assert.True(("IDjZE9BHSjcX67RddfCYYg==").Equals(encrypted)); }
public void TestMyObjectEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //create an object of the custom class CustomClass cc = new CustomClass(); //serialize it string result = Common.Serialize(cc); //encrypt it string encrypted = pubnubCrypto.Encrypt(result); Assert.AreEqual("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=", encrypted); }
public void TestArrayEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //create an empty array object object[] objArr = { }; string strArr = Common.Serialize(objArr); //Encrypt string encrypted = pubnubCrypto.Encrypt(strArr); Assert.True(("Ns4TB41JjT2NCXaGLWSPAQ==").Equals(encrypted)); }
public void TestUnicodeCharsEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); string message = "漢語"; message = Common.Serialize(message); Console.WriteLine(message); string encrypted = pubnubCrypto.Encrypt(message); Console.WriteLine(encrypted); Assert.That(("+BY5/miAA8aeuhVl4d13Kg==").Equals(encrypted)); }
//[Test] public void Test0ForComplexMessage2() { Pubnub pubnub = new Pubnub( "demo", "demo", "", "enigma", false ); string channel = "hello_world"; //pubnub.NonSubscribeTimeout = int.Parse (operationTimeoutInSeconds); object message = new PubnubDemoObject(); Common common = new Common(); DeliveryStatus = false; pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForEncryptedComplexMessage2"); pubnub.Publish <string>(channel, message, DisplayReturnMessageECM2, DisplayErrorMessageECM2); Pubnub pubnub2 = new Pubnub( "demo", "demo", "", "", true ); object message2 = new PubnubDemoObject(); string json = Common.Serialize(message2); DeliveryStatus = false; pubnub2.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl"); pubnub2.Publish(channel, message2, DisplayReturnMessageECM2Ssl, DisplayErrorMessageECM2Ssl); //common.WaitForResponse (); Pubnub pubnub3 = new Pubnub( "demo", "demo", "", "", false ); object message3 = new PubnubDemoObject(); //object message = new CustomClass2(); string json3 = Common.Serialize(message3); pubnub3.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2"); pubnub3.Publish <string> (channel, message3, DisplayReturnMessage, DisplayErrorMessage); }
public void TestGermanCharsEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); string message = "ÜÖ"; message = Common.Serialize(message); Console.WriteLine(message); string encrypted = pubnubCrypto.Encrypt(message); Console.WriteLine(encrypted); Assert.True(("stpgsG1DZZxb44J7mFNSzg==").Equals(encrypted)); }
public void TestPubNubEncryption1() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //non serialized string string message = "Pubnub Messaging API 1"; //serialize message = Common.Serialize(message); //encrypt string encrypted = pubnubCrypto.Encrypt(message); Assert.True(("f42pIQcWZ9zbTbH8cyLwByD/GsviOE0vcREIEVPARR0=").Equals(encrypted)); }
public void TestPubNubEncryption2() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string message = "Pubnub Messaging API 2"; //serialize the message message = Common.Serialize(message); //encrypt string encrypted = pubnubCrypto.Encrypt(message); Assert.True(("f42pIQcWZ9zbTbH8cyLwB/tdvRxjFLOYcBNMVKeHS54=").Equals(encrypted)); }
//[Test] public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2() { Pubnub pubnub = new Pubnub( Common.PublishKey, Common.SubscribeKey, "", "", false ); string channel = "hello_world"; object message = new PubnubDemoObject(); //object message = new CustomClass2(); string json = Common.Serialize(message); Common common = new Common(); pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2"); DeliveryStatus = false; pubnub.Publish <string> (channel, message, DisplayReturnMessage, DisplayErrorMessage); //wait till the response is received from the server common.WaitForResponse(); //while (!DeliveryStatus) //; if (common.Response != null) { IList <object> fields = common.Response as IList <object>; string sent = fields [1].ToString(); string one = fields [0].ToString(); Assert.AreEqual("Sent", sent); Assert.AreEqual("1", one); } else { Assert.Fail("Null response"); } /*if (Response != null) { #if(!UNITY_ANDROID) * IList<object> fields = Response as IList<object>; #else * UnityEngine.Debug.Log ("cm2: " + Response.ToString ()); * IList<object> fields = Response as IList<object>; #endif * string sent = fields [1].ToString (); * string one = fields [0].ToString (); * Assert.AreEqual ("Sent", sent); * Assert.AreEqual ("1", one); * } else { * Assert.Fail ("Null response"); * }*/ }
public void TestYayEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //deserialized string string message = "yay!"; //serialize the string message = Common.Serialize(message); Console.WriteLine(message); //Encrypt string encrypted = pubnubCrypto.Encrypt(message); Assert.True(("Wi24KS4pcTzvyuGOHubiXg==").Equals(encrypted)); }
public void TestMyObjectEncryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //create an object of the custom class CustomClass cc = new CustomClass(); //serialize it string result = Common.Serialize(cc); //encrypt it string encrypted = pubnubCrypto.Encrypt(result); UnityEngine.Debug.Log("encrypted:" + encrypted); UnityEngine.Debug.Log("result:" + result); Assert.True(("Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE=").Equals(encrypted)); }
public void TestObjectDecryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string message = "IDjZE9BHSjcX67RddfCYYg=="; //Decrypt string decrypted = pubnubCrypto.Decrypt(message); //create an object Object obj = new Object(); //Serialize the object string result = Common.Serialize(obj); Assert.True((decrypted).Equals(result)); }
public void TestMyObjectDecryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="; //Decrypt string decrypted = pubnubCrypto.Decrypt(message); //create an object of the custom class CustomClass cc = new CustomClass(); //Serialize it string result = Common.Serialize(cc); Assert.AreEqual(decrypted, result); }
public void TestArrayDecryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Input the deserialized string string message = "Ns4TB41JjT2NCXaGLWSPAQ=="; //decrypt string decrypted = pubnubCrypto.Decrypt(message); //create a serialized object object[] objArr = { }; string result = Common.Serialize(objArr); //compare the serialized object and the return of the Decrypt method Assert.True((result).Equals(decrypted)); }
public void TestMyObjectDecryption() { PubnubCrypto pubnubCrypto = new PubnubCrypto("enigma"); //Deserialized string message = "Zbr7pEF/GFGKj1rOstp0tWzA4nwJXEfj+ezLtAr8qqE="; //Decrypt string decrypted = pubnubCrypto.Decrypt(message); //create an object of the custom class CustomClass cc = new CustomClass(); //Serialize it string result = Common.Serialize(cc); UnityEngine.Debug.Log("decrypted:" + decrypted); UnityEngine.Debug.Log("result:" + result); Assert.True((decrypted).Equals(result)); }
//[Test] public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl() { Pubnub pubnub = new Pubnub( Common.PublishKey, Common.SubscribeKey, "", "", true ); string channel = "hello_world"; object message = new PubnubDemoObject(); //object message = new CustomClass2(); string json = Common.Serialize(message); Common common = new Common(); pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl"); common.DeliveryStatus = false; common.Response = null; pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage); //wait till the response is received from the server common.WaitForResponse(); if (common.Response != null) { IList <object> fields = common.Response as IList <object>; string sent = fields [1].ToString(); string one = fields [0].ToString(); Assert.AreEqual("Sent", sent); Assert.AreEqual("1", one); } else { Assert.Fail("Null response"); } /*if (ResponseECM2Ssl != null) { * IList<object> fields = ResponseECM2Ssl as IList<object>; * string sent = fields [1].ToString (); * string one = fields [0].ToString (); * Assert.AreEqual ("Sent", sent); * Assert.AreEqual ("1", one); * } else { * Assert.Fail ("Null response"); * }*/ }
public void ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl() { Pubnub pubnub = new Pubnub( Common.PublishKey, Common.SubscribeKey, "", "", true ); string channel = "hello_world"; object message = new PubnubDemoObject(); //object message = new CustomClass2(); string json = Common.Serialize(message); Common common = new Common(); pubnub.PubnubUnitTest = common.CreateUnitTestInstance("WhenAMessageIsPublished", "ThenItShouldReturnSuccessCodeAndInfoForComplexMessage2WithSsl"); common.DeliveryStatus = false; common.Response = null; pubnub.Publish(channel, message, common.DisplayReturnMessage, common.DisplayReturnMessage); //wait till the response is received from the server common.WaitForResponse(45); if (common.Response != null) { Console.WriteLine(" common.Response" + common.Response); IList <object> fields = common.Response as IList <object>; string sent = fields [1].ToString(); string one = fields [0].ToString(); Assert.True(("Sent").Equals(sent)); Assert.True(("1").Equals(one)); } else { Assert.Fail("Null response"); } pubnub.EndPendingRequests(); }