Exemplo n.º 1
0
            public void client_encryption_infos_should_match()
            {
                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);

                path = path.Replace("file:\\", "");

                MHostingEnvironment.ApplicationPhysicalPathGet = () => path;

                string inFile  = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\999900000-IN.config";
                string outFile = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "\\999900000-OUT.config";

                if (File.Exists(inFile))
                {
                    File.Delete(inFile);
                }

                if (File.Exists(outFile))
                {
                    File.Delete(outFile);
                }


                string inKey1 = service.InboundKeyPair.PublicKey.Substring(0, (service.InboundKeyPair.PublicKey.Length / 2));
                string inKey2 = service.InboundKeyPair.PublicKey.Substring(inKey1.Length, (service.InboundKeyPair.PublicKey.Length - inKey1.Length));

                string outKey1 = service.OutboundKeyPair.PrivateKey.Substring(0, (service.OutboundKeyPair.PrivateKey.Length / 2));
                string outKey2 = service.OutboundKeyPair.PrivateKey.Substring(outKey1.Length, (service.OutboundKeyPair.PrivateKey.Length - outKey1.Length));

                using (StreamWriter writer = new StreamWriter(inFile))
                {
                    writer.WriteLine(inKey2);
                }

                using (StreamWriter writer = new StreamWriter(outFile))
                {
                    writer.WriteLine(outKey2);
                }


                EncryptionInfo ei1 = servicesService.GetClientStandardEncryptionInfo(service);
                EncryptionInfo ei2 = controlService.GetStandardEncryptionInfo();

                Assert.IsTrue(ei1.Equals(ei2));
            }