Fix build on Linux.
This commit is contained in:
parent
ad9d75a599
commit
76cbb57f9a
131
makefile.shade
131
makefile.shade
|
|
@ -1,45 +1,86 @@
|
|||
use assembly='WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
|
||||
use namespace='System.IO.Packaging'
|
||||
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
||||
|
||||
#nupkg-patch target='compile'
|
||||
@{
|
||||
var packagePaths = Files.Include("artifacts/build/**/Microsoft.AspNet.DataProtection.SystemWeb.*.nupkg")
|
||||
.Exclude("**/*.symbols.nupkg");
|
||||
foreach (var packagePath in packagePaths)
|
||||
{
|
||||
using (var package = Package.Open(packagePath, FileMode.Open, FileAccess.ReadWrite))
|
||||
{
|
||||
CreatePartFromFile(
|
||||
package,
|
||||
@"src\Microsoft.AspNet.DataProtection.SystemWeb\web.config.transform",
|
||||
@"content\net451\web.config.transform");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
functions
|
||||
@{
|
||||
PackagePart CreatePartFromFile(
|
||||
Package destination,
|
||||
string sourceFileName,
|
||||
string partUriString)
|
||||
{
|
||||
var partUri = PackUriHelper.CreatePartUri(new Uri(partUriString, UriKind.Relative));
|
||||
var packagePart = destination.CreatePart(partUri, "application/octet", CompressionOption.Maximum);
|
||||
|
||||
using (var sourceStream = File.OpenRead(sourceFileName))
|
||||
using (var stream = packagePart.GetStream())
|
||||
{
|
||||
sourceStream.CopyTo(stream);
|
||||
}
|
||||
|
||||
return packagePart;
|
||||
}
|
||||
}
|
||||
use assembly='WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
|
||||
use namespace='System.IO.Packaging'
|
||||
use import="Environment"
|
||||
|
||||
var VERSION='0.1'
|
||||
var FULL_VERSION='0.1'
|
||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
||||
|
||||
use-standard-lifecycle
|
||||
k-standard-goals
|
||||
|
||||
var Configuration2='${E("Configuration")}'
|
||||
var ROOT = '${Directory.GetCurrentDirectory()}'
|
||||
var BUILD_DIR2 = '${Path.Combine(ROOT, "build")}'
|
||||
|
||||
#build-compile target='compile' if='!IsWindows && !IsBuildV2 && Directory.Exists("src")'
|
||||
@{
|
||||
var projectFiles = Files.Include("src/**/project.json")
|
||||
.Exclude("src/Microsoft.AspNet.DataProtection.SystemWeb/project.json")
|
||||
.ToList();
|
||||
|
||||
if (ShouldRunInParallel)
|
||||
{
|
||||
Parallel.ForEach(projectFiles, projectFile => DnuPack(projectFile, BUILD_DIR2, Configuration2));
|
||||
}
|
||||
else
|
||||
{
|
||||
projectFiles.ForEach(projectFile => DnuPack(projectFile, BUILD_DIR2, Configuration2));
|
||||
}
|
||||
|
||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR2, "*/*.nupkg")))
|
||||
{
|
||||
File.Copy(nupkg, Path.Combine(BUILD_DIR2, Path.GetFileName(nupkg)), true);
|
||||
}
|
||||
}
|
||||
|
||||
#build-compile target='compile' if='!IsWindows && IsBuildV2'
|
||||
@{
|
||||
if (Directory.Exists("src"))
|
||||
{
|
||||
var projects = Files.Include("src/*")
|
||||
.Exclude("src/Microsoft.AspNet.DataProtection.SystemWeb")
|
||||
.ToList();
|
||||
|
||||
DnuPack(string.Join(";", projects), BUILD_DIR2, Configuration2);
|
||||
|
||||
foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR2, "*/*.nupkg")))
|
||||
{
|
||||
File.Copy(nupkg, Path.Combine(BUILD_DIR2, Path.GetFileName(nupkg)), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (Directory.Exists("test"))
|
||||
{
|
||||
DnuBuild("test/*", Configuration2);
|
||||
}
|
||||
}
|
||||
|
||||
functions
|
||||
@{
|
||||
PackagePart CreatePartFromFile(
|
||||
Package destination,
|
||||
string sourceFileName,
|
||||
string partUriString)
|
||||
{
|
||||
var partUri = PackUriHelper.CreatePartUri(new Uri(partUriString, UriKind.Relative));
|
||||
var packagePart = destination.CreatePart(partUri, "application/octet", CompressionOption.Maximum);
|
||||
|
||||
using (var sourceStream = File.OpenRead(sourceFileName))
|
||||
using (var stream = packagePart.GetStream())
|
||||
{
|
||||
sourceStream.CopyTo(stream);
|
||||
}
|
||||
|
||||
return packagePart;
|
||||
}
|
||||
|
||||
bool IsWindows
|
||||
{
|
||||
get
|
||||
{
|
||||
var p = (int)Environment.OSVersion.Platform;
|
||||
return (p != 4) && (p != 6) && (p != 128);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("Microsoft.AspNet.Cryptography.KeyDerivation.Test")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNet.DataProtection")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNet.DataProtection.Abstractions.Test")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNet.DataProtection.Extensions.Test")]
|
||||
[assembly: InternalsVisibleTo("Microsoft.AspNet.DataProtection.Test")]
|
||||
[assembly: AssemblyMetadata("Serviceable", "True")]
|
||||
[assembly: NeutralResourcesLanguage("en-US")]
|
||||
|
|
|
|||
|
|
@ -20,5 +20,8 @@
|
|||
},
|
||||
"compilationOptions": {
|
||||
"warningsAsErrors": true
|
||||
},
|
||||
"packInclude": {
|
||||
"content/net451/": "web.config.transform"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.AspNet.DataProtection.Test.Shared;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -36,6 +37,7 @@ namespace Microsoft.AspNet.DataProtection
|
|||
|
||||
[ConditionalFact]
|
||||
[ConditionalRunTestOnlyIfLocalAppDataAvailable]
|
||||
[ConditionalRunTestOnlyOnWindows]
|
||||
public void System_UsesProvidedDirectory_WithConfigurationCallback()
|
||||
{
|
||||
WithUniqueTempDirectory(directory =>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
"dependencies": {
|
||||
"Microsoft.AspNet.DataProtection.Abstractions": "1.0.0-*",
|
||||
"Microsoft.AspNet.DataProtection.Extensions": "1.0.0-*",
|
||||
"Microsoft.AspNet.DataProtection.Test.Shared": { "type": "build", "version": "" },
|
||||
"Microsoft.AspNet.Testing": "1.0.0-*",
|
||||
"Moq": "4.2.1312.1622",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
|
|
|
|||
|
|
@ -130,9 +130,9 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
// Finally, was the correct element stored in the repository?
|
||||
string expectedXml = String.Format(@"
|
||||
<key id='3d6d01fd-c0e7-44ae-82dd-013b996b4093' version='1' xmlns:enc='http://schemas.asp.net/2015/03/dataProtection'>
|
||||
<creationDate>2014-01-01T00:00:00Z</creationDate>
|
||||
<activationDate>2014-02-01T00:00:00Z</activationDate>
|
||||
<expirationDate>2014-03-01T00:00:00Z</expirationDate>
|
||||
{1}
|
||||
{2}
|
||||
{3}
|
||||
<descriptor deserializerType='{0}'>
|
||||
<theElement>
|
||||
<secret enc:requiresEncryption='true'>
|
||||
|
|
@ -141,7 +141,10 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
</theElement>
|
||||
</descriptor>
|
||||
</key>",
|
||||
typeof(MyDeserializer).AssemblyQualifiedName);
|
||||
typeof(MyDeserializer).AssemblyQualifiedName,
|
||||
new XElement("creationDate", creationDate),
|
||||
new XElement("activationDate", activationDate),
|
||||
new XElement("expirationDate", expirationDate));
|
||||
XmlAssert.Equal(expectedXml, elementStoredInRepository);
|
||||
Assert.Equal("key-3d6d01fd-c0e7-44ae-82dd-013b996b4093", friendlyNameStoredInRepository);
|
||||
}
|
||||
|
|
@ -221,9 +224,9 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
// This should not have gone through the encryptor.
|
||||
string expectedEscrowXml = String.Format(@"
|
||||
<key id='3d6d01fd-c0e7-44ae-82dd-013b996b4093' version='1' xmlns:enc='http://schemas.asp.net/2015/03/dataProtection'>
|
||||
<creationDate>2014-01-01T00:00:00Z</creationDate>
|
||||
<activationDate>2014-02-01T00:00:00Z</activationDate>
|
||||
<expirationDate>2014-03-01T00:00:00Z</expirationDate>
|
||||
{1}
|
||||
{2}
|
||||
{3}
|
||||
<descriptor deserializerType='{0}'>
|
||||
<theElement>
|
||||
<secret enc:requiresEncryption='true'>
|
||||
|
|
@ -232,7 +235,10 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
</theElement>
|
||||
</descriptor>
|
||||
</key>",
|
||||
typeof(MyDeserializer).AssemblyQualifiedName);
|
||||
typeof(MyDeserializer).AssemblyQualifiedName,
|
||||
new XElement("creationDate", creationDate),
|
||||
new XElement("activationDate", activationDate),
|
||||
new XElement("expirationDate", expirationDate));
|
||||
XmlAssert.Equal(expectedEscrowXml, elementStoredInEscrow);
|
||||
Assert.Equal(keyId, keyIdStoredInEscrow.Value);
|
||||
|
||||
|
|
@ -240,9 +246,9 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
// This should have gone through the encryptor (which we set to be the null encryptor in this test)
|
||||
string expectedRepositoryXml = String.Format(@"
|
||||
<key id='3d6d01fd-c0e7-44ae-82dd-013b996b4093' version='1' xmlns:enc='http://schemas.asp.net/2015/03/dataProtection'>
|
||||
<creationDate>2014-01-01T00:00:00Z</creationDate>
|
||||
<activationDate>2014-02-01T00:00:00Z</activationDate>
|
||||
<expirationDate>2014-03-01T00:00:00Z</expirationDate>
|
||||
{2}
|
||||
{3}
|
||||
{4}
|
||||
<descriptor deserializerType='{0}'>
|
||||
<theElement>
|
||||
<enc:encryptedSecret decryptorType='{1}'>
|
||||
|
|
@ -256,7 +262,10 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
</descriptor>
|
||||
</key>",
|
||||
typeof(MyDeserializer).AssemblyQualifiedName,
|
||||
typeof(NullXmlDecryptor).AssemblyQualifiedName);
|
||||
typeof(NullXmlDecryptor).AssemblyQualifiedName,
|
||||
new XElement("creationDate", creationDate),
|
||||
new XElement("activationDate", activationDate),
|
||||
new XElement("expirationDate", expirationDate));
|
||||
XmlAssert.Equal(expectedRepositoryXml, elementStoredInRepository);
|
||||
Assert.Equal("key-3d6d01fd-c0e7-44ae-82dd-013b996b4093", friendlyNameStoredInRepository);
|
||||
}
|
||||
|
|
@ -660,7 +669,7 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
var services = serviceCollection.BuildServiceProvider();
|
||||
var keyManager = new XmlKeyManager(services);
|
||||
|
||||
var revocationDate = DateTimeOffset.UtcNow;
|
||||
var revocationDate = new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero);
|
||||
|
||||
// Act & assert
|
||||
|
||||
|
|
@ -672,19 +681,20 @@ namespace Microsoft.AspNet.DataProtection.KeyManagement
|
|||
// and we should've gotten a new CT.
|
||||
((IInternalXmlKeyManager)keyManager).RevokeSingleKey(
|
||||
keyId: new Guid("a11f35fc-1fed-4bd4-b727-056a63b70932"),
|
||||
revocationDate: new DateTimeOffset(2014, 01, 01, 0, 0, 0, TimeSpan.Zero),
|
||||
revocationDate: revocationDate,
|
||||
reason: "Here's some reason text.");
|
||||
var secondCancellationToken = keyManager.GetCacheExpirationToken();
|
||||
Assert.True(firstCancellationToken.IsCancellationRequested);
|
||||
Assert.False(secondCancellationToken.IsCancellationRequested);
|
||||
|
||||
// Was the correct element stored in the repository?
|
||||
const string expectedRepositoryXml = @"
|
||||
var expectedRepositoryXml = string.Format(@"
|
||||
<revocation version='1'>
|
||||
<revocationDate>2014-01-01T00:00:00Z</revocationDate>
|
||||
{0}
|
||||
<key id='a11f35fc-1fed-4bd4-b727-056a63b70932' />
|
||||
<reason>Here's some reason text.</reason>
|
||||
</revocation>";
|
||||
</revocation>",
|
||||
new XElement("revocationDate", revocationDate));
|
||||
XmlAssert.Equal(expectedRepositoryXml, elementStoredInRepository);
|
||||
Assert.Equal("revocation-a11f35fc-1fed-4bd4-b727-056a63b70932", friendlyNameStoredInRepository);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ using System;
|
|||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Microsoft.AspNet.DataProtection.Test.Shared;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.DataProtection.Managed
|
||||
|
|
@ -77,7 +79,8 @@ namespace Microsoft.AspNet.DataProtection.Managed
|
|||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[ConditionalFact]
|
||||
[ConditionalRunTestOnlyOnWindows]
|
||||
public void Encrypt_KnownKey()
|
||||
{
|
||||
// Arrange
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ namespace Microsoft.AspNet.DataProtection.XmlEncryption
|
|||
public void Encrypt_Decrypt_RoundTrips()
|
||||
{
|
||||
// Arrange
|
||||
var aes = new AesCryptoServiceProvider();
|
||||
aes.GenerateKey();
|
||||
var symmetricAlgorithm = new TripleDESCryptoServiceProvider();
|
||||
symmetricAlgorithm.GenerateKey();
|
||||
|
||||
var serviceCollection = new ServiceCollection();
|
||||
var mockInternalEncryptor = new Mock<IInternalCertificateXmlEncryptor>();
|
||||
mockInternalEncryptor.Setup(o => o.PerformEncryption(It.IsAny<EncryptedXml>(), It.IsAny<XmlElement>()))
|
||||
.Returns<EncryptedXml, XmlElement>((encryptedXml, element) =>
|
||||
{
|
||||
encryptedXml.AddKeyNameMapping("theKey", aes); // use symmetric encryption
|
||||
encryptedXml.AddKeyNameMapping("theKey", symmetricAlgorithm); // use symmetric encryption
|
||||
return encryptedXml.Encrypt(element, "theKey");
|
||||
});
|
||||
serviceCollection.AddInstance<IInternalCertificateXmlEncryptor>(mockInternalEncryptor.Object);
|
||||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.DataProtection.XmlEncryption
|
|||
mockInternalDecryptor.Setup(o => o.PerformPreDecryptionSetup(It.IsAny<EncryptedXml>()))
|
||||
.Callback<EncryptedXml>(encryptedXml =>
|
||||
{
|
||||
encryptedXml.AddKeyNameMapping("theKey", aes); // use symmetric encryption
|
||||
encryptedXml.AddKeyNameMapping("theKey", symmetricAlgorithm); // use symmetric encryption
|
||||
});
|
||||
serviceCollection.AddInstance<IInternalEncryptedXmlDecryptor>(mockInternalDecryptor.Object);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue