Upgrade to xunit 2.3.0-beta4
This commit is contained in:
parent
bd8207bf8f
commit
8ed38f5dcf
|
|
@ -8,8 +8,8 @@
|
|||
<NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
|
||||
<RedisVersion>1.2.4</RedisVersion>
|
||||
<RuntimeFrameworkVersion Condition="'$(TargetFramework)'=='netcoreapp2.0'">2.0.0-*</RuntimeFrameworkVersion>
|
||||
<TestSdkVersion>15.3.0-*</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-beta2-*</XunitVersion>
|
||||
<TestSdkVersion>15.3.0</TestSdkVersion>
|
||||
<XunitVersion>2.3.0-beta4-build3742</XunitVersion>
|
||||
<WindowsAzureStorageVersion>8.1.4</WindowsAzureStorageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,8 @@ namespace Microsoft.AspNetCore.Cryptography.Cng
|
|||
[Fact]
|
||||
public void Init_SetsProperties()
|
||||
{
|
||||
// Arrange
|
||||
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO cipherModeInfo;
|
||||
|
||||
// Act
|
||||
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.Init(out cipherModeInfo);
|
||||
BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.Init(out var cipherModeInfo);
|
||||
|
||||
// Assert
|
||||
Assert.Equal((uint)sizeof(BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO), cipherModeInfo.cbSize);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,9 @@ namespace Microsoft.AspNetCore.Cryptography
|
|||
var retVal = WeakReferenceHelpers.GetSharedInstance(ref wr, () => newInstance);
|
||||
|
||||
// Assert
|
||||
MyDisposable target;
|
||||
Assert.NotNull(wr);
|
||||
Assert.NotSame(wrOriginal, wr);
|
||||
Assert.True(wr.TryGetTarget(out target));
|
||||
Assert.True(wr.TryGetTarget(out var target));
|
||||
Assert.Same(newInstance, target);
|
||||
Assert.Same(newInstance, retVal);
|
||||
Assert.False(newInstance.HasBeenDisposed);
|
||||
|
|
@ -40,9 +39,8 @@ namespace Microsoft.AspNetCore.Cryptography
|
|||
var retVal = WeakReferenceHelpers.GetSharedInstance(ref wr, () => newInstance);
|
||||
|
||||
// Assert
|
||||
MyDisposable target;
|
||||
Assert.NotNull(wr);
|
||||
Assert.True(wr.TryGetTarget(out target));
|
||||
Assert.True(wr.TryGetTarget(out var target));
|
||||
Assert.Same(newInstance, target);
|
||||
Assert.Same(newInstance, retVal);
|
||||
Assert.False(newInstance.HasBeenDisposed);
|
||||
|
|
@ -65,9 +63,8 @@ namespace Microsoft.AspNetCore.Cryptography
|
|||
});
|
||||
|
||||
// Assert
|
||||
MyDisposable target;
|
||||
Assert.NotNull(wr);
|
||||
Assert.True(wr.TryGetTarget(out target));
|
||||
Assert.True(wr.TryGetTarget(out var target));
|
||||
Assert.Same(instanceThatWillBeCreatedFirst, target);
|
||||
Assert.Same(instanceThatWillBeCreatedFirst, retVal);
|
||||
Assert.False(instanceThatWillBeCreatedFirst.HasBeenDisposed);
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
{
|
||||
mockProtector.Object.Protect("Hello\ud800");
|
||||
});
|
||||
Assert.IsAssignableFrom(typeof(EncoderFallbackException), ex.InnerException);
|
||||
Assert.IsAssignableFrom<EncoderFallbackException>(ex.InnerException);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -293,7 +293,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
{
|
||||
mockProtector.Object.Unprotect("AQIDBAU");
|
||||
});
|
||||
Assert.IsAssignableFrom(typeof(DecoderFallbackException), ex.InnerException);
|
||||
Assert.IsAssignableFrom<DecoderFallbackException>(ex.InnerException);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -86,8 +86,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
mockDataProtector.Setup(o => o.Unprotect(new byte[] { 0x01, 0x02 }, out controlExpiration)).Returns(Encoding.UTF8.GetBytes("this is plaintext"));
|
||||
|
||||
// Act
|
||||
DateTimeOffset testExpiration;
|
||||
string unprotectedPayload = mockDataProtector.Object.Unprotect(SampleEncodedString, out testExpiration);
|
||||
string unprotectedPayload = mockDataProtector.Object.Unprotect(SampleEncodedString, out var testExpiration);
|
||||
|
||||
// Assert
|
||||
Assert.Equal("this is plaintext", unprotectedPayload);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
|
||||
// Step 3: validate that there's now a single key in the directory and that it's not protected
|
||||
var allFiles = directory.GetFiles();
|
||||
Assert.Equal(1, allFiles.Length);
|
||||
Assert.Single(allFiles);
|
||||
Assert.StartsWith("key-", allFiles[0].Name, StringComparison.OrdinalIgnoreCase);
|
||||
string fileText = File.ReadAllText(allFiles[0].FullName);
|
||||
Assert.Contains("Warning: the key below is in an unencrypted form.", fileText, StringComparison.Ordinal);
|
||||
|
|
@ -106,7 +106,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
|
||||
// Step 3: validate that there's now a single key in the directory and that it's protected with DPAPI
|
||||
var allFiles = directory.GetFiles();
|
||||
Assert.Equal(1, allFiles.Length);
|
||||
Assert.Single(allFiles);
|
||||
Assert.StartsWith("key-", allFiles[0].Name, StringComparison.OrdinalIgnoreCase);
|
||||
string fileText = File.ReadAllText(allFiles[0].FullName);
|
||||
Assert.DoesNotContain("Warning: the key below is in an unencrypted form.", fileText, StringComparison.Ordinal);
|
||||
|
|
@ -141,7 +141,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
|
||||
// Step 3: validate that there's now a single key in the directory and that it's is protected using the certificate
|
||||
var allFiles = directory.GetFiles();
|
||||
Assert.Equal(1, allFiles.Length);
|
||||
Assert.Single(allFiles);
|
||||
Assert.StartsWith("key-", allFiles[0].Name, StringComparison.OrdinalIgnoreCase);
|
||||
string fileText = File.ReadAllText(allFiles[0].FullName);
|
||||
Assert.DoesNotContain("Warning: the key below is in an unencrypted form.", fileText, StringComparison.Ordinal);
|
||||
|
|
|
|||
|
|
@ -78,8 +78,7 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
var timeLimitedProtector = new TimeLimitedDataProtector(mockInnerProtector.Object);
|
||||
|
||||
// Act
|
||||
DateTimeOffset actualExpiration;
|
||||
var retVal = timeLimitedProtector.UnprotectCore(new byte[] { 0x10, 0x11 }, now, out actualExpiration);
|
||||
var retVal = timeLimitedProtector.UnprotectCore(new byte[] { 0x10, 0x11 }, now, out var actualExpiration);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedExpiration, actualExpiration);
|
||||
|
|
@ -103,8 +102,8 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
var timeLimitedProtector = new TimeLimitedDataProtector(mockInnerProtector.Object);
|
||||
|
||||
// Act & assert
|
||||
DateTimeOffset unused;
|
||||
var ex = Assert.Throws<CryptographicException>(() => timeLimitedProtector.UnprotectCore(new byte[] { 0x10, 0x11 }, now, out unused));
|
||||
var ex = Assert.Throws<CryptographicException>(()
|
||||
=> timeLimitedProtector.UnprotectCore(new byte[] { 0x10, 0x11 }, now, out var _));
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.FormatTimeLimitedDataProtector_PayloadExpired(expectedExpiration), ex.Message);
|
||||
|
|
@ -124,8 +123,8 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
var timeLimitedProtector = new TimeLimitedDataProtector(mockInnerProtector.Object);
|
||||
|
||||
// Act & assert
|
||||
DateTimeOffset unused;
|
||||
var ex = Assert.Throws<CryptographicException>(() => timeLimitedProtector.Unprotect(new byte[] { 0x10, 0x11 }, out unused));
|
||||
var ex = Assert.Throws<CryptographicException>(()
|
||||
=> timeLimitedProtector.Unprotect(new byte[] { 0x10, 0x11 }, out var _));
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.TimeLimitedDataProtector_PayloadInvalid, ex.Message);
|
||||
|
|
@ -141,8 +140,8 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
var timeLimitedProtector = new TimeLimitedDataProtector(mockInnerProtector.Object);
|
||||
|
||||
// Act & assert
|
||||
DateTimeOffset unused;
|
||||
var ex = Assert.Throws<CryptographicException>(() => timeLimitedProtector.Unprotect(new byte[] { 0x10, 0x11 }, out unused));
|
||||
var ex = Assert.Throws<CryptographicException>(()
|
||||
=> timeLimitedProtector.Unprotect(new byte[] { 0x10, 0x11 }, out var _));
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.CryptCommon_GenericError, ex.Message);
|
||||
|
|
@ -162,8 +161,9 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
byte[] timeLimitedProtectedPayload = timeLimitedProtector.Protect(new byte[] { 0x11, 0x22, 0x33, 0x44 }, expectedExpiration);
|
||||
|
||||
// Assert
|
||||
DateTimeOffset actualExpiration;
|
||||
Assert.Equal(new byte[] { 0x11, 0x22, 0x33, 0x44 }, timeLimitedProtector.UnprotectCore(timeLimitedProtectedPayload, StringToDateTime("2010-01-01 00:00:00Z"), out actualExpiration));
|
||||
Assert.Equal(
|
||||
new byte[] { 0x11, 0x22, 0x33, 0x44 },
|
||||
timeLimitedProtector.UnprotectCore(timeLimitedProtectedPayload, StringToDateTime("2010-01-01 00:00:00Z"), out var actualExpiration));
|
||||
Assert.Equal(expectedExpiration, actualExpiration);
|
||||
|
||||
// the two providers shouldn't be able to talk to one another (due to the purpose chaining)
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
|
||||
// Act & assert
|
||||
var ex = ExceptionAssert2.ThrowsCryptographicException(() => protector.Protect(new byte[0]));
|
||||
Assert.IsAssignableFrom(typeof(MockException), ex.InnerException);
|
||||
Assert.IsAssignableFrom<MockException>(ex.InnerException);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -291,11 +291,10 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
newPurpose: "purpose");
|
||||
|
||||
// Act
|
||||
bool requiresMigration, wasRevoked;
|
||||
byte[] retVal = ((IPersistedDataProtector)protector).DangerousUnprotect(protectedData,
|
||||
ignoreRevocationErrors: true,
|
||||
requiresMigration: out requiresMigration,
|
||||
wasRevoked: out wasRevoked);
|
||||
requiresMigration: out var requiresMigration,
|
||||
wasRevoked: out var wasRevoked);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedPlaintext, retVal);
|
||||
|
|
@ -342,11 +341,10 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
Assert.Equal(expectedPlaintext, retVal);
|
||||
|
||||
// Act & assert - IPersistedDataProtector
|
||||
bool requiresMigration, wasRevoked;
|
||||
retVal = ((IPersistedDataProtector)protector).DangerousUnprotect(protectedData,
|
||||
ignoreRevocationErrors: false,
|
||||
requiresMigration: out requiresMigration,
|
||||
wasRevoked: out wasRevoked);
|
||||
requiresMigration: out var requiresMigration,
|
||||
wasRevoked: out var wasRevoked);
|
||||
Assert.Equal(expectedPlaintext, retVal);
|
||||
Assert.False(requiresMigration);
|
||||
Assert.False(wasRevoked);
|
||||
|
|
@ -393,11 +391,10 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
Assert.Equal(expectedPlaintext, retVal);
|
||||
|
||||
// Act & assert - IPersistedDataProtector
|
||||
bool requiresMigration, wasRevoked;
|
||||
retVal = ((IPersistedDataProtector)protector).DangerousUnprotect(protectedData,
|
||||
ignoreRevocationErrors: false,
|
||||
requiresMigration: out requiresMigration,
|
||||
wasRevoked: out wasRevoked);
|
||||
requiresMigration: out var requiresMigration,
|
||||
wasRevoked: out var wasRevoked);
|
||||
Assert.Equal(expectedPlaintext, retVal);
|
||||
Assert.True(requiresMigration);
|
||||
Assert.False(wasRevoked);
|
||||
|
|
|
|||
|
|
@ -57,9 +57,8 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
var keyRing = new KeyRing(key3, new[] { key1, key2 });
|
||||
|
||||
// Assert
|
||||
bool unused;
|
||||
Assert.Equal(key3.KeyId, keyRing.DefaultKeyId);
|
||||
Assert.Equal(key3.CreateEncryptor(), keyRing.GetAuthenticatedEncryptorByKeyId(key3.KeyId, out unused));
|
||||
Assert.Equal(key3.CreateEncryptor(), keyRing.GetAuthenticatedEncryptorByKeyId(key3.KeyId, out var _));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -77,9 +76,8 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
var keyRing = new KeyRing(key2, new[] { key1, key2 });
|
||||
|
||||
// Assert
|
||||
bool isRevoked;
|
||||
Assert.Equal(0, key1.NumTimesCreateEncryptorInstanceCalled);
|
||||
Assert.Same(expectedEncryptorInstance1, keyRing.GetAuthenticatedEncryptorByKeyId(key1.KeyId, out isRevoked));
|
||||
Assert.Same(expectedEncryptorInstance1, keyRing.GetAuthenticatedEncryptorByKeyId(key1.KeyId, out var isRevoked));
|
||||
Assert.True(isRevoked);
|
||||
Assert.Equal(1, key1.NumTimesCreateEncryptorInstanceCalled);
|
||||
Assert.Same(expectedEncryptorInstance1, keyRing.GetAuthenticatedEncryptorByKeyId(key1.KeyId, out isRevoked));
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
var keys = RunGetAllKeysCore(xml, mockActivator.Object).ToArray();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1, keys.Length);
|
||||
Assert.Single(keys);
|
||||
Assert.Equal(new Guid("09712588-ba68-438a-a5ee-fe842b3453b2"), keys[0].KeyId);
|
||||
Assert.Same(expectedDescriptor, keys[0].Descriptor);
|
||||
}
|
||||
|
|
@ -515,7 +515,7 @@ namespace Microsoft.AspNetCore.DataProtection.KeyManagement
|
|||
var keys = RunGetAllKeysCore(xml, mockActivator.Object).ToArray();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1, keys.Length);
|
||||
Assert.Single(keys);
|
||||
Assert.Equal(new Guid("49c0cda9-0232-4d8c-a541-de20cc5a73d6"), keys[0].KeyId);
|
||||
Assert.Same(expectedDescriptor, keys[0].Descriptor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ namespace Microsoft.AspNetCore.DataProtection
|
|||
// Assert
|
||||
var actualKeyEscrowSinks = context.KeyEscrowSinks.ToArray();
|
||||
Assert.Equal(2, actualKeyEscrowSinks.Length);
|
||||
Assert.IsType(typeof(MyKeyEscrowSink1), actualKeyEscrowSinks[0]);
|
||||
Assert.IsType(typeof(MyKeyEscrowSink2), actualKeyEscrowSinks[1]);
|
||||
Assert.IsType<MyKeyEscrowSink1>(actualKeyEscrowSinks[0]);
|
||||
Assert.IsType<MyKeyEscrowSink2>(actualKeyEscrowSinks[1]);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
|
|
|
|||
Loading…
Reference in New Issue