Skip to content

Commit

Permalink
Added test for 406
Browse files Browse the repository at this point in the history
  • Loading branch information
jholleran committed Aug 15, 2024
1 parent 1cb8455 commit 8ae8c44
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
13 changes: 13 additions & 0 deletions e2e/browser/test-app/components/problemDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,19 @@ export default function ProblemDetailsClient({
}
handleProblemDetails={setProblemDetails}
/>

<RequestButton
id={"methodNotAllowed"}
name={"Method Not Allowed"}
performRequest={
// This request should get return a 405 response.
() =>
session.fetch(new URL("/.well-known/solid", storageUrl), {
method: "DELETE",
})
}
handleProblemDetails={setProblemDetails}
/>
</>
) : (
<></>
Expand Down
18 changes: 18 additions & 0 deletions e2e/browser/test/e2e.playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,21 @@ test("403 problem details error", async ({ page, auth }) => {
"The server application intentionally responded with an HTTP error response status.",
);
});

test("405 problem details error", async ({ page, auth }) => {
await auth.login({ allow: true });
await waitFor(page);

await Promise.all([
page.waitForRequest((request) => request.method() === "DELETE"),
page.waitForResponse((response) => response.status() === 406),
page.click("button[data-testid=methodNotAllowed]"),
]);

await expectProblemDetails(
page,
"406",
"Method Not Allowed",
"The server application intentionally responded with an HTTP error response status.",
);
});
22 changes: 22 additions & 0 deletions e2e/node/error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,26 @@ describe(`End-to-end error description test for ${ENV.environment}`, () => {
expect(error.problemDetails.detail).toBeDefined();
expect(error.problemDetails.instance).toBeDefined();
});

it("returns an RFC9457 error response for method not allowed request", async () => {
const podRoot = await getPodRoot(authenticatedSession);
const response = await authenticatedSession.fetch(
new URL("/.well-known/solid", podRoot),
{
method: "DELETE",
},
);
const responseBody = await response.text();
const error = handleErrorResponse(
response,
responseBody,
"Some error message",
);
expect(error).toBeInstanceOf(ForbiddenError);
expect(error.message).toBe("Some error message");
expect(error.problemDetails.status).toBe(406);
expect(error.problemDetails.title).toBe("Method Not Found");
expect(error.problemDetails.detail).toBeDefined();
expect(error.problemDetails.instance).toBeDefined();
});
});

0 comments on commit 8ae8c44

Please sign in to comment.