-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: introduce dedicated option for GitHub API endpoint (#829)
Server and API endpoints can be different. Some code parts, e.g. issue parsing, need the server endpoint and we should make this explicit.
- Loading branch information
1 parent
9443145
commit 908ff83
Showing
9 changed files
with
131 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,7 +263,7 @@ test("Verify package, token and repository with environment variables", async (t | |
]); | ||
}); | ||
|
||
test("Verify package, token and repository access with alternative environment varialbes", async (t) => { | ||
test("Verify package, token and repository access with alternative environment variables", async (t) => { | ||
const owner = "test_user"; | ||
const repo = "test_repo"; | ||
const env = { | ||
|
@@ -299,6 +299,79 @@ test("Verify package, token and repository access with alternative environment v | |
t.true(fetch.done()); | ||
}); | ||
|
||
test("Verify package, token and repository access with custom API URL", async (t) => { | ||
const owner = "test_user"; | ||
const repo = "test_repo"; | ||
const env = { GH_TOKEN: "github_token" }; | ||
const githubUrl = "https://othertesturl.com:9090"; | ||
const githubApiUrl = "https://api.othertesturl.com:9090"; | ||
|
||
const fetch = fetchMock | ||
.sandbox() | ||
.getOnce(`https://api.othertesturl.com:9090/repos/${owner}/${repo}`, { | ||
permissions: { push: true }, | ||
}); | ||
|
||
await t.notThrowsAsync( | ||
verify( | ||
{ githubUrl, githubApiUrl }, | ||
{ | ||
env, | ||
options: { repositoryUrl: `github:${owner}/${repo}` }, | ||
logger: t.context.logger, | ||
}, | ||
{ | ||
Octokit: TestOctokit.defaults((options) => ({ | ||
...options, | ||
request: { ...options.request, fetch }, | ||
})), | ||
}, | ||
), | ||
); | ||
|
||
t.true(fetch.done()); | ||
t.deepEqual(t.context.log.args[0], [ | ||
"Verify GitHub authentication (%s)", | ||
"https://api.othertesturl.com:9090", | ||
]); | ||
}); | ||
|
||
test("Verify package, token and repository access with API URL in environment variable", async (t) => { | ||
const owner = "test_user"; | ||
const repo = "test_repo"; | ||
const env = { | ||
GITHUB_URL: "https://othertesturl.com:443", | ||
GITHUB_API_URL: "https://api.othertesturl.com:443", | ||
GITHUB_TOKEN: "github_token", | ||
}; | ||
|
||
const fetch = fetchMock | ||
.sandbox() | ||
.getOnce(`https://api.othertesturl.com:443/repos/${owner}/${repo}`, { | ||
permissions: { push: true }, | ||
}); | ||
|
||
await t.notThrowsAsync( | ||
verify( | ||
{}, | ||
{ | ||
env, | ||
options: { | ||
repositoryUrl: `[email protected]:${owner}/${repo}.git`, | ||
}, | ||
logger: t.context.logger, | ||
}, | ||
{ | ||
Octokit: TestOctokit.defaults((options) => ({ | ||
...options, | ||
request: { ...options.request, fetch }, | ||
})), | ||
}, | ||
), | ||
); | ||
t.true(fetch.done()); | ||
}); | ||
|
||
test('Verify "proxy" is a String', async (t) => { | ||
const owner = "test_user"; | ||
const repo = "test_repo"; | ||
|