예제 #1
0
        public void CreateSignedBundleTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleWithMetadata.p7m";

            var secString = new SecureString();

            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }

            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), _incominganchors)
                    , Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), _privateRedmondPfx),
                    secString);

            byte[] cmsdata = bundle.Create(resourceProvider, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata)));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData, true)));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
        }
예제 #2
0
        public void CreateBundleTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundle.p7m";

            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory()
                                 , _incominganchors)
                    , Path.Combine(Directory.GetCurrentDirectory()
                                   , outputFileName));

            byte[] cmsdata = bundle.Create(resourceProvider);

            //Assert (Using agent bundler resolver code)
            Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata)));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData)));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
        }
예제 #3
0
        public void CreateBundleWithMetadataTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleWithMetadata.p7b";

            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(Path.Combine(Directory.GetCurrentDirectory()
                                                      , _incominganchors),
                                         Path.Combine(Directory.GetCurrentDirectory(), outputFileName)
                                         , null
                                         , @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>");

            byte[] cmsdata = bundle.Create(resourceProvider);

            //Assert (Using agent bundler resolver code)
            Assert.Null(Record.Exception(() => resourceProvider.StoreBundle(cmsdata)));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.Null(Record.Exception(() => anchorBundle = new AnchorBundle(p7BData)));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.NotNull(anchorBundle.Metadata);
            Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata);
        }
예제 #4
0
        public void CreateBundleWithMetadataTest()
        {
            //Arrange
            Bundler bundle = new Bundler();
            const string outputFileName = @"TestBundleWithMetadata.p7b";

            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(Path.Combine(Directory.GetCurrentDirectory()
                                                  , @"Certificates\nhind\IncomingAnchors"),
                                     Path.Combine(Directory.GetCurrentDirectory(), outputFileName)
                                     , null
                                     , @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>");
            byte[] cmsdata = bundle.Create(resourceProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;
            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.NotNull(anchorBundle.Metadata);
            Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata);

        }
예제 #5
0
        public void CreateBundleTest()
        {
            //Arrange
            Bundler bundle = new Bundler();
            const string outputFileName = @"TestBundle.p7m";

            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory()
                    , @"Certificates\nhind\IncomingAnchors")
                    , Path.Combine(Directory.GetCurrentDirectory()
                    , outputFileName));
            byte[] cmsdata = bundle.Create(resourceProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;
            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
            
            
        }
예제 #6
0
        public void CreateSignedBundleWithMetadataTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleSignedWithMetadata.p7m";

            var secString = new SecureString();

            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }


            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(Path.Combine(Directory.GetCurrentDirectory()
                                                      , @"Certificates\nhind\IncomingAnchors"),
                                         Path.Combine(Directory.GetCurrentDirectory(), outputFileName)
                                         , null
                                         , @"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>");
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"),
                    secString);

            byte[] cmsdata = bundle.Create(resourceProvider, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.NotNull(anchorBundle.Metadata);
            Assert.Equal(@"<TrustBundle><Profile>The Good Guys</Profile><DistributionPoint>http://bundler.lab/testComunity/pack.p7b</DistributionPoint></TrustBundle>", anchorBundle.Metadata);
        }
예제 #7
0
        public void CreateSignedBundleIndependentTest()
        {
            //Arrange
            Bundler      bundle         = new Bundler();
            const string outputFileName = @"TestBundleSignedIndependent.p7m";

            var secString = new SecureString();

            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }


            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\nhind\IncomingAnchors")
                    , Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"),
                    secString);

            byte[] cmsdata = bundle.Create(resourceProvider);
            cmsdata = bundle.Sign(cmsdata, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[]       p7BData      = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;

            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
        }
예제 #8
0
        public void CreateSignedBundleTest()
        {
            //Arrange
            Bundler bundle = new Bundler();
            const string outputFileName = @"TestBundleWithMetadata.p7m";

            var secString = new SecureString();
            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }


            //Act
            IResourceProvider resourceProvider =
                new FileResourceProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\nhind\IncomingAnchors")
                    , Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            ISignProvider signProvider =
                new FileSignerProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Certificates\redmond\Private\redmond.pfx"),
                    secString);
            byte[] cmsdata = bundle.Create(resourceProvider, signProvider);

            //Assert (Using agent bundler resolver code)
            Assert.DoesNotThrow(() => resourceProvider.StoreBundle(cmsdata));
            byte[] p7BData = File.ReadAllBytes(Path.Combine(Directory.GetCurrentDirectory(), outputFileName));
            AnchorBundle anchorBundle = null;
            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(p7BData, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);


        }