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