Public Access
Let a team change hands, and be joined by somebody with no account yet
M3 built teams and stopped short of the two operations that decide who controls one. Both were written down as refusals rather than omissions: ADR 0009 listed ownership transfer under "deliberately not built", and design-import-gaps said an invitation needed "a token with a lifetime and an outbound mail path". One of those reasons had expired and the other never applied — an invitation does not need a token if it is not a thing anybody presents. Handing a team over is one write. The member you name becomes owner and you become an admin, in a single transaction, because ownership is sole: promoting first leaves the team owned twice, demoting first leaves it owned by nobody, and there is nobody left with the authority to finish a transfer that stopped in the middle. That is also why it is not two calls to the role endpoint, which refuses Owner outright. The outgoing owner is demoted rather than removed — removing them would revoke their vault key grants and flag every team vault for rekey, which is a far larger act than the one asked for, and somebody handing over a team is usually staying in it. It unblocks the thing that was impossible before: an owner can now leave, by handing the team on first. An invitation is a standing instruction rather than a message. This server has no outbound mail path, so nothing is sent and there is nothing for the invitee to present. The row says the next account signing in with that address joins this team at this role, and telling them to sign in is the caller's job over a channel this server does not carry. A link nobody can deliver would be worse than none. It lives in its own table rather than becoming a membership with MembershipStatus.Invited, and that member stays unwritten for the reason it always was: team_membership.user_id is not nullable and carries a foreign key, so somebody who has never signed in has nothing for that row to point at. Widening it would make the unique index on (team, user) meaningless, because PostgreSQL counts every NULL as distinct. Verification is the security boundary, and nothing in this server read it before. A claim requires the access token to assert email_verified. An invitation decides what the server will serve, so one claimable by anybody able to obtain a token carrying somebody else's address is a way into a team — which is precisely the attack OidcOptions.AllowEmailLinking exists to refuse, and it would have been reintroduced by the back door. There is deliberately no setting that relaxes it: a flag that exists is one somebody turns on for the afternoon their provider is misconfigured. Absence is refused rather than trusted, and logged, because a provider that never sends the claim otherwise leaves every invitation pending with nothing anywhere saying why. Claiming happens at just-in-time provisioning and again on an hourly sweep. The sweep is what makes it recoverable rather than one-shot — an invitation issued between an account being created and that person next signing in would otherwise be stranded for ever — and it shares its rate with the last-seen write because both are housekeeping nobody is waiting on. Archiving is refused while a team owns a vault, and that refusal is the end of the road rather than a step on it. A team vault is readable because of membership, so archiving one that still owned vaults would take them away from everybody holding a key, including the caller, quietly and all at once. Nothing in this product deletes a vault, so no order of operations gets past it today — which is stated with a count of what is in the way, for the reason the SFTP layer refuses a recursive delete: a refusal is visible and a quiet removal is not. It is owner-only, as handing over is; renaming is not, because a rename is visible to everybody and reversible by anybody who can do it. The slug is not renameable at all: it is unique only among live teams, so a rename could take one an archived team is still holding, and that team could then never be restored. LAST ACTIVE is real and coarse on purpose. UserAccount.LastSeenAtUtc is refreshed on ordinary authenticated requests, at most once per account per hour, through ExecuteUpdateAsync — user_account carries the xmin concurrency token, so a read-then-write on the hot path would start losing races between one user's own overlapping requests. An hour is the granularity the question is actually asked at, and the interface draws it to the day rather than the minute so it does not read as a precision that is not there. The remarks in Contracts and in the view model that argued at length for the column's absence are rewritten rather than extended; both had become false. Two endpoints already existed and nothing called them. ChangeTeamMemberRole and ListVaultGrants have been reachable since M3. The role picker refuses Owner itself rather than letting the server do it, since the interface already knew the rule; the key-holder list sits under the vault rather than beside the member, because a grant is per vault and a count on a member row would imply per-item sharing, which is M5. It lists withdrawn and stale grants and says which they are — a list that dropped them would show a departed colleague as merely absent rather than as somebody whose key was taken away — and staleness is decided by comparing generations, since a grant can be Active and still open nothing. ADD MEMBER stopped being a dead end. An address the directory did not know used to end at a sentence telling the user their colleague had to sign in first. It invites them instead, from the same button, because which of the two applies is a fact about the server's account table rather than about what the user is doing; which one happened is reported afterwards, because that decides what they do next. An address that merely has an account is invited rather than refused: refusing would have made the endpoint an oracle for which addresses have accounts here, answerable by anybody willing to create a team first. The phone has a TEAMS screen, behind MORE, and it is the reverse of every other row in design-import-gaps: a shipped screen the design had no slot for. It is there because an invitation is claimed by signing in, so somebody told they are now in a team is at least as likely to be holding a phone — and a membership visible only on a head they never installed is one they cannot see. It draws SHARE KEY and nothing that takes something away: wrapping a key is the one act on that screen a server cannot perform at all, and the desktop guards its revocations with a tooltip, which is a control a touch screen cannot show. Two defects were found by an adversarial pass and both were green against the whole suite at the time. The owner-only check on archiving and handing over had been weakened to the admin check while their messages and comments still said owner — and since nothing behind the archive endpoint re-checks it, an admin the owner had promoted could have archived the team out from under them. And the rename endpoint built its response with a hardcoded Owner role, so an admin who renamed a team was handed a summary claiming they owned it, and a client trusting that instead of re-listing would have offered them the two owner-only buttons the server then refuses. The new table gets its constraints tested rather than merely migrated: live uniqueness per (team, address), the citext proof that an address typed by a person matches one cased by a provider, and reissue after both revocation and acceptance. The teams screen gets its first entries in the layout suite, at the minimum window with every list populated and with each of the two states that cover half of it — it had none, and it just grew four sections and a second line in the member row. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1403,6 +1403,88 @@ public sealed class ScreenLayoutTests : IAsyncLifetime
|
||||
failure)));
|
||||
|
||||
/// <summary>Lays the vault screen out at the width it gets once the nav rail has taken its column.</summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The teams screen had no entry in this suite at all until it grew four sections — a rename form, an
|
||||
/// armed confirmation, an invitations list and a key-holders list — plus a second line in the member
|
||||
/// row. Its right-hand column is the narrowest measured here: the window's minimum is 1016, the nav
|
||||
/// rail takes 190 and the team list 268, leaving 558 for everything above.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Every list is seeded, and seeded with the long rows rather than the convenient ones — see
|
||||
/// <see cref="StubTeamServer"/>. The two states that hide half the screen, the rename form and the
|
||||
/// confirmation, are measured in their own tests below rather than here, because a control that is
|
||||
/// collapsed when the window is laid out is a control this suite has not checked.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public Task TheTeamsScreen_FitsWithEveryListPopulated() =>
|
||||
OnTheTeamsScreenAsync(
|
||||
teams => { },
|
||||
window => LayoutHarness.Unreachable(window)
|
||||
.ShouldBeEmpty("the teams screen with members, invitations and key holders"));
|
||||
|
||||
/// <remarks>
|
||||
/// The rename form is drawn in place, above the members list, and pushes everything below it down.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public Task TheTeamsScreen_FitsWhileRenamingATeam() =>
|
||||
OnTheTeamsScreenAsync(
|
||||
teams => teams.RenameTeamCommand.Execute(null),
|
||||
window => LayoutHarness.Unreachable(window)
|
||||
.ShouldBeEmpty("the teams screen with the rename form open"));
|
||||
|
||||
/// <remarks>
|
||||
/// The armed confirmation carries two sentences of prose and replaces the header's buttons. It is the
|
||||
/// tallest thing that can appear above the members list, so it is the case most likely to push the
|
||||
/// key-holders list off the bottom.
|
||||
/// </remarks>
|
||||
[Fact]
|
||||
public Task TheTeamsScreen_FitsWhileConfirmingAnArchive() =>
|
||||
OnTheTeamsScreenAsync(
|
||||
teams => teams.ArchiveTeamCommand.Execute(null),
|
||||
window => LayoutHarness.Unreachable(window)
|
||||
.ShouldBeEmpty("the teams screen with the archive confirmation armed"));
|
||||
|
||||
/// <remarks>
|
||||
/// A real <c>TeamsViewModel</c> over a stub server rather than the unlocked vault the rest of this
|
||||
/// suite uses, because nothing on this screen is vault content: it is read from the server on open.
|
||||
/// The session function answers null, which is the state a member is in before anybody has wrapped
|
||||
/// them a key — and it is also the one that draws the most text, since every vault row then carries
|
||||
/// the "waiting for a key" sentence.
|
||||
/// </remarks>
|
||||
private static async Task OnTheTeamsScreenAsync(
|
||||
Action<TeamsViewModel> arrange,
|
||||
Action<Window> assert)
|
||||
{
|
||||
using var teamServer = new StubTeamServer();
|
||||
|
||||
var teams = new TeamsViewModel(() => teamServer, () => null);
|
||||
|
||||
await teams.LoadAsync(Token);
|
||||
|
||||
await LayoutHarness.OnTheUiThreadAsync(
|
||||
() =>
|
||||
{
|
||||
arrange(teams);
|
||||
|
||||
var screen = new TeamsScreen { DataContext = teams };
|
||||
|
||||
var window = LayoutHarness.HostAtMinimumSize(
|
||||
screen, LayoutHarness.ScreenWidth, LayoutHarness.ScreenHeight);
|
||||
|
||||
try
|
||||
{
|
||||
assert(window);
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
},
|
||||
Token);
|
||||
}
|
||||
|
||||
private Task MeasureVaultAsync(Action<IReadOnlyList<string>> assert) =>
|
||||
OnTheVaultAsync((_, window) => assert(LayoutHarness.Unreachable(window)));
|
||||
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
using DodoSSH.Client.Api;
|
||||
using DodoSSH.Client.Auth;
|
||||
using DodoSSH.Client.Session;
|
||||
using DodoSSH.Client.Sync;
|
||||
using DodoSSH.Contracts;
|
||||
|
||||
namespace DodoSSH.Client.App.Layout.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The least server a <c>TeamsViewModel</c> needs in order to be laid out with something in it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// The teams screen is the one screen in this suite whose content cannot come from an unlocked vault,
|
||||
/// because none of it is vault content: a team, its members, its invitations and who holds a key to a
|
||||
/// vault are all read from the server on open, and the suite's <c>FakeAccountServer</c> implements
|
||||
/// <see cref="IAccountApi"/> and nothing else. Rather than teach that fake five more interfaces for one
|
||||
/// screen, this serves fixed rows and refuses everything a layout test has no business calling.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// The rows are deliberately the <em>long</em> ones. A layout suite that measured "Bob" in a column sized
|
||||
/// for an email address would certify a shape no real team produces — so the names, addresses and status
|
||||
/// sentences here are at or near the length the interface can really be handed, which is what makes an
|
||||
/// overflow show up at the minimum window rather than on somebody's screen.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal sealed class StubTeamServer : IVaultServer, ITeamApi, IVaultGrantApi
|
||||
{
|
||||
private static readonly Guid OwnerId = Guid.CreateVersion7();
|
||||
private static readonly Guid ColleagueId = Guid.CreateVersion7();
|
||||
private static readonly Guid TeamId = Guid.CreateVersion7();
|
||||
private static readonly Guid VaultId = Guid.CreateVersion7();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Uri ServerUrl { get; } = new("https://dodossh.example");
|
||||
|
||||
/// <inheritdoc />
|
||||
public ITeamApi Teams => this;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IVaultGrantApi Grants => this;
|
||||
|
||||
/// <inheritdoc />
|
||||
public IAccountApi Account => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public ISyncApi Sync => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IDirectoryApi Directory => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public IKeyBindingAuthorizer KeyBinding => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public SyncOptions SyncOptions => new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public string? RefreshToken => null;
|
||||
|
||||
/// <summary>The vault whose key holders are listed, so a test can select it.</summary>
|
||||
internal static Guid TeamVaultId => VaultId;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<IReadOnlyList<TeamSummary>> ListTeamsAsync(CancellationToken cancellationToken) =>
|
||||
Task.FromResult<IReadOnlyList<TeamSummary>>(
|
||||
[
|
||||
new TeamSummary(
|
||||
TeamId,
|
||||
"Platform Engineering",
|
||||
"platform-engineering",
|
||||
"Everything that runs the estate.",
|
||||
TeamMemberRole.Owner,
|
||||
MemberCount: 2,
|
||||
VaultCount: 1,
|
||||
DateTimeOffset.UnixEpoch),
|
||||
]);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<IReadOnlyList<TeamMemberSummary>> ListTeamMembersAsync(
|
||||
Guid teamId,
|
||||
CancellationToken cancellationToken) =>
|
||||
Task.FromResult<IReadOnlyList<TeamMemberSummary>>(
|
||||
[
|
||||
new TeamMemberSummary(
|
||||
OwnerId,
|
||||
"alexandra.hollingsworth@dodotech.example",
|
||||
"Alexandra Hollingsworth",
|
||||
TeamMemberRole.Owner,
|
||||
TeamMemberStatus.Active,
|
||||
IsEnrolled: true,
|
||||
DateTimeOffset.UnixEpoch,
|
||||
DateTimeOffset.UnixEpoch),
|
||||
|
||||
// The unenrolled case on purpose: its key-state phrase is the longest the column ever
|
||||
// carries, and it is the row that decides whether that column is wide enough.
|
||||
new TeamMemberSummary(
|
||||
ColleagueId,
|
||||
"bartholomew.fotheringay@dodotech.example",
|
||||
"Bartholomew Fotheringay",
|
||||
TeamMemberRole.Member,
|
||||
TeamMemberStatus.Active,
|
||||
IsEnrolled: false,
|
||||
DateTimeOffset.UnixEpoch,
|
||||
LastActiveAt: null),
|
||||
]);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<IReadOnlyList<TeamInvitationSummary>> ListTeamInvitationsAsync(
|
||||
Guid teamId,
|
||||
CancellationToken cancellationToken) =>
|
||||
Task.FromResult<IReadOnlyList<TeamInvitationSummary>>(
|
||||
[
|
||||
// Pending, because its sentence is the long one — it has to carry the whole mechanism,
|
||||
// since nothing was sent and there is nothing else on the screen that could say so.
|
||||
new TeamInvitationSummary(
|
||||
Guid.CreateVersion7(),
|
||||
"wilhelmina.ashworth-blake@dodotech.example",
|
||||
TeamMemberRole.Admin,
|
||||
TeamInvitationState.Pending,
|
||||
OwnerId,
|
||||
DateTimeOffset.UnixEpoch,
|
||||
DateTimeOffset.UnixEpoch.AddDays(14),
|
||||
AcceptedAt: null),
|
||||
]);
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<VaultGrantsResponse> ListVaultGrantsAsync(
|
||||
Guid vaultId,
|
||||
CancellationToken cancellationToken) =>
|
||||
Task.FromResult(new VaultGrantsResponse(
|
||||
vaultId,
|
||||
KeyGeneration: 2,
|
||||
RekeyRequired: true,
|
||||
Grants:
|
||||
[
|
||||
new VaultGrantSummary(
|
||||
OwnerId,
|
||||
"alexandra.hollingsworth@dodotech.example",
|
||||
"Alexandra Hollingsworth",
|
||||
KeyGeneration: 2,
|
||||
VaultGrantState.Active,
|
||||
OwnerId,
|
||||
DateTimeOffset.UnixEpoch,
|
||||
RevokedAt: null),
|
||||
|
||||
// A generation behind, so the "stale" phrasing is the one being measured rather than
|
||||
// the two-word happy case.
|
||||
new VaultGrantSummary(
|
||||
ColleagueId,
|
||||
"bartholomew.fotheringay@dodotech.example",
|
||||
"Bartholomew Fotheringay",
|
||||
KeyGeneration: 1,
|
||||
VaultGrantState.Active,
|
||||
OwnerId,
|
||||
DateTimeOffset.UnixEpoch,
|
||||
RevokedAt: null),
|
||||
]));
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TeamSummary> CreateTeamAsync(
|
||||
CreateTeamRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TeamSummary> UpdateTeamAsync(
|
||||
Guid teamId,
|
||||
UpdateTeamRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<bool> ArchiveTeamAsync(Guid teamId, CancellationToken cancellationToken) =>
|
||||
throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task TransferTeamOwnershipAsync(
|
||||
Guid teamId,
|
||||
TransferTeamOwnershipRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TeamMemberSummary> AddTeamMemberAsync(
|
||||
Guid teamId,
|
||||
AddTeamMemberRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TeamMemberSummary> ChangeTeamMemberRoleAsync(
|
||||
Guid teamId,
|
||||
Guid userId,
|
||||
ChangeTeamMemberRoleRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<bool> RemoveTeamMemberAsync(
|
||||
Guid teamId,
|
||||
Guid userId,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<TeamInvitationSummary> CreateTeamInvitationAsync(
|
||||
Guid teamId,
|
||||
CreateTeamInvitationRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<bool> RevokeTeamInvitationAsync(
|
||||
Guid teamId,
|
||||
Guid invitationId,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<VaultSummary> CreateTeamVaultAsync(
|
||||
Guid teamId,
|
||||
CreateTeamVaultRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task IssueVaultGrantAsync(
|
||||
Guid vaultId,
|
||||
IssueVaultGrantRequest request,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<bool> RevokeVaultGrantAsync(
|
||||
Guid vaultId,
|
||||
Guid userId,
|
||||
CancellationToken cancellationToken) => throw new NotSupportedException();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
// Nothing held.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user