mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 17:11:10 +00:00
Formats code comments as sentences in the tests.
Capitalizes the first word and adds the terminal period in the unit, integration and security tests. The AAA markers stay bare, the TODO bodies stay lowercase, and no assertion, payload, expected status code or test signature changes.
This commit is contained in:
1 parent
727aa33318
commit
057f557791
540 files changed
+3888
-3888
No files matched your search
+4
-4
@@ -180,10 +180,10 @@ public class CoverArtArchiveHttpClientTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("https://evil.example/index.json")] // an unrelated public host
|
||||
[InlineData("https://localhost/index.json")] // the loopback host name
|
||||
[InlineData("https://127.0.0.1/index.json")] // the IPv4 loopback address
|
||||
[InlineData("https://169.254.169.254/latest/meta-data/")] // the link local cloud metadata endpoint
|
||||
[InlineData("https://evil.example/index.json")] // An unrelated public host.
|
||||
[InlineData("https://localhost/index.json")] // The loopback host name.
|
||||
[InlineData("https://127.0.0.1/index.json")] // The IPv4 loopback address.
|
||||
[InlineData("https://169.254.169.254/latest/meta-data/")] // The link local cloud metadata endpoint.
|
||||
public async Task GetReleaseArtworkAsync_WhenTheRedirectPointsAtADisallowedHost_ShouldThrow(string location)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+18
-18
@@ -12,10 +12,10 @@ namespace Lumina.Plugins.CoverArtArchive.UnitTests.Core;
|
||||
public class CoverArtArchiveHostsTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("coverartarchive.org")] // the Cover Art Archive host
|
||||
[InlineData("archive.org")] // the Internet Archive host
|
||||
[InlineData("ia800100.us.archive.org")] // a subdomain of the Internet Archive that serves its downloads
|
||||
[InlineData("media.coverartarchive.org")] // a subdomain of the Cover Art Archive
|
||||
[InlineData("coverartarchive.org")] // The Cover Art Archive host.
|
||||
[InlineData("archive.org")] // The Internet Archive host.
|
||||
[InlineData("ia800100.us.archive.org")] // A subdomain of the Internet Archive that serves its downloads.
|
||||
[InlineData("media.coverartarchive.org")] // A subdomain of the Cover Art Archive.
|
||||
public void IsAllowed_WhenTheHostIsATrustedArchiveHost_ShouldReturnTrue(string host)
|
||||
{
|
||||
// Act
|
||||
@@ -26,8 +26,8 @@ public class CoverArtArchiveHostsTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("COVERARTARCHIVE.ORG")] // the Cover Art Archive host, upper cased
|
||||
[InlineData("Archive.Org")] // the Internet Archive host, mixed cased
|
||||
[InlineData("COVERARTARCHIVE.ORG")] // The Cover Art Archive host, upper cased.
|
||||
[InlineData("Archive.Org")] // The Internet Archive host, mixed cased.
|
||||
public void IsAllowed_WhenTheHostDiffersOnlyByCase_ShouldReturnTrue(string host)
|
||||
{
|
||||
// Act
|
||||
@@ -38,18 +38,18 @@ public class CoverArtArchiveHostsTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("")] // an empty host
|
||||
[InlineData(" ")] // only white space
|
||||
[InlineData("localhost")] // the loopback host name
|
||||
[InlineData("127.0.0.1")] // the IPv4 loopback address
|
||||
[InlineData("169.254.169.254")] // the link local cloud metadata endpoint
|
||||
[InlineData("10.0.0.5")] // a private class A address
|
||||
[InlineData("192.168.1.10")] // a private class C address
|
||||
[InlineData("evil.example")] // an unrelated public host
|
||||
[InlineData("coverartarchive.org.evil.example")] // the trusted host used as a prefix of an attacker controlled host
|
||||
[InlineData("archive.org.evil.example")] // the Internet Archive host used as a prefix of an attacker controlled host
|
||||
[InlineData("notcoverartarchive.org")] // a suffix collision that is not a subdomain
|
||||
[InlineData("notarchive.org")] // a suffix collision that is not a subdomain
|
||||
[InlineData("")] // An empty host.
|
||||
[InlineData(" ")] // Only white space.
|
||||
[InlineData("localhost")] // The loopback host name.
|
||||
[InlineData("127.0.0.1")] // The IPv4 loopback address.
|
||||
[InlineData("169.254.169.254")] // The link local cloud metadata endpoint.
|
||||
[InlineData("10.0.0.5")] // A private class A address.
|
||||
[InlineData("192.168.1.10")] // A private class C address.
|
||||
[InlineData("evil.example")] // An unrelated public host.
|
||||
[InlineData("coverartarchive.org.evil.example")] // The trusted host used as a prefix of an attacker controlled host.
|
||||
[InlineData("archive.org.evil.example")] // The Internet Archive host used as a prefix of an attacker controlled host.
|
||||
[InlineData("notcoverartarchive.org")] // A suffix collision that is not a subdomain.
|
||||
[InlineData("notarchive.org")] // A suffix collision that is not a subdomain.
|
||||
public void IsAllowed_WhenTheHostIsNotATrustedArchiveHost_ShouldReturnFalse(string host)
|
||||
{
|
||||
// Act
|
||||
|
||||
+34
-34
@@ -73,9 +73,9 @@ public class CoverArtArchiveMapperTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // a null URL
|
||||
[InlineData("")] // an empty URL
|
||||
[InlineData(" ")] // a white space URL
|
||||
[InlineData(null)] // A null URL.
|
||||
[InlineData("")] // An empty URL.
|
||||
[InlineData(" ")] // A white space URL.
|
||||
public void MapArtwork_WhenTheImageUrlIsMissing_ShouldSkipIt(string? imageUrl)
|
||||
{
|
||||
// Arrange
|
||||
@@ -90,9 +90,9 @@ public class CoverArtArchiveMapperTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("not-a-url")] // a value that is not an URI at all
|
||||
[InlineData("/release/11111111-1111-1111-1111-111111111111/1.jpg")] // a relative URI
|
||||
[InlineData("coverartarchive.org/release/1.jpg")] // a host without a scheme
|
||||
[InlineData("not-a-url")] // A value that is not an URI at all.
|
||||
[InlineData("/release/11111111-1111-1111-1111-111111111111/1.jpg")] // A relative URI.
|
||||
[InlineData("coverartarchive.org/release/1.jpg")] // A host without a scheme.
|
||||
public void MapArtwork_WhenTheImageUrlIsNotAnAbsoluteUri_ShouldSkipIt(string imageUrl)
|
||||
{
|
||||
// Arrange
|
||||
@@ -107,14 +107,14 @@ public class CoverArtArchiveMapperTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("http://localhost/release/1.jpg")] // the loopback host name
|
||||
[InlineData("http://127.0.0.1/release/1.jpg")] // the IPv4 loopback address
|
||||
[InlineData("http://169.254.169.254/latest/meta-data/")] // the link local cloud metadata endpoint
|
||||
[InlineData("http://10.0.0.5/release/1.jpg")] // a private class A address
|
||||
[InlineData("http://192.168.1.10/release/1.jpg")] // a private class C address
|
||||
[InlineData("https://evil.example/release/1.jpg")] // an unrelated public host
|
||||
[InlineData("https://coverartarchive.org.evil.example/1.jpg")] // the trusted host used as a prefix of an attacker controlled host
|
||||
[InlineData("https://archive.org.evil.example/1.jpg")] // the Internet Archive host used as a prefix of an attacker controlled host
|
||||
[InlineData("http://localhost/release/1.jpg")] // The loopback host name.
|
||||
[InlineData("http://127.0.0.1/release/1.jpg")] // The IPv4 loopback address.
|
||||
[InlineData("http://169.254.169.254/latest/meta-data/")] // The link local cloud metadata endpoint.
|
||||
[InlineData("http://10.0.0.5/release/1.jpg")] // A private class A address.
|
||||
[InlineData("http://192.168.1.10/release/1.jpg")] // A private class C address.
|
||||
[InlineData("https://evil.example/release/1.jpg")] // An unrelated public host.
|
||||
[InlineData("https://coverartarchive.org.evil.example/1.jpg")] // The trusted host used as a prefix of an attacker controlled host.
|
||||
[InlineData("https://archive.org.evil.example/1.jpg")] // The Internet Archive host used as a prefix of an attacker controlled host.
|
||||
public void MapArtwork_WhenTheImageUrlPointsAtAnUntrustedHost_ShouldSkipIt(string imageUrl)
|
||||
{
|
||||
// Arrange
|
||||
@@ -129,9 +129,9 @@ public class CoverArtArchiveMapperTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("file:///etc/passwd")] // a local file URI
|
||||
[InlineData("ftp://coverartarchive.org/1.jpg")] // an unsupported scheme on a trusted host
|
||||
[InlineData("data:image/png;base64,SGVsbG8=")] // an inline data URI
|
||||
[InlineData("file:///etc/passwd")] // A local file URI.
|
||||
[InlineData("ftp://coverartarchive.org/1.jpg")] // An unsupported scheme on a trusted host.
|
||||
[InlineData("data:image/png;base64,SGVsbG8=")] // An inline data URI.
|
||||
public void MapArtwork_WhenTheImageUrlUsesAnUnsupportedScheme_ShouldSkipIt(string imageUrl)
|
||||
{
|
||||
// Arrange
|
||||
@@ -178,20 +178,20 @@ public class CoverArtArchiveMapperTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("front", ArtworkType.Cover)] // the front cover type, lower cased
|
||||
[InlineData("Front", ArtworkType.Cover)] // the front cover type
|
||||
[InlineData("BACK", ArtworkType.Back)] // the back cover type, upper cased
|
||||
[InlineData("Booklet", ArtworkType.Booklet)] // a booklet page
|
||||
[InlineData("Medium", ArtworkType.Medium)] // a medium label
|
||||
[InlineData("Tray", ArtworkType.Tray)] // the tray artwork
|
||||
[InlineData("Spine", ArtworkType.Spine)] // the spine artwork
|
||||
[InlineData("Obi", ArtworkType.Obi)] // the obi strip
|
||||
[InlineData("Sticker", ArtworkType.Sticker)] // the sticker
|
||||
[InlineData("Poster", ArtworkType.Poster)] // the poster
|
||||
[InlineData("Liner", ArtworkType.Liner)] // the liner notes
|
||||
[InlineData("Watermark", ArtworkType.Watermark)] // a watermark
|
||||
[InlineData(" Booklet ", ArtworkType.Booklet)] // a type with surrounding white space
|
||||
[InlineData("SomeUnknownType", ArtworkType.Other)] // an unknown type is kept as generic artwork
|
||||
[InlineData("front", ArtworkType.Cover)] // The front cover type, lower cased.
|
||||
[InlineData("Front", ArtworkType.Cover)] // The front cover type.
|
||||
[InlineData("BACK", ArtworkType.Back)] // The back cover type, upper cased.
|
||||
[InlineData("Booklet", ArtworkType.Booklet)] // A booklet page.
|
||||
[InlineData("Medium", ArtworkType.Medium)] // A medium label.
|
||||
[InlineData("Tray", ArtworkType.Tray)] // The tray artwork.
|
||||
[InlineData("Spine", ArtworkType.Spine)] // The spine artwork.
|
||||
[InlineData("Obi", ArtworkType.Obi)] // The obi strip.
|
||||
[InlineData("Sticker", ArtworkType.Sticker)] // The sticker.
|
||||
[InlineData("Poster", ArtworkType.Poster)] // The poster.
|
||||
[InlineData("Liner", ArtworkType.Liner)] // The liner notes.
|
||||
[InlineData("Watermark", ArtworkType.Watermark)] // A watermark.
|
||||
[InlineData(" Booklet ", ArtworkType.Booklet)] // A type with surrounding white space.
|
||||
[InlineData("SomeUnknownType", ArtworkType.Other)] // An unknown type is kept as generic artwork.
|
||||
public void MapArtwork_WhenTheImageIsTaggedWithAType_ShouldMapItToTheExpectedArtworkType(string type, ArtworkType expectedArtworkType)
|
||||
{
|
||||
// Arrange
|
||||
@@ -254,9 +254,9 @@ public class CoverArtArchiveMapperTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // a null element inside the types collection
|
||||
[InlineData("")] // an empty element inside the types collection
|
||||
[InlineData(" ")] // a white space element inside the types collection
|
||||
[InlineData(null)] // A null element inside the types collection.
|
||||
[InlineData("")] // An empty element inside the types collection.
|
||||
[InlineData(" ")] // A white space element inside the types collection.
|
||||
public void MapArtwork_WhenTheTypesCollectionContainsNullOrEmptyElements_ShouldSkipThem(string? type)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+19
-19
@@ -78,11 +78,11 @@ public class CoverArtArchiveSettingsProviderTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("user\r\n@example.com")] // carriage return and line feed injection
|
||||
[InlineData("user@example.com\r\nX-Injected: value")] // header injection attempt
|
||||
[InlineData("user(comment)@example.com")] // parentheses break the user agent comment
|
||||
[InlineData("user\"quoted\"@example.com")] // quotes break the header value
|
||||
[InlineData("user example@example.com")] // an inner space is not a valid token character
|
||||
[InlineData("user\r\n@example.com")] // Carriage return and line feed injection.
|
||||
[InlineData("user@example.com\r\nX-Injected: value")] // Header injection attempt.
|
||||
[InlineData("user(comment)@example.com")] // Parentheses break the user agent comment.
|
||||
[InlineData("user\"quoted\"@example.com")] // Quotes break the header value.
|
||||
[InlineData("user example@example.com")] // An inner space is not a valid token character.
|
||||
public async Task GetAsync_WhenThePersistedContactEmailContainsUnsafeCharacters_ShouldDropIt(string storedEmail)
|
||||
{
|
||||
// Arrange
|
||||
@@ -99,9 +99,9 @@ public class CoverArtArchiveSettingsProviderTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("", null)] // an empty value clears the email
|
||||
[InlineData(" ", null)] // a white space value clears the email
|
||||
[InlineData(" user@example.com ", "user@example.com")] // a value with surrounding white space is trimmed
|
||||
[InlineData("", null)] // An empty value clears the email.
|
||||
[InlineData(" ", null)] // A white space value clears the email.
|
||||
[InlineData(" user@example.com ", "user@example.com")] // A value with surrounding white space is trimmed.
|
||||
public async Task GetAsync_WhenThePersistedContactEmailIsPresent_ShouldSetOrClearIt(string storedEmail, string? expectedEmail)
|
||||
{
|
||||
// Arrange
|
||||
@@ -119,17 +119,17 @@ public class CoverArtArchiveSettingsProviderTests
|
||||
|
||||
[Theory]
|
||||
[InlineData("2.5", 2.5)]
|
||||
[InlineData("0", 0)] // an interval of zero is allowed
|
||||
[InlineData("-3", 0)] // a negative interval is clamped to zero
|
||||
[InlineData("not-a-number", 1)] // an unparsable value keeps the default
|
||||
[InlineData("NaN", 1)] // a non finite value keeps the default
|
||||
[InlineData("Infinity", 1)] // a non finite value keeps the default
|
||||
[InlineData("-Infinity", 1)] // a non finite value keeps the default
|
||||
[InlineData("1e400", 1)] // a value that overflows the double range keeps the default
|
||||
[InlineData("1e308", 60)] // a huge but finite value is clamped to the maximum
|
||||
[InlineData("1000", 60)] // a value above the maximum is clamped
|
||||
[InlineData("60", 60)] // the maximum itself is kept
|
||||
[InlineData("59", 59)] // a value within the range is kept
|
||||
[InlineData("0", 0)] // An interval of zero is allowed.
|
||||
[InlineData("-3", 0)] // A negative interval is clamped to zero.
|
||||
[InlineData("not-a-number", 1)] // An unparsable value keeps the default.
|
||||
[InlineData("NaN", 1)] // A non finite value keeps the default.
|
||||
[InlineData("Infinity", 1)] // A non finite value keeps the default.
|
||||
[InlineData("-Infinity", 1)] // A non finite value keeps the default.
|
||||
[InlineData("1e400", 1)] // A value that overflows the double range keeps the default.
|
||||
[InlineData("1e308", 60)] // A huge but finite value is clamped to the maximum.
|
||||
[InlineData("1000", 60)] // A value above the maximum is clamped.
|
||||
[InlineData("60", 60)] // The maximum itself is kept.
|
||||
[InlineData("59", 59)] // A value within the range is kept.
|
||||
public async Task GetAsync_WhenThePersistedMinimumRequestIntervalIsPresent_ShouldParseAndClampIt(string storedInterval, double expectedSeconds)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
Reference in new issue
Block a user