-
Notifications
You must be signed in to change notification settings - Fork 0
fix(capture): require write access for board attachment #3310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5ced929
test(capture): reproduce Viewer board-attachment authorization gap
Chris0Jeky 770b487
test(capture): add authenticated Viewer attachment negative
Chris0Jeky ff77d8a
fix(capture): require write access for board attachment
Chris0Jeky 553ad71
test(capture): import shared error codes
Chris0Jeky cac5fe0
test(capture): align dual-write fixture with write authorization
Chris0Jeky 2026199
test(capture): keep authorization usernames within contract
Chris0Jeky 3311e01
test(capture): align fixtures with write authorization
Chris0Jeky a38a890
fix(capture): serialize board authorization with enqueue
Chris0Jeky 86eca5d
fix(capture): hide board entry points for viewers
Chris0Jeky e336ccb
fix(capture): hide column capture for viewers
Chris0Jeky 0a77af8
fix(auth): refresh tracked board access before capture
Chris0Jeky 34fb5c8
fix: protect queued capture board writes
Chris0Jeky f642869
test(frontend): align BoardView fixture with write capability
Chris0Jeky aec449b
test(api): reload board access before mutation
Chris0Jeky f06012f
fix(inbox): gate scoped capture by board write access
Chris0Jeky 2dac12e
fix(queue): normalize capture request types before authorization
Chris0Jeky 7704fb1
Fix scoped Inbox capture escape hatch
Chris0Jeky 3c37b19
Preserve direct nib capture callers
Chris0Jeky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
backend/tests/Taskdeck.Api.Tests/BoardAccessRepositoryFreshnessTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| using FluentAssertions; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Taskdeck.Domain.Entities; | ||
| using Taskdeck.Domain.Enums; | ||
| using Taskdeck.Infrastructure.Persistence; | ||
| using Taskdeck.Infrastructure.Repositories; | ||
| using Xunit; | ||
|
|
||
| namespace Taskdeck.Api.Tests; | ||
|
|
||
| public sealed class BoardAccessRepositoryFreshnessTests | ||
| { | ||
| [Fact] | ||
| public async Task GetByBoardAndUserAsync_reads_role_changes_after_an_earlier_read() | ||
| { | ||
| var dbPath = Path.Combine(Path.GetTempPath(), $"taskdeck-board-access-freshness-{Guid.NewGuid():N}.db"); | ||
| try | ||
| { | ||
| var options = new DbContextOptionsBuilder<TaskdeckDbContext>() | ||
| .UseSqlite(TestSqlite.ConnectionString(dbPath)) | ||
| .Options; | ||
|
|
||
| var owner = new User("access-freshness-owner", $"access-freshness-owner-{Guid.NewGuid():N}@example.com", "hash"); | ||
| var member = new User("access-freshness-member", $"access-freshness-member-{Guid.NewGuid():N}@example.com", "hash"); | ||
| var board = new Board("Access freshness", ownerId: owner.Id); | ||
| var access = new BoardAccess(board.Id, member.Id, UserRole.Editor, owner.Id); | ||
|
|
||
| await using (var seed = new TaskdeckDbContext(options)) | ||
| { | ||
| await seed.Database.MigrateAsync(); | ||
| seed.Users.AddRange(owner, member); | ||
| seed.Boards.Add(board); | ||
| seed.BoardAccesses.Add(access); | ||
| await seed.SaveChangesAsync(); | ||
| } | ||
|
|
||
| await using var reader = new TaskdeckDbContext(options); | ||
| var repository = new BoardAccessRepository(reader); | ||
| var initial = await repository.GetByBoardAndUserAsync(board.Id, member.Id); | ||
| initial!.Role.Should().Be(UserRole.Editor); | ||
|
|
||
| await using (var writer = new TaskdeckDbContext(options)) | ||
| { | ||
| var persisted = await writer.BoardAccesses.SingleAsync(value => | ||
| value.BoardId == board.Id && value.UserId == member.Id); | ||
| persisted.UpdateRole(UserRole.Viewer, owner.Id); | ||
| await writer.SaveChangesAsync(); | ||
| } | ||
|
|
||
| var refreshed = await repository.GetByBoardAndUserAsync(board.Id, member.Id); | ||
| refreshed!.Role.Should().Be(UserRole.Viewer); | ||
| } | ||
| finally | ||
| { | ||
| foreach (var suffix in new[] { "", "-wal", "-shm", "-journal" }) | ||
| { | ||
| try { File.Delete(dbPath + suffix); } | ||
| catch (IOException) { } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.