Пример #1
0
        public void TestAddFileStream()
        {
            byte[] zippedBytes;

            var signingCertificates = TestdataLoader.ReadCertificatesForTest();

            using (var zipStream = new MemoryStream())
                using (var fileStream = File.OpenRead("small.pdf"))
                {
                    using (var asiceBuilder =
                               AsiceBuilder.Create(zipStream, MessageDigestAlgorithm.SHA256, signingCertificates))
                    {
                        asiceBuilder.Should().NotBeNull();

                        asiceBuilder.AddFile(fileStream).Should().NotBeNull().And.BeOfType <AsiceBuilder>();

                        var asiceArchive = asiceBuilder.Build();
                        asiceArchive.Should().NotBeNull();
                    }

                    zippedBytes = zipStream.ToArray();
                }

            LogFixture.GetLog <AsiceBuilderTest>().Info($"Created zip containing {zippedBytes.Length} bytes");
            zippedBytes.Should().HaveCountGreaterThan(0);

            using (var zipStream = new MemoryStream(zippedBytes))
                using (var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Read))
                {
                    zipArchive.Entries.Count.Should().Be(4);
                }
        }
Пример #2
0
        public void VerifyValidCades()
        {
            var            asiceArchive  = TestdataLoader.ReadFromResource("cades-valid.asice");
            IAsiceVerifier asiceVerifier = new AsiceVerifier();

            using (var inputStream = new MemoryStream(asiceArchive))
            {
                var asicManifest = asiceVerifier.Verify(inputStream);
                asicManifest.Should().NotBeNull();
                asicManifest.certificate.Should().NotBeNull();
                asicManifest.certificate.Length.Should().Be(1);
                asicManifest.file.Should().NotBeNull();
                asicManifest.file.Length.Should().Be(2);
                asicManifest.rootfile.Should().BeNull();
            }
        }