Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: v20 #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: rewrite agent-ca tests with undici
  • Loading branch information
wolfy1339 committed Jul 10, 2023
commit 8a9a24e020eb73b5b702fac8463bd59b0a33560e
36 changes: 35 additions & 1 deletion 36 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion 3 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"semantic-release": "^21.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^29.0.0",
"typescript": "^5.0.0"
"typescript": "^5.0.0",
"undici": "^5.22.1"
},
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
Expand Down
44 changes: 33 additions & 11 deletions 44 test/integration/agent-ca/agent-ca-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const https = require("https");
const { readFileSync } = require("fs");
const { resolve } = require("path");
const { fetch: undiciFetch, Agent } = require("undici");

const { Octokit } = require("../../..");
const ca = readFileSync(resolve(__dirname, "./ca.crt"));

describe.skip("custom client certificate", () => {
describe("custom client certificate", () => {
let server;
before((done) => {
server = https.createServer(
Expand All @@ -26,13 +26,23 @@ describe.skip("custom client certificate", () => {
server.listen(0, done);
});

it("https.Agent({ca})", () => {
const agent = new https.Agent({
ca,
it("undici.Agent({ca})", () => {
const agent = new Agent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
connect: { ca: ca },
});
const myFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: agent,
});
};
const octokit = new Octokit({
baseUrl: "https://localhost:" + server.address().port,
request: { agent },
request: {
fetch: myFetch,
},
});

return octokit.rest.repos.get({
Expand All @@ -41,14 +51,26 @@ describe.skip("custom client certificate", () => {
});
});

it("https.Agent({ca, rejectUnauthorized})", () => {
const agent = new https.Agent({
ca: "invalid",
rejectUnauthorized: false,
it("undici.Agent({ca, rejectUnauthorized})", () => {
const agent = new Agent({
keepAliveTimeout: 10,
keepAliveMaxTimeout: 10,
connect: {
ca: "invalid",
rejectUnauthorized: true,
},
});
const myFetch = (url, opts) => {
return undiciFetch(url, {
...opts,
dispatcher: agent,
});
};
const octokit = new Octokit({
baseUrl: "https://localhost:" + server.address().port,
request: { agent },
request: {
fetch: myFetch,
},
});

return octokit.rest.repos.get({
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.