Beispiel #1
0
        public async Task When_package_is_file_can_generate_executable_and_decrypt()
        {
            using (var sourcePackageDirectory = TempDirectory.InBaseDirectory())
                using (var decryptedPackageDirectory = TempDirectory.InBaseDirectory())
                    using (var files = new TempFileCollection(AppDomain.CurrentDomain.BaseDirectory))
                    {
                        string selfExtractorPath = files.AddFileWithExtension("exe");
                        string encryptedContent  = $"Encrypted content {Guid.NewGuid()}";
                        sourcePackageDirectory.CreateTextFile("file.txt", encryptedContent);
                        files.AddFile("decryption.log");

                        string archivedPackage = files.AddFileWithExtension("zip");
                        ZipFile.CreateFromDirectory(sourcePackageDirectory.Path, archivedPackage, CompressionLevel.NoCompression, false);

                        ProcessResult encryptionResult = await new eCryptRunner()
                                                         .RunAsync(selfExtractorPath, TestKeys.PublicKeyPath, archivedPackage);
                        ProcessResult decryptionResult = await new SelfExtractorRunner(selfExtractorPath)
                                                         .RunAsync(TestKeys.PrivateKeyPath, decryptedPackageDirectory.Path);

                        encryptionResult.Should().BeSuccessfullProcessResult();
                        decryptionResult.Should().BeSuccessfullProcessResult();
                        decryptedPackageDirectory.Files.Count().Should().Be(1);
                        decryptedPackageDirectory.Files.Single().Should().BePathToFileWithContent(encryptedContent);
                    }
        }