mirror of
https://github.com/vector-im/element-call.git
synced 2026-04-03 07:10:26 +00:00
Count 404 as a connection failure
This commit is contained in:
@@ -59,9 +59,22 @@ test("getSFUConfigWithOpenID throws if connection fails", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("getSFUConfigWithOpenID throws if server returns error", async () => {
|
||||
test("getSFUConfigWithOpenID throws if endpoint is not found", async () => {
|
||||
await withFetchSpy(async (fetch) => {
|
||||
fetch.mockResolvedValue({ ok: false, status: 404 } as Response);
|
||||
await expect(async () =>
|
||||
getSFUConfigWithOpenID(mockClient, mockFocus),
|
||||
).rejects.toThrowError(expect.any(AuthConnectionFailedError));
|
||||
});
|
||||
});
|
||||
|
||||
test("getSFUConfigWithOpenID throws if endpoint returns error", async () => {
|
||||
await withFetchSpy(async (fetch) => {
|
||||
fetch.mockResolvedValue({
|
||||
ok: false,
|
||||
status: 503,
|
||||
text: async () => Promise.resolve("Internal server error"),
|
||||
} as Response);
|
||||
await expect(async () =>
|
||||
getSFUConfigWithOpenID(mockClient, mockFocus),
|
||||
).rejects.toThrowError(expect.any(AuthConnectionRejectedError));
|
||||
|
||||
@@ -104,7 +104,13 @@ async function getLiveKitJWT(
|
||||
throw new AuthConnectionFailedError(livekitServiceURL, e);
|
||||
}
|
||||
if (!res.ok) {
|
||||
throw new AuthConnectionRejectedError(livekitServiceURL, res.status);
|
||||
throw res.status === 404
|
||||
? new AuthConnectionFailedError(livekitServiceURL)
|
||||
: new AuthConnectionRejectedError(
|
||||
livekitServiceURL,
|
||||
res.status,
|
||||
await res.text(),
|
||||
);
|
||||
}
|
||||
return await res.json();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user