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); }
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); }
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); }
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); }
protected override void ProcessRecord() { try { Bundler bundle = new Bundler(); IResourceProvider resourceProvider = new FileResourceProvider( Name , Output , Ignore , Metadata); bundle.Create(resourceProvider); byte[] p7BData = bundle.Create(resourceProvider); WriteObject(p7BData); } catch (Exception e) { WriteError( new ErrorRecord( e, "Export-Bundle", ErrorCategory.NotSpecified, Name ) ); } }
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); }
public override void Given() { base.Given(); var tenantContextProvider = MockRepository.GenerateMock <ITenantContextProvider>(); tenantContextProvider.Stub(n => n.Language).Return("fr"); TenantContext.SetTenantContextProvider(tenantContextProvider); XmlSerializer serializer = new XmlSerializer(typeof(List <FileResourceProvider.RessourceDictionaryItem>)); using (FileStream stream = new FileStream(Path, FileMode.OpenOrCreate)) { serializer.Serialize(stream, ResourcesToSerialize); stream.Close(); }; fileRessourceProvider = new FileResourceProvider(); }
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); }
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); }
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); }