diff --git a/docs/technical/api/library/audio-library/music-library/Api.Tracks.md b/docs/technical/api/library/audio-library/music-library/Api.Tracks.md index 4cf0d71c..fa5e6b17 100644 --- a/docs/technical/api/library/audio-library/music-library/Api.Tracks.md +++ b/docs/technical/api/library/audio-library/music-library/Api.Tracks.md @@ -320,7 +320,6 @@ PUT api/v1/libraries/3b3a19f3-1f5a-4d5a-9a3a-5c5a4a3a2a1a/artists/d7c41e6a-9f2b- ```json { - "path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac", "metadata": { "title": "Bohemian Rhapsody", "originalTitle": "Bohemian Rhapsody", diff --git a/docs/technical/requests/library/audio-library/music-library/tracks/UpdateTrack.http b/docs/technical/requests/library/audio-library/music-library/tracks/UpdateTrack.http index e8bd3ec3..8553d97a 100644 --- a/docs/technical/requests/library/audio-library/music-library/tracks/UpdateTrack.http +++ b/docs/technical/requests/library/audio-library/music-library/tracks/UpdateTrack.http @@ -3,7 +3,6 @@ Authorization: Bearer {{ACCESS_TOKEN}} Content-Type: application/json { - "path": "/music/queen/a-night-at-the-opera/01-bohemian-rhapsody.flac", "metadata": { "title": "Bohemian Rhapsody", "originalTitle": "Bohemian Rhapsody", diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMapping.cs index 076e5672..ebcc9b38 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMapping.cs @@ -158,7 +158,6 @@ public static class UpdateArtistCommandMapping Result updateTrackResult = artist.UpdateTrackInAlbum( existingAlbum, existingTrack, - domainTrack.Path, domainTrack.Metadata, domainTrack.Disambiguation, domainTrack.TrackNumber, diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AudioMetadataDtoMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AudioMetadataDtoMapping.cs index 76393ef8..fdab831b 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AudioMetadataDtoMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/AudioMetadataDtoMapping.cs @@ -111,7 +111,6 @@ public static class AudioMetadataDtoMapping return artist.UpdateTrackInAlbum( album, track, - track.Path, metadataResult.Value, disambiguation, track.TrackNumber, diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMapping.cs index c7ff1519..ee882104 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMapping.cs @@ -85,7 +85,6 @@ public static class UpdateTrackCommandMapping Result updateResult = artist.UpdateTrackInAlbum( album, track, - command.Path!, metadataResult.Value, Optional.FromNullable(metadata.Disambiguation), command.TrackNumber!.Value, diff --git a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMapping.cs b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMapping.cs index 257e2bf1..62d1d6da 100644 --- a/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMapping.cs +++ b/src/Lumina.Application/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMapping.cs @@ -26,7 +26,6 @@ public static class UpdateTrackRequestMapping artistId, albumId, trackId, - request.Path, request.Metadata, request.TrackNumber, request.DiscNumber, diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs index 9f5c15f0..6230619f 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommand.cs @@ -19,7 +19,6 @@ namespace Lumina.Application.Core.MediaLibrary.AudioLibrary.MusicLibrary.Tracks. /// The unique identifier of the artist this track belongs to, taken from the route. /// The unique identifier of the album this track belongs to, taken from the route. /// The unique identifier of the track, taken from the route. -/// The file system path of the track. /// The audio metadata of the track. /// The number of the track on its disc. /// The number of the disc the track belongs to, if applicable. @@ -39,7 +38,6 @@ public record UpdateTrackCommand( string? ArtistId, string? AlbumId, string? TrackId, - string? Path, MusicTrackMetadataDto? Metadata, int? TrackNumber, int? DiscNumber, diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandler.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandler.cs index bced0f6d..edf2a6ad 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandler.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandler.cs @@ -26,7 +26,6 @@ using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.ExternalIden using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate; using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Entities; using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.ValueObjects; -using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services; using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary; using Lumina.Domain.SharedKernel.Common.Enums.Common; using System; @@ -48,7 +47,6 @@ public class UpdateTrackCommandHandler : ICommandHandler _validator; - private readonly IPathService _pathService; /// /// Initializes a new instance of the class. @@ -57,14 +55,12 @@ public class UpdateTrackCommandHandler : ICommandHandlerInjected service for authorization related functionality. /// Injected service to retrieve the current user information. /// Injected validator for application validation rules. - /// Injected service for file system path related functionality. - public UpdateTrackCommandHandler(IUnitOfWork unitOfWork, IAuthorizationService authorizationService, ICurrentUserService currentUserService, IValidator validator, IPathService pathService) + public UpdateTrackCommandHandler(IUnitOfWork unitOfWork, IAuthorizationService authorizationService, ICurrentUserService currentUserService, IValidator validator) { _unitOfWork = unitOfWork; _authorizationService = authorizationService; _currentUserService = currentUserService; _validator = validator; - _pathService = pathService; } /// @@ -127,11 +123,6 @@ public class UpdateTrackCommandHandler : ICommandHandler> getContributorsResult = await GetExistingContributorsAsync(command, cancellationToken).ConfigureAwait(false); if (getContributorsResult.IsFailure) @@ -164,17 +155,6 @@ public class UpdateTrackCommandHandler : ICommandHandler - /// Determines whether the track path referenced by is stored inside one of the content locations of . - /// - /// The media library that owns the track. - /// The command carrying the referenced track. - /// when the referenced track path is within a content location of the library; otherwise, . - private bool AreTrackPathsWithinLibraryContentLocations(LibraryEntity library, UpdateTrackCommand command) - { - return library.ContentLocations.Any(contentLocation => _pathService.IsPathWithin(command.Path!, contentLocation.Path)); - } - /// /// Gets the media contributors referenced by , requiring each referenced Id to already exist. /// diff --git a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs index aee75a3e..04ae999c 100644 --- a/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs +++ b/src/Lumina.Application/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidator.cs @@ -57,12 +57,6 @@ public class UpdateTrackCommandValidator : AbstractValidator .When(command => command.TrackId is not null && command.TrackId.Length > 0) .WithError(Errors.Music.TrackIdCannotBeEmpty); - RuleFor(command => command.Path) - .NotEmpty() - .WithError(Errors.Music.TrackPathCannotBeEmpty) - .MaximumLength(2048) - .WithError(Errors.Music.TrackPathMustBeMaximum2048CharactersLong); - // Validates the audio metadata of the track: title, lengths, release information, languages, genres and tags. RuleFor(command => command.Metadata) .NotNull() diff --git a/src/Lumina.Contracts/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequest.cs b/src/Lumina.Contracts/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequest.cs index 34cb73d8..c2e624ad 100644 --- a/src/Lumina.Contracts/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequest.cs +++ b/src/Lumina.Contracts/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequest.cs @@ -14,7 +14,6 @@ namespace Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Track /// /// Represents a request to update an existing track. /// -/// The file system path of the track. Required. /// The audio metadata of the track. Required. /// The number of the track on its disc. Required. /// The number of the disc the track belongs to. Optional. @@ -30,7 +29,6 @@ namespace Lumina.Contracts.Requests.MediaLibrary.AudioLibrary.MusicLibrary.Track /// The list of ratings for this track. Required. [DebuggerDisplay("Title: {Metadata.Title}")] public record UpdateTrackRequest( - string? Path, MusicTrackMetadataDto? Metadata, int? TrackNumber, int? DiscNumber, diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs index 5a5043f2..9fda2db6 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Artist.cs @@ -638,11 +638,11 @@ public sealed class Artist : AggregateRoot /// /// A track is a child entity of the artist aggregate, not an aggregate root, so it is mutated through its owning artist, /// which is the consistency boundary. Book is itself an aggregate root, so its update flow reconstitutes it directly - /// with its own Create method instead. This difference is intentional. + /// with its own Create method instead. This difference is intentional. The file system path of the track is never updated + /// here: a track path is set only when the track is created by the scanner. /// /// The album the track belongs to. /// The track to update. - /// The file system path of the track. /// The audio metadata of the track. /// The optional disambiguation comment of the track. /// The number of the track on its disc. @@ -662,7 +662,6 @@ public sealed class Artist : AggregateRoot public Result UpdateTrackInAlbum( Album album, Track track, - string path, AudioMetadata metadata, Optional disambiguation, int trackNumber, @@ -686,7 +685,6 @@ public sealed class Artist : AggregateRoot return Errors.Music.TrackNotFound; track.UpdateDetails( - path, metadata, disambiguation, trackNumber, diff --git a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs index 0f3842a4..78703c91 100644 --- a/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs +++ b/src/Lumina.Domain/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/Track.cs @@ -343,9 +343,12 @@ public sealed class Track : Entity } /// - /// Updates the details of the track, without touching the moods, the ISRCs, the media contributors, and the ratings. + /// Updates the details of the track, without touching the file system path, the moods, the ISRCs, the media contributors, and the ratings. /// - /// The file system path of the track. + /// + /// The file system path is intentionally not editable here: it is set only when the track is created by the scanner, so that a client + /// can never point an existing track at an arbitrary file of the host. + /// /// The audio metadata of the track. /// The optional disambiguation comment of the track. /// The number of the track on its disc. @@ -359,7 +362,6 @@ public sealed class Track : Entity /// The optional MusicBrainz identifier of the track. /// An representing either a successful operation, or an error. internal Result UpdateDetails( - string path, AudioMetadata metadata, Optional disambiguation, int trackNumber, @@ -372,7 +374,6 @@ public sealed class Track : Entity Optional musicBrainzRecordingId, Optional musicBrainzTrackId) { - Path = path; Metadata = metadata; Disambiguation = disambiguation; TrackNumber = trackNumber; diff --git a/src/Lumina.Presentation.Api/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointSummary.cs b/src/Lumina.Presentation.Api/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointSummary.cs index e873a6d6..38595b03 100644 --- a/src/Lumina.Presentation.Api/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointSummary.cs +++ b/src/Lumina.Presentation.Api/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointSummary.cs @@ -31,7 +31,6 @@ public class UpdateTrackEndpointSummary : Summary r.Path, "The file system path of the track. Required."); RequestParam(r => r.Metadata, "The audio metadata of the track. Required."); RequestParam(r => r.Metadata!.Title, "The title of the track. Required."); RequestParam(r => r.Metadata!.OriginalTitle, "The original title of the track. Optional."); @@ -397,7 +395,7 @@ public class UpdateTrackEndpointSummary : Summary /// Represents a request to update an existing track of an album of a music artist. /// -/// The file system path of the track. Required. /// The audio metadata of the track. Required. /// The number of the track on its disc. Required. /// The number of the disc the track belongs to. Optional. @@ -30,7 +29,6 @@ namespace Lumina.Presentation.Web.Common.Requests.Library.AudioLibrary.MusicLibr /// The list of ratings for this track. Required. [DebuggerDisplay("Title: {Metadata?.Title}")] public record UpdateMusicTrackRequest( - string? Path, MusicTrackMetadataDto? Metadata, int? TrackNumber, int? DiscNumber, diff --git a/src/Lumina.Presentation.Web/Core/Views/Library/AudioLibrary/MusicLibrary/Tracks/Item.cshtml b/src/Lumina.Presentation.Web/Core/Views/Library/AudioLibrary/MusicLibrary/Tracks/Item.cshtml index 133310d4..976870a1 100644 --- a/src/Lumina.Presentation.Web/Core/Views/Library/AudioLibrary/MusicLibrary/Tracks/Item.cshtml +++ b/src/Lumina.Presentation.Web/Core/Views/Library/AudioLibrary/MusicLibrary/Tracks/Item.cshtml @@ -95,10 +95,10 @@

@_localizer["GeneralInformation"]

- +
-
:
-
+
@_localizer["TrackPath"]:
+
@(Model.Path ?? string.Empty)
@_localizer["TrackPathDescription"]
@@ -793,9 +793,9 @@ } // Builds the payload of the edited track, matching the update request of the API. + // The file system path is not included: a track path is set only by the scanner and can never be edited. function buildPayload() { return { - Path: readValue('track-path') || null, Metadata: { Title: readValue('track-title'), OriginalTitle: readValue('track-original-title') || null, diff --git a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs index 2638718d..db2e3fc2 100644 --- a/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs +++ b/tests/Common/Lumina.Application.Fixtures/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandFixture.cs @@ -39,7 +39,6 @@ public class UpdateTrackCommandFixture /// Optional. The Id of the artist the track belongs to. /// Optional. The Id of the album the track belongs to. /// Optional. The Id of the track to update. - /// Optional. The file system path of the track. /// Optional. The audio metadata of the track. /// Optional. The number of the track on its disc. /// Optional. The number of the disc the track belongs to. @@ -69,7 +68,6 @@ public class UpdateTrackCommandFixture /// Whether the artist Id should be included, or forced to . /// Whether the album Id should be included, or forced to . /// Whether the track Id should be included, or forced to . - /// Whether the path should be included, or forced to . /// Whether the track number should be included, or forced to . /// The created command to update a track. public UpdateTrackCommand Create( @@ -77,7 +75,6 @@ public class UpdateTrackCommandFixture string? artistId = null, string? albumId = null, string? trackId = null, - string? path = null, MusicTrackMetadataDto? metadata = null, int? trackNumber = null, int? discNumber = null, @@ -107,7 +104,6 @@ public class UpdateTrackCommandFixture bool includeArtistId = true, bool includeAlbumId = true, bool includeTrackId = true, - bool includePath = true, bool includeTrackNumber = true) { return new UpdateTrackCommand( @@ -115,7 +111,6 @@ public class UpdateTrackCommandFixture includeArtistId ? (artistId ?? _faker.Random.Guid().ToString()) : null, includeAlbumId ? (albumId ?? _faker.Random.Guid().ToString()) : null, includeTrackId ? (trackId ?? _faker.Random.Guid().ToString()) : null, - includePath ? (path ?? _faker.System.FilePath()) : null, includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null, diff --git a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs index bdf7e052..a2f239ed 100644 --- a/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs +++ b/tests/Common/Lumina.Contracts.Fixtures/Core/Requests/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestFixture.cs @@ -35,7 +35,6 @@ public class UpdateTrackRequestFixture /// /// Creates a random valid request to update a track. /// - /// Optional. The file system path of the track. /// Optional. The audio metadata of the track. /// Optional. The number of the track on its disc. /// Optional. The number of the disc the track belongs to. @@ -60,12 +59,10 @@ public class UpdateTrackRequestFixture /// Whether the ISRC codes should be included, or forced to . /// Whether the contributors list should be included, or forced to . /// Whether the ratings list should be included, or forced to . - /// Whether the path should be included, or forced to . /// Whether the metadata should be included, or forced to . /// Whether the track number should be included, or forced to . /// The created request to update a track. public UpdateTrackRequest Create( - string? path = null, MusicTrackMetadataDto? metadata = null, int? trackNumber = null, int? discNumber = null, @@ -90,12 +87,10 @@ public class UpdateTrackRequestFixture bool includeIsrcs = true, bool includeContributors = true, bool includeRatings = true, - bool includePath = true, bool includeMetadata = true, bool includeTrackNumber = true) { return new UpdateTrackRequest( - includePath ? (path ?? _faker.System.FilePath()) : null, includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null, includeTrackNumber ? (trackNumber ?? _faker.Random.Int(1, 20)) : null, includeDiscNumber ? (discNumber ?? _faker.Random.Int(1, 3)) : null, diff --git a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/AudioLibrary/MusicLibrary/Tracks/UpdateMusicTrackRequestFixture.cs b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/AudioLibrary/MusicLibrary/Tracks/UpdateMusicTrackRequestFixture.cs index b34db133..3f17a46b 100644 --- a/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/AudioLibrary/MusicLibrary/Tracks/UpdateMusicTrackRequestFixture.cs +++ b/tests/Common/Lumina.Presentation.Web.Fixtures/Common/Requests/Library/AudioLibrary/MusicLibrary/Tracks/UpdateMusicTrackRequestFixture.cs @@ -35,7 +35,6 @@ public class UpdateMusicTrackRequestFixture /// /// Creates a new instance with randomized test data. /// - /// Optional. The file system path of the track. /// Optional. The audio metadata of the track. /// Optional. The number of the track on its disc. /// Optional. The number of the disc the track belongs to. @@ -49,7 +48,6 @@ public class UpdateMusicTrackRequestFixture /// Optional. The ISRC codes of the track. /// Optional. The references to the media contributors that performed on the track. /// Optional. The ratings of the track. - /// Whether the path should be included, or forced to . /// Whether the metadata should be included, or forced to . /// Whether the track number should be included, or forced to . /// Whether the disc number should be included, or forced to . @@ -65,7 +63,6 @@ public class UpdateMusicTrackRequestFixture /// Whether the ratings should be included, or forced to . /// A configured instance. public UpdateMusicTrackRequest Create( - string? path = null, MusicTrackMetadataDto? metadata = null, int? trackNumber = null, int? discNumber = null, @@ -79,7 +76,6 @@ public class UpdateMusicTrackRequestFixture List? isrcs = null, List? contributors = null, List? ratings = null, - bool includePath = true, bool includeMetadata = true, bool includeTrackNumber = true, bool includeDiscNumber = true, @@ -95,7 +91,6 @@ public class UpdateMusicTrackRequestFixture bool includeRatings = true) { return new UpdateMusicTrackRequest( - Path: includePath ? (path ?? _faker.System.FilePath()) : null, Metadata: includeMetadata ? (metadata ?? _musicTrackMetadataDtoFixture.Create()) : null, TrackNumber: includeTrackNumber ? (trackNumber ?? _faker.Random.Number(1, 30)) : null, DiscNumber: includeDiscNumber ? (discNumber ?? _faker.Random.Number(1, 4)) : null, diff --git a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs index c7f0ebc8..9a28581d 100644 --- a/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs +++ b/tests/IntegrationTests/Lumina.Presentation.Api.IntegrationTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs @@ -56,7 +56,6 @@ namespace Lumina.Presentation.Api.IntegrationTests.Core.Endpoints.Library.AudioL public class UpdateTrackEndpointTests : IClassFixture, IAsyncLifetime { private static readonly string s_contentRootPath = Path.Combine(Path.GetTempPath(), "lumina-update-track-tests"); - private static readonly string s_outsideContentRootPath = Path.Combine(Path.GetTempPath(), "lumina-update-track-outside"); private HttpClient _client; private readonly AuthenticatedLuminaApiFactory _apiFactory; @@ -115,10 +114,9 @@ public class UpdateTrackEndpointTests : IClassFixture(); TrackEntity storedTrack = dbContext.Tracks.Single(track => track.Id == trackId); Assert.Equal("Somebody to Love", storedTrack.Title); - Assert.Equal(updatedPath, storedTrack.Path); + Assert.Equal(originalPath, storedTrack.Path); } [Fact] @@ -160,7 +159,6 @@ public class UpdateTrackEndpointTests : IClassFixture link.Role == MediaContributorRole.Guitar); } - [Fact] - public async Task UpdateTrack_WhenPathIsNull_ShouldReturnUnprocessableEntity() - { - // Arrange - UpdateTrackRequest request = _updateTrackRequestFixture.Create(includePath: false); - - // Act - HttpResponseMessage response = await PutTrackAsync(request); - - // Assert - await AssertUnprocessableEntityWithValidationErrors(response, "TrackPathCannotBeEmpty"); - } - - [Fact] - public async Task UpdateTrack_WhenPathExceeds2048Characters_ShouldReturnUnprocessableEntity() - { - // Arrange - UpdateTrackRequest request = _updateTrackRequestFixture.Create(path: new Faker().Random.String2(2049)); - - // Act - HttpResponseMessage response = await PutTrackAsync(request); - - // Assert - await AssertUnprocessableEntityWithValidationErrors(response, "TrackPathMustBeMaximum2048CharactersLong"); - } - [Fact] public async Task UpdateTrack_WhenMetadataIsNull_ShouldReturnUnprocessableEntity() { @@ -1004,7 +958,7 @@ public class UpdateTrackEndpointTests : IClassFixture using JsonDocument json = JsonDocument.Parse(content); Assert.True(json.RootElement.GetProperty("success").GetBoolean()); Assert.Equal(trackId, json.RootElement.GetProperty("data").GetProperty("id").GetGuid()); - Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == $"libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}" && putRequest.Data is UpdateMusicTrackRequest forwarded && forwarded.Metadata!.Title == request.Metadata!.Title && forwarded.Path == request.Path); + Assert.Contains(_apiFactory.ApiClientStub.PutRequests, putRequest => putRequest.Endpoint == $"libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}" && putRequest.Data is UpdateMusicTrackRequest forwarded && forwarded.Metadata!.Title == request.Metadata!.Title); } [Fact] diff --git a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs index eafa1ec8..a66b6385 100644 --- a/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs +++ b/tests/SecurityTests/Lumina.Presentation.Api.SecurityTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs @@ -94,7 +94,6 @@ public class UpdateTrackEndpointTests : IClassFixture, IDispos SeedLibrary(libraryId, userId); (Guid artistId, Guid albumId, Guid trackId) = SeedArtistGraph(libraryId); UpdateTrackRequest request = _updateTrackRequestFixture.Create( - path: Path.Combine(s_contentRootPath, $"injected-{Guid.NewGuid():N}.flac"), metadata: _musicTrackMetadataDtoFixture.Create(title: maliciousTitle), moods: [], isrcs: [], diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMappingTests.cs index 4d78854a..a3463b17 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Artists/UpdateArtistCommandMappingTests.cs @@ -44,8 +44,9 @@ public class UpdateArtistCommandMappingTests // Arrange Guid libraryId = Guid.NewGuid(); (Artist artist, Guid albumId, Guid trackId) = CreateDomainArtist(libraryId); - string updatedPath = "/music/queen/a-night-at-the-opera/03-you-re-my-best-friend.flac"; - AddTrackCommand trackCommand = _addTrackCommandFixture.Create(trackId: trackId, path: updatedPath, trackNumber: 7); + string originalPath = artist.Albums.SelectMany(album => album.Tracks).First(track => track.Id.Value == trackId).Path; + string attemptedPath = "/music/queen/a-night-at-the-opera/03-you-re-my-best-friend.flac"; + AddTrackCommand trackCommand = _addTrackCommandFixture.Create(trackId: trackId, path: attemptedPath, trackNumber: 7); AddAlbumCommand albumCommand = _addAlbumCommandFixture.Create(albumId: albumId, tracks: [trackCommand]); UpdateArtistCommand command = _updateArtistCommandFixture.Create( libraryId: libraryId.ToString(), @@ -67,7 +68,9 @@ public class UpdateArtistCommandMappingTests Album updatedAlbum = result.Value.Albums.First(album => album.Id.Value == albumId); Assert.Equal(albumCommand.Metadata!.Title, updatedAlbum.Metadata.Title); Track updatedTrack = updatedAlbum.Tracks.First(track => track.Id.Value == trackId); - Assert.Equal(updatedPath, updatedTrack.Path); + // the file system path of an existing track is never changed by the update, it is set only when the track is created + Assert.Equal(originalPath, updatedTrack.Path); + Assert.NotEqual(attemptedPath, updatedTrack.Path); Assert.Equal(7, updatedTrack.TrackNumber); Assert.True(updatedTrack.DiscNumber.HasValue); Assert.Equal(trackCommand.DiscNumber, updatedTrack.DiscNumber.Value); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMappingTests.cs index f43c1870..5033efa8 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackCommandMappingTests.cs @@ -45,8 +45,8 @@ public class UpdateTrackCommandMappingTests // Arrange Guid libraryId = Guid.NewGuid(); (Artist artist, Guid albumId, Guid trackId) = CreateDomainArtist(libraryId); - string updatedPath = "/music/queen/a-night-at-the-opera/02-love-of-my-life.flac"; - UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artist.Id.Value.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString(), path: updatedPath); + string originalPath = artist.Albums.SelectMany(album => album.Tracks).First(track => track.Id.Value == trackId).Path; + UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artist.Id.Value.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString()); // Act Result result = command.ToDomainEntity(artist); @@ -55,7 +55,8 @@ public class UpdateTrackCommandMappingTests Assert.False(result.IsFailure); Assert.Same(artist, result.Value); Track updatedTrack = result.Value.Albums.First(album => album.Id.Value == albumId).Tracks.First(track => track.Id.Value == trackId); - Assert.Equal(updatedPath, updatedTrack.Path); + // The file system path is never changed by the update, it is set only when the track is created. + Assert.Equal(originalPath, updatedTrack.Path); Assert.Equal(command.Metadata!.Title, updatedTrack.Metadata.Title); Assert.Equal(command.TrackNumber, updatedTrack.TrackNumber); Assert.True(updatedTrack.DiscNumber.HasValue); @@ -83,8 +84,8 @@ public class UpdateTrackCommandMappingTests // Arrange Guid libraryId = Guid.NewGuid(); (Artist artist, Guid albumId, Guid trackId) = CreateDomainArtist(libraryId); - string updatedPath = "/music/queen/a-night-at-the-opera/03-you-re-my-best-friend.flac"; - UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artist.Id.Value.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString(), path: updatedPath, includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false, contributors: [], ratings: []); + string originalPath = artist.Albums.SelectMany(album => album.Tracks).First(track => track.Id.Value == trackId).Path; + UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: artist.Id.Value.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString(), includeDiscNumber: false, includeScript: false, includeKey: false, includeBpm: false, includeWork: false, includeMusicBrainzRecordingId: false, includeMusicBrainzTrackId: false, includeMoods: false, includeIsrcs: false, contributors: [], ratings: []); // Act Result result = command.ToDomainEntity(artist); @@ -92,7 +93,8 @@ public class UpdateTrackCommandMappingTests // Assert Assert.False(result.IsFailure); Track updatedTrack = result.Value.Albums.First(album => album.Id.Value == albumId).Tracks.First(track => track.Id.Value == trackId); - Assert.Equal(updatedPath, updatedTrack.Path); + // the file system path is never changed by the update, it is set only when the track is created + Assert.Equal(originalPath, updatedTrack.Path); Assert.Equal(command.TrackNumber, updatedTrack.TrackNumber); Assert.False(updatedTrack.DiscNumber.HasValue); Assert.False(updatedTrack.Script.HasValue); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs index c19f7f36..b4bc293c 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Common/Mapping/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/UpdateTrackRequestMappingTests.cs @@ -38,7 +38,6 @@ public class UpdateTrackRequestMappingTests Assert.Equal(artistId.ToString(), result.ArtistId); Assert.Equal(albumId.ToString(), result.AlbumId); Assert.Equal(trackId.ToString(), result.TrackId); - Assert.Equal(request.Path, result.Path); Assert.Equal(request.Metadata, result.Metadata); Assert.Equal(request.TrackNumber, result.TrackNumber); Assert.Equal(request.DiscNumber, result.DiscNumber); diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandlerTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandlerTests.cs index a470115e..d8f9ed42 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandlerTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandHandlerTests.cs @@ -26,7 +26,6 @@ using Lumina.Contracts.Fixtures.Core.DTO.MediaLibrary.AudioLibrary.MusicLibrary; using Lumina.Contracts.Responses.MediaLibrary.AudioLibrary.MusicLibrary.Tracks; using Lumina.Domain.Common.Errors; using Lumina.Domain.Common.Primitives; -using Lumina.Domain.Core.BoundedContexts.FileSystemManagementBoundedContext.FileSystemManagementAggregate.Services; using Lumina.Domain.SharedKernel.Common.Enums.MediaContributors; using NSubstitute; using System; @@ -54,7 +53,6 @@ public class UpdateTrackCommandHandlerTests private readonly IAuthorizationService _mockAuthorizationService; private readonly ICurrentUserService _mockCurrentUserService; private readonly IValidator _mockValidator; - private readonly IPathService _mockPathService; private readonly UpdateTrackCommandHandler _sut; private readonly Guid _userId; private readonly UpdateTrackCommandFixture _updateTrackCommandFixture = new(); @@ -86,16 +84,14 @@ public class UpdateTrackCommandHandlerTests _mockAuthorizationService = Substitute.For(); _mockCurrentUserService = Substitute.For(); _mockValidator = Substitute.For>(); - _mockPathService = Substitute.For(); _userId = Guid.NewGuid(); // Default stubs: the current user is authenticated, the library ownership policy allows access, the validator passes, - // the track path is within the library content locations, the artist is updated and the library and contributors exist. + // the artist is updated and the library and contributors exist. _mockCurrentUserService.UserId.Returns(_userId); _mockAuthorizationService.EvaluatePolicyAsync(_userId, Arg.Any(), Arg.Any()) .Returns(true); _mockValidator.Validate(Arg.Any()).Returns([]); - _mockPathService.IsPathWithin(Arg.Any(), Arg.Any()).Returns(true); _mockArtistRepository.UpdateAsync(Arg.Any(), Arg.Any()) .Returns(Result.Updated); _mockLibraryRepository.GetByIdAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) @@ -109,7 +105,7 @@ public class UpdateTrackCommandHandlerTests return Result.From>([.. contributorIds.Select(contributorId => _mediaContributorEntityFixture.Create(id: contributorId, displayName: contributorId.ToString()))]); }); - _sut = new UpdateTrackCommandHandler(_mockUnitOfWork, _mockAuthorizationService, _mockCurrentUserService, _mockValidator, _mockPathService); + _sut = new UpdateTrackCommandHandler(_mockUnitOfWork, _mockAuthorizationService, _mockCurrentUserService, _mockValidator); } [Fact] @@ -118,6 +114,7 @@ public class UpdateTrackCommandHandlerTests // Arrange Guid libraryId = Guid.NewGuid(); (ArtistEntity existingArtist, Guid albumId, Guid trackId) = CreateArtistWithTrack(libraryId); + string originalPath = existingArtist.Albums.SelectMany(album => album.Tracks).First(track => track.Id == trackId).Path; UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: existingArtist.Id.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString()); ArtistEntity? updatedArtist = null; TrackEntity? updatedTrack = null; @@ -139,7 +136,8 @@ public class UpdateTrackCommandHandlerTests // Assert Assert.False(result.IsFailure); Assert.Equal(trackId, result.Value.Id); - Assert.Equal(command.Path, result.Value.Path); + // The file system path is preserved by the update, it is set only when the track is created. + Assert.Equal(originalPath, result.Value.Path); Assert.Equal(command.Metadata!.Title, result.Value.Metadata!.Title); Assert.Equal(command.Contributors!.Count, result.Value.Contributors!.Count); await _mockArtistRepository.Received(1).UpdateAsync(Arg.Any(), Arg.Any()); @@ -338,29 +336,6 @@ public class UpdateTrackCommandHandlerTests await _mockArtistRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any()); } - [Fact] - public async Task HandleAsync_WhenPathIsNotWithinLibraryContentLocations_ShouldReturnPathError() - { - // Arrange - Guid libraryId = Guid.NewGuid(); - (ArtistEntity existingArtist, Guid albumId, Guid trackId) = CreateArtistWithTrack(libraryId); - UpdateTrackCommand command = _updateTrackCommandFixture.Create(libraryId: libraryId.ToString(), artistId: existingArtist.Id.ToString(), albumId: albumId.ToString(), trackId: trackId.ToString()); - _mockArtistRepository.GetByIdAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) - .Returns(Result.From(existingArtist)); - _mockLibraryRepository.GetByIdAsync(Arg.Any(), Arg.Any(), Arg.Any(), Arg.Any()) - .Returns(_ => Result.From(_libraryEntityFixture.Create(contentLocations: ["/music/queen"]))); - _mockPathService.IsPathWithin(Arg.Any(), Arg.Any()).Returns(false); - - // Act - Result result = await _sut.HandleAsync(command, CancellationToken.None); - - // Assert - Assert.True(result.IsFailure); - Assert.Equal(Errors.Music.TrackPathMustBeWithinLibraryContentLocations, result.FirstError); - _mockPathService.Received(1).IsPathWithin(command.Path!, Arg.Any()); - await _mockArtistRepository.DidNotReceive().UpdateAsync(Arg.Any(), Arg.Any()); - } - [Fact] public async Task HandleAsync_WhenNoContributorsAreReferenced_ShouldNotQueryTheContributorRepository() { diff --git a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs index b0bfe69a..49c76aa2 100644 --- a/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs +++ b/tests/UnitTests/Lumina.Application.UnitTests/Core/MediaLibrary/AudioLibrary/MusicLibrary/Tracks/Commands/UpdateTrack/UpdateTrackCommandValidatorTests.cs @@ -353,71 +353,6 @@ public class UpdateTrackCommandValidatorTests result.ShouldNotHaveValidationError(Errors.Music.TrackIdCannotBeEmpty); } - [Fact] - public void Validate_WhenPathIsNull_ShouldHaveValidationError() - { - // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(includePath: false); - - // Act - List result = _validator.TestValidate(command); - - // Assert - result.ShouldHaveValidationError(Errors.Music.TrackPathCannotBeEmpty); - } - - [Fact] - public void Validate_WhenPathIsEmpty_ShouldHaveValidationError() - { - // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(path: string.Empty); - - // Act - List result = _validator.TestValidate(command); - - // Assert - result.ShouldHaveValidationError(Errors.Music.TrackPathCannotBeEmpty); - } - - [Fact] - public void Validate_WhenPathIsWhitespace_ShouldHaveValidationError() - { - // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(path: " "); - - // Act - List result = _validator.TestValidate(command); - - // Assert - result.ShouldHaveValidationError(Errors.Music.TrackPathCannotBeEmpty); - } - - [Fact] - public void Validate_WhenPathExceeds2048Characters_ShouldHaveValidationError() - { - // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(path: new Faker().Random.String2(2049)); - - // Act - List result = _validator.TestValidate(command); - - // Assert - result.ShouldHaveValidationError(Errors.Music.TrackPathMustBeMaximum2048CharactersLong); - } - - [Fact] - public void Validate_WhenPathIs2048Characters_ShouldNotHaveValidationError() - { - // Arrange - UpdateTrackCommand command = _updateTrackCommandFixture.Create(path: new Faker().Random.String2(2048)); - - // Act - List result = _validator.TestValidate(command); - - // Assert - result.ShouldNotHaveValidationError(Errors.Music.TrackPathMustBeMaximum2048CharactersLong); - } - [Fact] public void Validate_WhenMetadataIsNull_ShouldHaveValidationError() { diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs index 7b557286..02e0add9 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/ArtistTests.cs @@ -661,7 +661,7 @@ public class ArtistTests Track track = _trackFixture.Create(); Album album = _albumFixture.Create(tracks: [track]); Artist artist = _artistFixture.Create(albums: [album]); - string path = "C:\\Music\\queen\\bohemian-rhapsody.flac"; + string originalPath = track.Path; AudioMetadata metadata = _audioMetadataFixture.Create(); Optional disambiguation = Optional.Some("remastered"); Optional discNumber = Optional.Some(1); @@ -681,7 +681,6 @@ public class ArtistTests Result result = artist.UpdateTrackInAlbum( album, track, - path, metadata, disambiguation, 11, @@ -700,7 +699,8 @@ public class ArtistTests // Assert Assert.False(result.IsFailure); - Assert.Equal(path, track.Path); + // The file system path is not part of the track update, it is set only when the track is created. + Assert.Equal(originalPath, track.Path); Assert.Equal(metadata, track.Metadata); Assert.Equal(disambiguation, track.Disambiguation); Assert.Equal(11, track.TrackNumber); @@ -735,7 +735,6 @@ public class ArtistTests Result result = artist.UpdateTrackInAlbum( foreignAlbum, track, - "C:\\Music\\queen\\bohemian-rhapsody.flac", _audioMetadataFixture.Create(), Optional.None(), 11, @@ -773,7 +772,6 @@ public class ArtistTests Result result = artist.UpdateTrackInAlbum( album, track, - "C:\\Music\\queen\\bohemian-rhapsody.flac", _audioMetadataFixture.Create(), Optional.None(), 11, diff --git a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs index a9413b05..1487b4b6 100644 --- a/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs +++ b/tests/UnitTests/Lumina.Domain.UnitTests/Core/BoundedContexts/AudioLibraryBoundedContext/MusicLibraryAggregate/Entities/TrackTests.cs @@ -190,8 +190,8 @@ public class TrackTests { // Arrange Track track = _trackFixture.Create(); + string originalPath = track.Path; List originalMoods = [.. track.Moods]; - string path = "C:\\Music\\queen\\bohemian-rhapsody.flac"; AudioMetadata metadata = _audioMetadataFixture.Create(); Optional disambiguation = Optional.Some("remastered"); Optional discNumber = Optional.Some(2); @@ -206,7 +206,6 @@ public class TrackTests // Act Result result = track.UpdateDetails( - path, metadata, disambiguation, 7, @@ -221,7 +220,6 @@ public class TrackTests // Assert Assert.False(result.IsFailure); - Assert.Equal(path, track.Path); Assert.Equal(metadata, track.Metadata); Assert.Equal(disambiguation, track.Disambiguation); Assert.Equal(7, track.TrackNumber); @@ -235,7 +233,9 @@ public class TrackTests Assert.Equal(trackId, track.MusicBrainzTrackId); Assert.True(track.UpdatedOnUtc.HasValue); Assert.True(track.UpdatedOnUtc.Value >= beforeUpdate); - // the collections are not part of the details update + // The file system path is not part of the details update, it is set only when the track is created. + Assert.Equal(originalPath, track.Path); + // The collections are not part of the details update. Assert.Equal(originalMoods, track.Moods); } @@ -376,7 +376,6 @@ public class TrackTests // Act Result result = track.UpdateDetails( - "C:\\Music\\queen\\bohemian-rhapsody.flac", _audioMetadataFixture.Create(), Optional.None(), 11, diff --git a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs index 31623a6d..b52b6df2 100644 --- a/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs +++ b/tests/UnitTests/Lumina.Presentation.Api.UnitTests/Core/Endpoints/Library/AudioLibrary/MusicLibrary/Tracks/UpdateTrack/UpdateTrackEndpointTests.cs @@ -158,7 +158,6 @@ public class UpdateTrackEndpointTests command.ArtistId == artistId.ToString() && command.AlbumId == albumId.ToString() && command.TrackId == trackId.ToString() && - command.Path == request.Path && command.Metadata == request.Metadata && command.TrackNumber == request.TrackNumber && command.DiscNumber == request.DiscNumber &&