public void TestMethodSendMessage() { DSACryptoServiceProvider mycrypto = new DSACryptoServiceProvider(); DSAParameters publickey = mycrypto.ExportParameters(false); DSACryptoServiceProvider petitmalin = new DSACryptoServiceProvider(); DSAParameters Clemoisi = petitmalin.ExportParameters(false); ASCIIEncoding encoding = new ASCIIEncoding(); ServiceReference1.ServeurChatSoapClient a = new ServiceReference1.ServeurChatSoapClient(); byte[] hash = mycrypto.SignData(encoding.GetBytes("Cuddy")); string message = "je suis jalouse de Cameron"; a.Register("Cuddy", "iluvhouse", hash, publickey.Counter, publickey.G, publickey.J, publickey.P, publickey.Q, publickey.Seed, publickey.X, publickey.Y); byte[] messagesigned = mycrypto.SignData(encoding.GetBytes(message)); Assert.AreEqual(true, a.SendMessage("Cuddy", message, messagesigned)); byte[] hashmoisi = petitmalin.SignData(encoding.GetBytes(message)); Assert.AreEqual(false, a.SendMessage("Cuddy", message, hashmoisi)); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\Message_serialization.xml"); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\User_serialization.xml"); }
public void TestMethodReceiveMessageUnread() { DSACryptoServiceProvider mycrypto = new DSACryptoServiceProvider(); DSAParameters publickey = mycrypto.ExportParameters(false); ASCIIEncoding encoding = new ASCIIEncoding(); byte[] hash = mycrypto.SignData(encoding.GetBytes("Cuddy")); ServiceReference1.ServeurChatSoapClient a = new ServiceReference1.ServeurChatSoapClient(); string message = "je suis jalouse de Cameron"; byte[] messagesigned = mycrypto.SignData(encoding.GetBytes(message)); a.Register("Cuddy", "iluvhouse", hash, publickey.Counter, publickey.G, publickey.J, publickey.P, publickey.Q, publickey.Seed, publickey.X, publickey.Y); a.SendMessage("Cuddy", message, messagesigned); UnitTest.ServiceReference1.Message[] b = a.ReceiveMessageNonRead("Cuddy", hash); Assert.AreEqual("je suis jalouse de Cameron", b[0].Text); //meme commentaire que pour les messages prives Assert.AreEqual("Cuddy", b[0].Auteur); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\Message_serialization.xml"); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\User_serialization.xml"); }
public void TestMethodSendMessage() { DSACryptoServiceProvider mycrypto = new DSACryptoServiceProvider(); DSAParameters publickey = mycrypto.ExportParameters(false); DSACryptoServiceProvider petitmalin = new DSACryptoServiceProvider(); DSAParameters Clemoisi = petitmalin.ExportParameters(false); ASCIIEncoding encoding = new ASCIIEncoding(); ServiceReference1.ServeurChatSoapClient a = new ServiceReference1.ServeurChatSoapClient(); byte[] hash = mycrypto.SignData(encoding.GetBytes("Cuddy")); string message = "je suis jalouse de Cameron"; a.Register("Cuddy", "iluvhouse", hash, publickey.Counter, publickey.G, publickey.J, publickey.P, publickey.Q, publickey.Seed, publickey.X, publickey.Y); byte[] messagesigned = mycrypto.SignData(encoding.GetBytes(message)); Assert.AreEqual(true, a.SendMessage("Cuddy", message, messagesigned)); byte[] hashmoisi = petitmalin.SignData(encoding.GetBytes(message)); Assert.AreEqual(false, a.SendMessage("Cuddy",message,hashmoisi)); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\Message_serialization.xml"); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\User_serialization.xml"); }
public void TestMethodReceiveAllMessage() { DSACryptoServiceProvider mycrypto = new DSACryptoServiceProvider(); DSAParameters publickey = mycrypto.ExportParameters(false); ASCIIEncoding encoding = new ASCIIEncoding(); byte[] hash = mycrypto.SignData(encoding.GetBytes("Cuddy")); ServiceReference1.ServeurChatSoapClient a = new ServiceReference1.ServeurChatSoapClient(); string message = "je suis jalouse de Cameron"; byte[] messagesigned = mycrypto.SignData(encoding.GetBytes(message)); a.Register("Cuddy", "iluvhouse", hash, publickey.Counter, publickey.G, publickey.J, publickey.P, publickey.Q, publickey.Seed, publickey.X, publickey.Y); a.SendMessage("Cuddy", message, messagesigned); UnitTest.ServiceReference1.Message[] b = a.ReceiveMessageNonRead("Cuddy", hash); UnitTest.ServiceReference1.Message[] c = a.ReceiveAllMessage("Cuddy", hash); Assert.AreEqual("je suis jalouse de Cameron", c[0].Text); //identique a tous les reception de message[] Assert.AreEqual("Cuddy", c[0].Auteur); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\Message_serialization.xml"); File.Delete("C:\\Program Files\\Common Files\\microsoft shared\\DevServer\\10.0\\User_serialization.xml"); }