Skip to content
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

fix: node-http-handler tests which require NODE_TLS_REJECT_UNAUTHORIZED=0 #244

Closed
trivikr opened this issue May 9, 2019 · 4 comments
Closed
Labels
blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. CI/CD This is related to CI/CD closed-for-staleness p2 This is a standard priority issue

Comments

@trivikr
Copy link
Member

trivikr commented May 9, 2019

While updating jest v20->v24 in #243, some node-http-handler tests were commented out to unblock Jest upgrade

/*it("can send https requests", async () => {
const mockResponse = {
statusCode: 200,
headers: {},
body: "test"
};
mockHttpsServer.addListener(
"request",
createResponseFunction(mockResponse)
);
const nodeHttpHandler = new NodeHttpHandler();
let response = await nodeHttpHandler.handle(
{
hostname: "localhost",
method: "GET",
port: mockHttpsServer.address().port,
protocol: "https:",
path: "/",
headers: {}
},
{}
);
expect(response.statusCode).toEqual(mockResponse.statusCode);
expect(response.headers).toBeDefined();
expect(response.headers).toMatchObject(mockResponse.headers);
expect(response.body).toBeDefined();
});
it("can send requests with bodies", async () => {
const body = Buffer.from("test");
const mockResponse = {
statusCode: 200,
headers: {}
};
mockHttpsServer.addListener(
"request",
createResponseFunction(mockResponse)
);
const spy = jest.spyOn(https, "request").mockImplementationOnce(() => {
let calls = spy.mock.calls;
let currentIndex = calls.length - 1;
return https.request(calls[currentIndex][0], calls[currentIndex][1]);
});
const nodeHttpHandler = new NodeHttpHandler();
let response = await nodeHttpHandler.handle(
{
hostname: "localhost",
method: "PUT",
port: mockHttpsServer.address().port,
protocol: "https:",
path: "/",
headers: {},
body
},
{}
);
expect(response.statusCode).toEqual(mockResponse.statusCode);
expect(response.headers).toBeDefined();
expect(response.headers).toMatchObject(mockResponse.headers);
});
it("can handle expect 100-continue", async () => {
const body = Buffer.from("test");
const mockResponse = {
statusCode: 200,
headers: {}
};
mockHttpsServer.addListener(
"checkContinue",
createContinueResponseFunction(mockResponse)
);
let endSpy: jest.SpyInstance<any>;
let continueWasTriggered = false;
const spy = jest.spyOn(https, "request").mockImplementationOnce(() => {
let calls = spy.mock.calls;
let currentIndex = calls.length - 1;
const request = https.request(
calls[currentIndex][0],
calls[currentIndex][1]
);
request.on("continue", () => {
continueWasTriggered = true;
});
endSpy = jest.spyOn(request, "end");
return request;
});
const nodeHttpHandler = new NodeHttpHandler();
let response = await nodeHttpHandler.handle(
{
hostname: "localhost",
method: "PUT",
port: mockHttpsServer.address().port,
protocol: "https:",
path: "/",
headers: {
Expect: "100-continue"
},
body
},
{}
);
expect(response.statusCode).toEqual(mockResponse.statusCode);
expect(response.headers).toBeDefined();
expect(response.headers).toMatchObject(mockResponse.headers);
expect(endSpy!.mock.calls.length).toBe(1);
expect(endSpy!.mock.calls[0][0]).toBe(body);
expect(continueWasTriggered).toBe(true);
});
it("can send requests with streaming bodies", async () => {
const body = new ReadFromBuffers({
buffers: [
Buffer.from("t"),
Buffer.from("e"),
Buffer.from("s"),
Buffer.from("t")
]
});
let inputBodySpy = jest.spyOn(body, "pipe");
const mockResponse = {
statusCode: 200,
headers: {}
};
mockHttpsServer.addListener(
"request",
createResponseFunction(mockResponse)
);
const nodeHttpHandler = new NodeHttpHandler();
let response = await nodeHttpHandler.handle(
{
hostname: "localhost",
method: "PUT",
port: mockHttpsServer.address().port,
protocol: "https:",
path: "/",
headers: {},
body
},
{}
);
expect(response.statusCode).toEqual(mockResponse.statusCode);
expect(response.headers).toBeDefined();
expect(response.headers).toMatchObject(mockResponse.headers);
expect(inputBodySpy.mock.calls.length).toBeTruthy();
});*/

These tests need to be fixed

@alexforsyth
Copy link
Contributor

Need to see if jest 26 fixes this issue

@alexforsyth alexforsyth added the blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. label Nov 12, 2020
@github-actions
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 13, 2021
@trivikr trivikr removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label Nov 13, 2021
@RanVaknin RanVaknin added the p2 This is a standard priority issue label Mar 15, 2023
Copy link

Greetings! We’re closing this issue because it has been open a long time and hasn’t been updated in a while and may not be getting the attention it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to comment or open a new issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Mar 15, 2024
Copy link

github-actions bot commented Apr 4, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked Work is blocked on this issue for this codebase. Other labels or comments may indicate why. CI/CD This is related to CI/CD closed-for-staleness p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

4 participants