mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11: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
+3
-3
@@ -66,9 +66,9 @@ public class DeleteThemeEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // missing theme id
|
||||
[InlineData("")] // empty theme id
|
||||
[InlineData(" ")] // whitespace theme id
|
||||
[InlineData(null)] // Missing theme id.
|
||||
[InlineData("")] // Empty theme id.
|
||||
[InlineData(" ")] // Whitespace theme id.
|
||||
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
|
||||
{
|
||||
// Act
|
||||
|
||||
+3
-3
@@ -72,9 +72,9 @@ public class DownloadThemeEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // missing theme id
|
||||
[InlineData("")] // empty theme id
|
||||
[InlineData(" ")] // whitespace theme id
|
||||
[InlineData(null)] // Missing theme id.
|
||||
[InlineData("")] // Empty theme id.
|
||||
[InlineData(" ")] // Whitespace theme id.
|
||||
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
|
||||
{
|
||||
// Act
|
||||
|
||||
+3
-3
@@ -90,14 +90,14 @@ public class InstallThemeEndpointTests
|
||||
|
||||
private void ConfigureFormWithArchive(byte[] content, string fileName)
|
||||
{
|
||||
// the stream stays open for the duration of the test, since the endpoint reads it through the form file during execution
|
||||
// The stream stays open for the duration of the test, since the endpoint reads it through the form file during execution.
|
||||
MemoryStream archiveStream = new(content);
|
||||
IFormFile formFile = new FormFile(archiveStream, 0, content.Length, "archive", fileName);
|
||||
FormFileCollection files = [formFile];
|
||||
IFormCollection form = new FormCollection([], files);
|
||||
_sut.HttpContext.Request.ContentType = "multipart/form-data; boundary=----test";
|
||||
// a real FormFeature is used instead of a substitute, because the endpoint execution reads the form through the
|
||||
// request machinery, which would bypass a mocked feature and parse the (empty) request body
|
||||
// A real FormFeature is used instead of a substitute, because the endpoint execution reads the form through the
|
||||
// request machinery, which would bypass a mocked feature and parse the (empty) request body.
|
||||
_sut.HttpContext.Features.Set<IFormFeature>(new FormFeature(form));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -69,9 +69,9 @@ public class RestoreThemeEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // missing theme id
|
||||
[InlineData("")] // empty theme id
|
||||
[InlineData(" ")] // whitespace theme id
|
||||
[InlineData(null)] // Missing theme id.
|
||||
[InlineData("")] // Empty theme id.
|
||||
[InlineData(" ")] // Whitespace theme id.
|
||||
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
|
||||
{
|
||||
// Act
|
||||
|
||||
+3
-3
@@ -62,9 +62,9 @@ public class SetCurrentThemeEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // missing theme id
|
||||
[InlineData("")] // empty theme id
|
||||
[InlineData(" ")] // whitespace theme id
|
||||
[InlineData(null)] // Missing theme id.
|
||||
[InlineData("")] // Empty theme id.
|
||||
[InlineData(" ")] // Whitespace theme id.
|
||||
public async Task ExecuteAsync_WhenThemeIdIsBlank_ShouldReturnProblemWithBadRequest(string? themeId)
|
||||
{
|
||||
// Act
|
||||
|
||||
+6
-6
@@ -145,8 +145,8 @@ public class GetFavoritesEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(2, 50, "users/me/favorites?currentPage=2&perPage=50")] // both the page and the size are supplied
|
||||
[InlineData(-1, 0, "users/me/favorites?currentPage=-1&perPage=0")] // out of range values are preserved, so the API reports its own validation
|
||||
[InlineData(2, 50, "users/me/favorites?currentPage=2&perPage=50")] // Both the page and the size are supplied.
|
||||
[InlineData(-1, 0, "users/me/favorites?currentPage=-1&perPage=0")] // Out of range values are preserved, so the API reports its own validation.
|
||||
public async Task ExecuteAsync_WhenPaginationValuesAreSupplied_ShouldForwardTheNormalizedQueryString(int currentPage, int perPage, string expectedEndpoint)
|
||||
{
|
||||
// Arrange
|
||||
@@ -167,10 +167,10 @@ public class GetFavoritesEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(FavoriteMediaKind.MusicArtist, "users/me/favorites?currentPage=1&perPage=200&mediaKind=MusicArtist")] // artist favorites
|
||||
[InlineData(FavoriteMediaKind.MusicAlbum, "users/me/favorites?currentPage=1&perPage=200&mediaKind=MusicAlbum")] // album favorites
|
||||
[InlineData(FavoriteMediaKind.MusicTrack, "users/me/favorites?currentPage=1&perPage=200&mediaKind=MusicTrack")] // track favorites
|
||||
[InlineData(FavoriteMediaKind.Book, "users/me/favorites?currentPage=1&perPage=200&mediaKind=Book")] // book favorites
|
||||
[InlineData(FavoriteMediaKind.MusicArtist, "users/me/favorites?currentPage=1&perPage=200&mediaKind=MusicArtist")] // Artist favorites.
|
||||
[InlineData(FavoriteMediaKind.MusicAlbum, "users/me/favorites?currentPage=1&perPage=200&mediaKind=MusicAlbum")] // Album favorites.
|
||||
[InlineData(FavoriteMediaKind.MusicTrack, "users/me/favorites?currentPage=1&perPage=200&mediaKind=MusicTrack")] // Track favorites.
|
||||
[InlineData(FavoriteMediaKind.Book, "users/me/favorites?currentPage=1&perPage=200&mediaKind=Book")] // Book favorites.
|
||||
public async Task ExecuteAsync_WhenMediaKindIsSupplied_ShouldAppendTheCanonicalKindToTheQueryString(FavoriteMediaKind mediaKind, string expectedEndpoint)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+17
-17
@@ -56,13 +56,13 @@ public class RemoveFavoriteEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MusicArtist", "MusicArtist")] // canonical member name
|
||||
[InlineData("MusicAlbum", "MusicAlbum")] // another canonical member name
|
||||
[InlineData("MusicTrack", "MusicTrack")] // another canonical member name
|
||||
[InlineData("Book", "Book")] // another canonical member name
|
||||
[InlineData("musictrack", "MusicTrack")] // lowercase member name
|
||||
[InlineData("MUSICTRACK", "MusicTrack")] // uppercase member name
|
||||
[InlineData("musicTrack", "MusicTrack")] // mixed case member name
|
||||
[InlineData("MusicArtist", "MusicArtist")] // Canonical member name.
|
||||
[InlineData("MusicAlbum", "MusicAlbum")] // Another canonical member name.
|
||||
[InlineData("MusicTrack", "MusicTrack")] // Another canonical member name.
|
||||
[InlineData("Book", "Book")] // Another canonical member name.
|
||||
[InlineData("musictrack", "MusicTrack")] // Lowercase member name.
|
||||
[InlineData("MUSICTRACK", "MusicTrack")] // Uppercase member name.
|
||||
[InlineData("musicTrack", "MusicTrack")] // Mixed case member name.
|
||||
public async Task ExecuteAsync_WhenMediaKindNameIsValid_ShouldForwardTheCanonicalMemberName(string routeMediaKind, string expectedMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
@@ -78,16 +78,16 @@ public class RemoveFavoriteEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1")] // numeric enum value
|
||||
[InlineData("0")] // numeric enum value
|
||||
[InlineData("NotAFavoriteMediaKind")] // undefined member name
|
||||
[InlineData("None")] // the default value is not a kind that can be favorited
|
||||
[InlineData("none")] // the default value, matched case insensitively
|
||||
[InlineData("MusicTrack,Book")] // comma separated member names
|
||||
[InlineData("Music Track")] // member name with a space
|
||||
[InlineData("MusicTrack/../..")] // path traversal attempt
|
||||
[InlineData("..")] // dot segment
|
||||
[InlineData("MusicTrack%2F..")] // encoded slash traversal attempt
|
||||
[InlineData("1")] // Numeric enum value.
|
||||
[InlineData("0")] // Numeric enum value.
|
||||
[InlineData("NotAFavoriteMediaKind")] // Undefined member name.
|
||||
[InlineData("None")] // The default value is not a kind that can be favorited.
|
||||
[InlineData("none")] // The default value, matched case insensitively.
|
||||
[InlineData("MusicTrack,Book")] // Comma separated member names.
|
||||
[InlineData("Music Track")] // Member name with a space.
|
||||
[InlineData("MusicTrack/../..")] // Path traversal attempt.
|
||||
[InlineData("..")] // Dot segment.
|
||||
[InlineData("MusicTrack%2F..")] // Encoded slash traversal attempt.
|
||||
public async Task ExecuteAsync_WhenMediaKindNameIsRejected_ShouldForwardTheInvalidPlaceholder(string routeMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+9
-9
@@ -83,8 +83,8 @@ public class GetPlaybackManifestEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(true)] // a null template means the delivery has no segment route
|
||||
[InlineData(false)] // an empty template means the delivery has no segment route
|
||||
[InlineData(true)] // A null template means the delivery has no segment route.
|
||||
[InlineData(false)] // An empty template means the delivery has no segment route.
|
||||
public async Task ExecuteAsync_WhenSegmentPathTemplateIsEmpty_ShouldClearTheDeliveryIdAndTheTemplate(bool useNullTemplate)
|
||||
{
|
||||
// Arrange
|
||||
@@ -153,10 +153,10 @@ public class GetPlaybackManifestEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("mp3/mp3", "?capabilities=mp3%2Fmp3")] // the capabilities are forwarded and URL-escaped
|
||||
[InlineData("flac/flac,mp3/mp3", "?capabilities=flac%2Fflac%2Cmp3%2Fmp3")] // a capability list is forwarded as one escaped value
|
||||
[InlineData(" ", "")] // whitespace only capabilities are not forwarded
|
||||
[InlineData(null, "")] // absent capabilities are not forwarded
|
||||
[InlineData("mp3/mp3", "?capabilities=mp3%2Fmp3")] // The capabilities are forwarded and URL-escaped.
|
||||
[InlineData("flac/flac,mp3/mp3", "?capabilities=flac%2Fflac%2Cmp3%2Fmp3")] // A capability list is forwarded as one escaped value.
|
||||
[InlineData(" ", "")] // Whitespace only capabilities are not forwarded.
|
||||
[InlineData(null, "")] // Absent capabilities are not forwarded.
|
||||
public async Task ExecuteAsync_WhenCapabilitiesAreProvided_ShouldForwardThemOnlyWhenTheyAreNotEmpty(string? capabilities, string expectedSuffix)
|
||||
{
|
||||
// Arrange
|
||||
@@ -211,9 +211,9 @@ public class GetPlaybackManifestEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/lumina", "/lumina")] // a plain absolute path base is prefixed
|
||||
[InlineData("//evil", "")] // a protocol relative path base would point the stream at another origin
|
||||
[InlineData("/a?b", "")] // a path base with a query would truncate the built path
|
||||
[InlineData("/lumina", "/lumina")] // A plain absolute path base is prefixed.
|
||||
[InlineData("//evil", "")] // A protocol relative path base would point the stream at another origin.
|
||||
[InlineData("/a?b", "")] // A path base with a query would truncate the built path.
|
||||
public async Task ExecuteAsync_WhenPathBaseIsPresent_ShouldUseItOnlyWhenItIsSafe(string pathBase, string expectedPrefix)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+2
-2
@@ -142,8 +142,8 @@ public class StreamMusicTrackEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.ServiceUnavailable)] // a busy normalization pipeline is a transient condition
|
||||
[InlineData(HttpStatusCode.TooManyRequests)] // the stream concurrency limit was reached
|
||||
[InlineData(HttpStatusCode.ServiceUnavailable)] // A busy normalization pipeline is a transient condition.
|
||||
[InlineData(HttpStatusCode.TooManyRequests)] // The stream concurrency limit was reached.
|
||||
public async Task ExecuteAsync_WhenApiReportsATransientCondition_ShouldReturnABareStatusWithoutThrowing(HttpStatusCode statusCode)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+8
-8
@@ -46,9 +46,9 @@ public class StreamMusicTrackSegmentEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("uppercase")] // the handle format only accepts lowercase hexadecimal characters
|
||||
[InlineData("dashed")] // the handle format is the N format of a GUID, without dashes
|
||||
[InlineData("short")] // a handle that is shorter than the format allows
|
||||
[InlineData("uppercase")] // The handle format only accepts lowercase hexadecimal characters.
|
||||
[InlineData("dashed")] // The handle format is the N format of a GUID, without dashes.
|
||||
[InlineData("short")] // A handle that is shorter than the format allows.
|
||||
public async Task ExecuteAsync_WhenDeliveryIdIsInvalid_ShouldReturnNotFoundWithoutCallingTheApi(string malformedHandleKind)
|
||||
{
|
||||
// Arrange
|
||||
@@ -104,9 +104,9 @@ public class StreamMusicTrackSegmentEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("artistId", "' OR '1'='1")] // an unparseable artist Id is normalized to an empty GUID
|
||||
[InlineData("albumId", "'; DROP TABLE Tracks; --")] // an unparseable album Id is normalized to an empty GUID
|
||||
[InlineData("trackId", "not-a-guid")] // an unparseable track Id is normalized to an empty GUID
|
||||
[InlineData("artistId", "' OR '1'='1")] // An unparseable artist Id is normalized to an empty GUID.
|
||||
[InlineData("albumId", "'; DROP TABLE Tracks; --")] // An unparseable album Id is normalized to an empty GUID.
|
||||
[InlineData("trackId", "not-a-guid")] // An unparseable track Id is normalized to an empty GUID.
|
||||
public async Task ExecuteAsync_WhenRouteIdsAreNotParseable_ShouldForwardEmptyGuidsToTheApi(string routeValue, string invalidValue)
|
||||
{
|
||||
// Arrange
|
||||
@@ -137,8 +137,8 @@ public class StreamMusicTrackSegmentEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.ServiceUnavailable)] // a busy normalization pipeline is a transient condition
|
||||
[InlineData(HttpStatusCode.TooManyRequests)] // the stream concurrency limit was reached
|
||||
[InlineData(HttpStatusCode.ServiceUnavailable)] // A busy normalization pipeline is a transient condition.
|
||||
[InlineData(HttpStatusCode.TooManyRequests)] // The stream concurrency limit was reached.
|
||||
public async Task ExecuteAsync_WhenApiReportsATransientCondition_ShouldReturnABareStatusWithoutThrowing(HttpStatusCode statusCode)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -53,9 +53,9 @@ public class ClearConsumptionHistoryEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespace_ShouldDeleteCurrentUserHistory(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -53,9 +53,9 @@ public class ClearResumePointsEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespaceAndLibraryIdIsNull_ShouldClearCurrentUserResumePointsWithoutFilter(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+6
-6
@@ -58,9 +58,9 @@ public class DeleteConsumptionItemHistoryEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespace_ShouldDeleteCurrentUserItemHistory(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
@@ -81,9 +81,9 @@ public class DeleteConsumptionItemHistoryEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(MediaKind.MusicTrack, "MusicTrack")] // a music track
|
||||
[InlineData(MediaKind.PodcastEpisode, "PodcastEpisode")] // a podcast episode
|
||||
[InlineData(MediaKind.Book, "Book")] // a book
|
||||
[InlineData(MediaKind.MusicTrack, "MusicTrack")] // A music track.
|
||||
[InlineData(MediaKind.PodcastEpisode, "PodcastEpisode")] // A podcast episode.
|
||||
[InlineData(MediaKind.Book, "Book")] // A book.
|
||||
public async Task ExecuteAsync_WhenMediaKindIsSet_ShouldUseTheMediaKindNameInTheUpstreamRoute(MediaKind mediaKind, string expectedMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -68,9 +68,9 @@ public class GetConsumptionStatisticsEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespace_ShouldRequestCurrentUserStatisticsWithoutQueryString(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -69,9 +69,9 @@ public class GetGenreConsumptionEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespace_ShouldRequestCurrentUserGenresWithoutQueryString(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -80,9 +80,9 @@ public class GetMostConsumedEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespaceAndNoFilterIsSupplied_ShouldRequestCurrentUserItemsWithDefaultPaging(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -80,9 +80,9 @@ public class GetRecentlyConsumedEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespaceAndNoFilterIsSupplied_ShouldRequestCurrentUserItemsWithDefaultPaging(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -69,9 +69,9 @@ public class GetTagConsumptionEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no user selected, the current user is implied
|
||||
[InlineData("")] // empty user selected
|
||||
[InlineData(" ")] // whitespace user selected
|
||||
[InlineData(null)] // No user selected, the current user is implied.
|
||||
[InlineData("")] // Empty user selected.
|
||||
[InlineData(" ")] // Whitespace user selected.
|
||||
public async Task ExecuteAsync_WhenUserIdIsNullOrWhitespace_ShouldRequestCurrentUserTagsWithoutQueryString(string? userId)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+3
-3
@@ -190,9 +190,9 @@ public class StatisticsIndexViewEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)] // no identifier claim at all
|
||||
[InlineData("")] // empty identifier claim
|
||||
[InlineData("not-a-guid")] // identifier claim that is not a GUID
|
||||
[InlineData(null)] // No identifier claim at all.
|
||||
[InlineData("")] // Empty identifier claim.
|
||||
[InlineData("not-a-guid")] // Identifier claim that is not a GUID.
|
||||
public async Task ExecuteAsync_WhenNameIdentifierIsMissingOrNotAGuid_ShouldLeaveCurrentUserIdNull(string? nameIdentifier)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+22
-22
@@ -149,15 +149,15 @@ public class GetResumePointEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Book", "Book")] // canonical member name
|
||||
[InlineData("book", "Book")] // lowercase member name
|
||||
[InlineData("BOOK", "Book")] // uppercase member name
|
||||
[InlineData("MusicTrack", "MusicTrack")] // another canonical member name
|
||||
[InlineData("musicTrack", "MusicTrack")] // mixed case member name
|
||||
[InlineData("TvEpisode", "TvEpisode")] // another canonical member name
|
||||
[InlineData("tvEpisode", "TvEpisode")] // another mixed case member name
|
||||
[InlineData("PodcastEpisode", "PodcastEpisode")] // another canonical member name
|
||||
[InlineData("podcastepisode", "PodcastEpisode")] // another lowercase member name
|
||||
[InlineData("Book", "Book")] // Canonical member name.
|
||||
[InlineData("book", "Book")] // Lowercase member name.
|
||||
[InlineData("BOOK", "Book")] // Uppercase member name.
|
||||
[InlineData("MusicTrack", "MusicTrack")] // Another canonical member name.
|
||||
[InlineData("musicTrack", "MusicTrack")] // Mixed case member name.
|
||||
[InlineData("TvEpisode", "TvEpisode")] // Another canonical member name.
|
||||
[InlineData("tvEpisode", "TvEpisode")] // Another mixed case member name.
|
||||
[InlineData("PodcastEpisode", "PodcastEpisode")] // Another canonical member name.
|
||||
[InlineData("podcastepisode", "PodcastEpisode")] // Another lowercase member name.
|
||||
public async Task ExecuteAsync_WhenMediaKindNameIsValid_ShouldForwardTheCanonicalMemberName(string routeMediaKind, string expectedMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
@@ -175,14 +175,14 @@ public class GetResumePointEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1")] // numeric enum value
|
||||
[InlineData("0")] // numeric enum value, the None member
|
||||
[InlineData("NotAMediaKind")] // undefined member name
|
||||
[InlineData("MusicTrack,Book")] // comma separated member names
|
||||
[InlineData("Music Track")] // member name with a space
|
||||
[InlineData("MusicTrack/../..")] // path traversal attempt
|
||||
[InlineData("..")] // dot segment
|
||||
[InlineData("MusicTrack%2F..")] // encoded slash traversal attempt
|
||||
[InlineData("1")] // Numeric enum value.
|
||||
[InlineData("0")] // Numeric enum value, the None member.
|
||||
[InlineData("NotAMediaKind")] // Undefined member name.
|
||||
[InlineData("MusicTrack,Book")] // Comma separated member names.
|
||||
[InlineData("Music Track")] // Member name with a space.
|
||||
[InlineData("MusicTrack/../..")] // Path traversal attempt.
|
||||
[InlineData("..")] // Dot segment.
|
||||
[InlineData("MusicTrack%2F..")] // Encoded slash traversal attempt.
|
||||
public async Task ExecuteAsync_WhenMediaKindNameIsRejected_ShouldForwardTheInvalidPlaceholder(string routeMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
@@ -249,9 +249,9 @@ public class GetResumePointEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MediaResumePointNotFound")] // the user has no resume point for the media item
|
||||
[InlineData("BookNotFound")] // the book of the resume point no longer exists
|
||||
[InlineData("TrackNotFound")] // the track of the resume point no longer exists
|
||||
[InlineData("MediaResumePointNotFound")] // The user has no resume point for the media item.
|
||||
[InlineData("BookNotFound")] // The book of the resume point no longer exists.
|
||||
[InlineData("TrackNotFound")] // The track of the resume point no longer exists.
|
||||
public async Task ExecuteAsync_WhenApiReportsAnAbsentResumePoint_ShouldReturnSuccessWithNullData(string detail)
|
||||
{
|
||||
// Arrange
|
||||
@@ -289,8 +289,8 @@ public class GetResumePointEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(HttpStatusCode.Forbidden)] // authorization failure reported by the API
|
||||
[InlineData(HttpStatusCode.InternalServerError)] // unexpected API failure
|
||||
[InlineData(HttpStatusCode.Forbidden)] // Authorization failure reported by the API.
|
||||
[InlineData(HttpStatusCode.InternalServerError)] // Unexpected API failure.
|
||||
public async Task ExecuteAsync_WhenApiReturnsAnErrorOtherThanAnAbsentResumePoint_ShouldRethrow(HttpStatusCode httpStatusCode)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+14
-14
@@ -168,12 +168,12 @@ public class StartConsumptionEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("MusicTrack", "MusicTrack")] // canonical member name
|
||||
[InlineData("musictrack", "MusicTrack")] // lowercase member name
|
||||
[InlineData("MUSICTRACK", "MusicTrack")] // uppercase member name
|
||||
[InlineData("tvEpisode", "TvEpisode")] // mixed case member name
|
||||
[InlineData("Book", "Book")] // another canonical member name
|
||||
[InlineData("podcastepisode", "PodcastEpisode")] // another lowercase member name
|
||||
[InlineData("MusicTrack", "MusicTrack")] // Canonical member name.
|
||||
[InlineData("musictrack", "MusicTrack")] // Lowercase member name.
|
||||
[InlineData("MUSICTRACK", "MusicTrack")] // Uppercase member name.
|
||||
[InlineData("tvEpisode", "TvEpisode")] // Mixed case member name.
|
||||
[InlineData("Book", "Book")] // Another canonical member name.
|
||||
[InlineData("podcastepisode", "PodcastEpisode")] // Another lowercase member name.
|
||||
public async Task ExecuteAsync_WhenMediaKindNameIsValid_ShouldForwardTheCanonicalMemberName(string routeMediaKind, string expectedMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
@@ -193,14 +193,14 @@ public class StartConsumptionEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("1")] // numeric enum value
|
||||
[InlineData("0")] // numeric enum value, the None member
|
||||
[InlineData("NotAMediaKind")] // undefined member name
|
||||
[InlineData("MusicTrack,Book")] // comma separated member names
|
||||
[InlineData("Music Track")] // member name with a space
|
||||
[InlineData("MusicTrack/../..")] // path traversal attempt
|
||||
[InlineData("..")] // dot segment
|
||||
[InlineData("MusicTrack%2F..")] // encoded slash traversal attempt
|
||||
[InlineData("1")] // Numeric enum value.
|
||||
[InlineData("0")] // Numeric enum value, the None member.
|
||||
[InlineData("NotAMediaKind")] // Undefined member name.
|
||||
[InlineData("MusicTrack,Book")] // Comma separated member names.
|
||||
[InlineData("Music Track")] // Member name with a space.
|
||||
[InlineData("MusicTrack/../..")] // Path traversal attempt.
|
||||
[InlineData("..")] // Dot segment.
|
||||
[InlineData("MusicTrack%2F..")] // Encoded slash traversal attempt.
|
||||
public async Task ExecuteAsync_WhenMediaKindNameIsRejected_ShouldForwardTheInvalidPlaceholder(string routeMediaKind)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -148,11 +148,11 @@ public class AddPlaylistEntriesEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -153,11 +153,11 @@ public class AddPlaylistEntryEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -182,11 +182,11 @@ public class AddPlaylistScopeEntriesEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -114,11 +114,11 @@ public class DeletePlaylistEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -239,11 +239,11 @@ public class GetPlaylistEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -318,11 +318,11 @@ public class PlaylistItemViewEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -150,11 +150,11 @@ public class MovePlaylistEntryEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenRouteValuesAreCrafted_ShouldNormalizeThemAndNeverForwardTheRawValues(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -116,11 +116,11 @@ public class RemovePlaylistEntryEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenRouteValuesAreCrafted_ShouldNormalizeThemAndNeverForwardTheRawValues(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+5
-5
@@ -151,11 +151,11 @@ public class UpdatePlaylistEndpointTests
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("' OR '1'='1")] // basic SQL injection
|
||||
[InlineData("1;DROP TABLE")] // destructive injection
|
||||
[InlineData("../../admin")] // path traversal
|
||||
[InlineData("<script>alert(1)</script>")] // markup injection
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // unicode payload
|
||||
[InlineData("' OR '1'='1")] // Basic SQL injection.
|
||||
[InlineData("1;DROP TABLE")] // Destructive injection.
|
||||
[InlineData("../../admin")] // Path traversal.
|
||||
[InlineData("<script>alert(1)</script>")] // Markup injection.
|
||||
[InlineData("𝕡𝕝𝕒𝕪𝕝𝕚𝕤𝕥")] // Unicode payload.
|
||||
public async Task ExecuteAsync_WhenPlaylistIdIsCrafted_ShouldNormalizeItAndNeverForwardTheRawValue(string payload)
|
||||
{
|
||||
// Arrange
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class InstallPluginEndpointTests
|
||||
|
||||
private void ConfigureFormWithArchive(byte[] content, string fileName)
|
||||
{
|
||||
// the stream stays open for the duration of the test, since the endpoint reads it through the form file during execution
|
||||
// The stream stays open for the duration of the test, since the endpoint reads it through the form file during execution.
|
||||
MemoryStream archiveStream = new(content);
|
||||
IFormFile formFile = new FormFile(archiveStream, 0, content.Length, "archive", fileName);
|
||||
FormFileCollection files = [formFile];
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class LoginViewEndpointTests
|
||||
// Arrange
|
||||
ISession session = Substitute.For<ISession>();
|
||||
byte[] pendingBytes = Encoding.UTF8.GetBytes("true");
|
||||
#pragma warning disable CS8601 // possible null reference assignment in the NSubstitute out-argument stub
|
||||
#pragma warning disable CS8601 // Possible null reference assignment in the NSubstitute out-argument stub.
|
||||
session.TryGetValue(HttpContextItemKeys.PENDING_SUPER_ADMIN_SETUP, out Arg.Any<byte[]>()).Returns(callInfo =>
|
||||
{
|
||||
callInfo[1] = pendingBytes;
|
||||
|
||||
Reference in new issue
Block a user