fix(connect): refresh relay credentials before expiry (#9178)
Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
1 parent
a19f01fc19
commit
9e646ad84c
8 files changed
+153
-9
No files matched your search
@@ -5,7 +5,10 @@ import * as Option from "effect/Option";
|
||||
|
||||
import { PrimaryConnectionTarget, type PreparedConnection } from "../connection/model.ts";
|
||||
import { remoteHttpClientLayer } from "../rpc/http.ts";
|
||||
import { fetchEnvironmentPullRequestDiff } from "./pullRequestDiffHttp.ts";
|
||||
import {
|
||||
fetchEnvironmentPullRequestDiff,
|
||||
PullRequestDiffCredentialRejectedError,
|
||||
} from "./pullRequestDiffHttp.ts";
|
||||
|
||||
const TARGET = new PrimaryConnectionTarget({
|
||||
environmentId: EnvironmentId.make("environment-1"),
|
||||
@@ -77,4 +80,41 @@ describe("fetchEnvironmentPullRequestDiff", () => {
|
||||
});
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("gives rejected diff sessions a recovery action", () =>
|
||||
Effect.gen(function* () {
|
||||
const fetchFn = (() =>
|
||||
Promise.resolve(
|
||||
Response.json(
|
||||
{
|
||||
_tag: "EnvironmentAuthInvalidError",
|
||||
code: "auth_invalid",
|
||||
reason: "invalid_credential",
|
||||
traceId: "trace-auth-test",
|
||||
},
|
||||
{ status: 401 },
|
||||
),
|
||||
)) satisfies typeof fetch;
|
||||
|
||||
const error = yield* fetchEnvironmentPullRequestDiff({
|
||||
prepared: PREPARED,
|
||||
signer: Option.none(),
|
||||
diff: {
|
||||
projectId: ProjectId.make("project-1"),
|
||||
repository: "owner/repository",
|
||||
number: 42,
|
||||
},
|
||||
}).pipe(Effect.provide(remoteHttpClientLayer(fetchFn)), Effect.flip);
|
||||
|
||||
expect(error).toBeInstanceOf(PullRequestDiffCredentialRejectedError);
|
||||
expect(error).toMatchObject({
|
||||
repository: "owner/repository",
|
||||
number: 42,
|
||||
traceId: "trace-auth-test",
|
||||
});
|
||||
expect(error.message).toBe(
|
||||
"This environment session is no longer valid (invalid_credential). Refresh the page or quit and reopen T3 Code.",
|
||||
);
|
||||
}),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user