Skip to content

Commit

Permalink
test: auth.hook() uses app auth for "https://api.github.com/app/insta…
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 8, 2019
1 parent 60abe4f commit b8b5910
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,41 @@ test("auth.hook() creates token and uses it for succeeding requests", async () =
expect(mock.done()).toBe(true);
});

test("auth.hook() uses app auth for full URLs", async () => {
const mock = fetchMock
.sandbox()
.getOnce("https://api.github.com/app/installations?per_page=100", [], {
headers: {
authorization: `bearer ${BEARER}`
}
});

const auth = createAppAuth({
id: APP_ID,
privateKey: PRIVATE_KEY
});

const requestWithMock = request.defaults({
headers: {
"user-agent": "test"
},
request: {
fetch: mock
}
});
const requestWithAuth = requestWithMock.defaults({
request: {
hook: auth.hook
}
});

await requestWithAuth("GET https://api.github.com/app/installations", {
per_page: 100
});

expect(mock.done()).toBe(true);
});

test("oauth endpoint error", async () => {
const requestMock = request.defaults({
headers: {
Expand Down

0 comments on commit b8b5910

Please sign in to comment.