Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros committed Nov 4, 2024
1 parent 14eee79 commit b5d1656
Show file tree
Hide file tree
Showing 27 changed files with 205 additions and 179 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void Encrypt_Decrypt_RoundTrips()
byte[] decipheredtext = encryptor.Decrypt(new ArraySegment<byte>(ciphertext), aad);

// Assert
Assert.Equal(plaintext, decipheredtext);
Assert.Equal(plaintext.AsSpan(), decipheredtext);
}

[ConditionalFact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void Encrypt_Decrypt_RoundTrips()
byte[] decipheredtext = encryptor.Decrypt(new ArraySegment<byte>(ciphertext), aad);

// Assert
Assert.Equal(plaintext, decipheredtext);
Assert.Equal(plaintext.AsSpan(), decipheredtext);
}

[ConditionalFact]
Expand Down Expand Up @@ -100,6 +100,6 @@ public void Encrypt_KnownKey()
// | 00 00 00 00 (postBuffer)

string retValAsString = Convert.ToBase64String(retVal);
Assert.Equal("AAAAAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaG0O2kY0NZtmh2UQtXY5B2jlgnOgAAAAA", retValAsString);
Assert.Equal("AAAAAAECAwQFBgcICQoLDA0ODxAREhMUFRYXGBkaG0O2kY0NZtmh2UQtXY5B2jlgnOgAAAAA".AsSpan(), retValAsString);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void Protect_EncryptsToDefaultProtector_MultiplePurposes()
.Setup(o => o.Encrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualPlaintext, actualAad) =>
{
Assert.Equal(expectedPlaintext, actualPlaintext);
Assert.Equal(expectedAad, actualAad);
Assert.Equal(expectedPlaintext.AsSpan(), actualPlaintext);
Assert.Equal(expectedAad.AsSpan(), actualAad);
return new byte[] { 0x23, 0x29, 0x31, 0x37 }; // ciphertext + tag
});

Expand Down Expand Up @@ -83,8 +83,8 @@ public void Protect_EncryptsToDefaultProtector_SinglePurpose()
.Setup(o => o.Encrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualPlaintext, actualAad) =>
{
Assert.Equal(expectedPlaintext, actualPlaintext);
Assert.Equal(expectedAad, actualAad);
Assert.Equal(expectedPlaintext.AsSpan(), actualPlaintext);
Assert.Equal(expectedAad.AsSpan(), actualAad);
return new byte[] { 0x23, 0x29, 0x31, 0x37 }; // ciphertext + tag
});

Expand Down Expand Up @@ -423,8 +423,8 @@ public void Unprotect_KeyRevoked_RevocationAllowed_ReturnsOriginalData_SetsRevok
.Setup(o => o.Decrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualCiphertext, actualAad) =>
{
Assert.Equal(expectedCiphertext, actualCiphertext);
Assert.Equal(expectedAad, actualAad);
Assert.Equal(expectedCiphertext.AsSpan(), actualCiphertext);
Assert.Equal(expectedAad.AsSpan(), actualAad);
return expectedPlaintext;
});
var mockDescriptor = new Mock<IAuthenticatedEncryptorDescriptor>();
Expand Down Expand Up @@ -470,8 +470,8 @@ public void Unprotect_IsAlsoDefaultKey_Success_NoMigrationRequired()
.Setup(o => o.Decrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualCiphertext, actualAad) =>
{
Assert.Equal(expectedCiphertext, actualCiphertext);
Assert.Equal(expectedAad, actualAad);
Assert.Equal(expectedCiphertext.AsSpan(), actualCiphertext);
Assert.Equal(expectedAad.AsSpan(), actualAad);
return expectedPlaintext;
});
var mockDescriptor = new Mock<IAuthenticatedEncryptorDescriptor>();
Expand Down Expand Up @@ -519,8 +519,8 @@ public void Unprotect_IsNotDefaultKey_Success_RequiresMigration()
.Setup(o => o.Decrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualCiphertext, actualAad) =>
{
Assert.Equal(expectedCiphertext, actualCiphertext);
Assert.Equal(expectedAad, actualAad);
Assert.Equal(expectedCiphertext.AsSpan(), actualCiphertext);
Assert.Equal(expectedAad.AsSpan(), actualAad);
return expectedPlaintext;
});
var mockDescriptor = new Mock<IAuthenticatedEncryptorDescriptor>();
Expand Down Expand Up @@ -594,8 +594,8 @@ public void CreateProtector_ChainsPurposes()
.Setup(o => o.Encrypt(It.IsAny<ArraySegment<byte>>(), It.IsAny<ArraySegment<byte>>()))
.Returns<ArraySegment<byte>, ArraySegment<byte>>((actualPlaintext, actualAad) =>
{
Assert.Equal(expectedPlaintext, actualPlaintext);
Assert.Equal(expectedAad, actualAad);
Assert.Equal(expectedPlaintext.AsSpan(), actualPlaintext);
Assert.Equal(expectedAad.AsSpan(), actualAad);
return new byte[] { 0x23, 0x29, 0x31, 0x37 }; // ciphertext + tag
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Encrypt_Decrypt_RoundTrips()
byte[] decipheredtext = encryptor.Decrypt(new ArraySegment<byte>(ciphertext), aad);

// Assert
Assert.Equal(plaintext, decipheredtext);
Assert.Equal(plaintext.AsSpan(), decipheredtext);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Headers/test/CacheControlHeaderValueTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public void Properties_SetAndGetAllProperties_SetValueReturnedInGetter()
Assert.Throws<FormatException>(() => cacheControl.NoCacheHeaders.Add("invalid PLACEHOLDER"));
cacheControl.NoCacheHeaders.Add("PLACEHOLDER");
Assert.Single(cacheControl.NoCacheHeaders);
Assert.Equal("PLACEHOLDER", cacheControl.NoCacheHeaders.First());
Assert.Equal("PLACEHOLDER".AsSpan(), cacheControl.NoCacheHeaders.First());

Assert.NotNull(cacheControl.PrivateHeaders);
Assert.Throws<ArgumentException>(() => cacheControl.PrivateHeaders.Add(null));
Assert.Throws<FormatException>(() => cacheControl.PrivateHeaders.Add("invalid PLACEHOLDER"));
cacheControl.PrivateHeaders.Add("PLACEHOLDER");
Assert.Single(cacheControl.PrivateHeaders);
Assert.Equal("PLACEHOLDER", cacheControl.PrivateHeaders.First());
Assert.Equal("PLACEHOLDER".AsSpan(), cacheControl.PrivateHeaders.First());

// NameValueHeaderValue collection property
Assert.NotNull(cacheControl.Extensions);
Expand Down
Loading

0 comments on commit b5d1656

Please sign in to comment.