Combines the two installation requests (org and user) into one because
`/org/{org}` can also be accessed at `/users/{org}`.
---------
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import { test } from "./main.js";
|
|
|
|
// Verify retries work when getting a token for a user or organization fails on the first attempt.
|
|
await test((mockPool) => {
|
|
process.env.INPUT_OWNER = "smockle";
|
|
delete process.env.INPUT_REPOSITORIES;
|
|
|
|
// Mock installation ID and app slug request
|
|
const mockInstallationId = "123456";
|
|
const mockAppSlug = "github-actions";
|
|
mockPool
|
|
.intercept({
|
|
path: `/users/${process.env.INPUT_OWNER}/installation`,
|
|
method: "GET",
|
|
headers: {
|
|
accept: "application/vnd.github.v3+json",
|
|
"user-agent": "actions/create-github-app-token",
|
|
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
|
|
},
|
|
})
|
|
.reply(500, "GitHub API not available");
|
|
mockPool
|
|
.intercept({
|
|
path: `/users/${process.env.INPUT_OWNER}/installation`,
|
|
method: "GET",
|
|
headers: {
|
|
accept: "application/vnd.github.v3+json",
|
|
"user-agent": "actions/create-github-app-token",
|
|
// Intentionally omitting the `authorization` header, since JWT creation is not idempotent.
|
|
},
|
|
})
|
|
.reply(
|
|
200,
|
|
{ id: mockInstallationId, app_slug: mockAppSlug },
|
|
{ headers: { "content-type": "application/json" } }
|
|
);
|
|
});
|