Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/mobile/src/features/cloud/linkEnvironment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ describe("mobile cloud link environment client", () => {
Response.json(
{
_tag: "EnvironmentHttpUnauthorizedError",
message: "Invalid environment bearer session.",
reason: "cloud_cli_authorization_required",
message: "Run `t3 connect link` to authorize this environment.",
},
{ status: 401 },
),
Expand All @@ -623,7 +624,7 @@ describe("mobile cloud link environment client", () => {
).pipe(Effect.flip);
expect(error._tag).toBe("CloudEnvironmentLinkError");
expect(error.message).toBe(
"Could not obtain environment link proof: Invalid environment bearer session.",
"Could not obtain environment link proof: Run `t3 connect link` to authorize this environment.",
);
expect(fetchMock).toHaveBeenCalledTimes(2);
}),
Expand Down
26 changes: 26 additions & 0 deletions apps/server/src/auth/EnvironmentAuth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
.pipe(Effect.flip);

expect(error._tag).toBe("ServerAuthScopeNotGrantedError");
if (error._tag === "ServerAuthScopeNotGrantedError") {
expect(error.requestedScopes).toEqual(["orchestration:read", "access:write"]);
expect(error.grantedScopes).toEqual([
"orchestration:read",
"orchestration:operate",
"terminal:operate",
"review:write",
"relay:read",
]);
}
}).pipe(Effect.provide(makeEnvironmentAuthLayer())),
);

Expand Down Expand Up @@ -252,4 +262,20 @@ it.layer(NodeServices.layer)("EnvironmentAuth.layer", (it) => {
),
),
);

it.effect("retains both session ids when rejecting self-revocation", () =>
Effect.gen(function* () {
const serverAuth = yield* EnvironmentAuth.EnvironmentAuth;
const issued = yield* serverAuth.issueSession();
const error = yield* serverAuth
.revokeClientSession(issued.sessionId, issued.sessionId)
.pipe(Effect.flip);

expect(error._tag).toBe("ServerAuthForbiddenOperationError");
if (error._tag === "ServerAuthForbiddenOperationError") {
expect(error.currentSessionId).toBe(issued.sessionId);
expect(error.targetSessionId).toBe(issued.sessionId);
}
}).pipe(Effect.provide(makeEnvironmentAuthLayer())),
);
});
Loading
Loading