|
1 | 1 | import { createPrivateKey, X509Certificate } from 'node:crypto'; |
2 | 2 | import { readFileSync } from 'node:fs'; |
| 3 | +import { request } from 'node:http'; |
3 | 4 |
|
4 | | -import got from 'got'; // eslint-disable-line import/no-unresolved |
5 | 5 | import nock from 'nock'; |
6 | 6 | import { importJWK } from 'jose'; |
7 | 7 | import sinon from 'sinon'; |
@@ -448,24 +448,42 @@ describe('client authentication options', () => { |
448 | 448 | .expect(tokenAuthSucceeded); |
449 | 449 | }); |
450 | 450 |
|
451 | | - // TODO: not sure why when mounted everything crap out |
452 | | - if (!process.env.MOUNT_VIA) { |
453 | | - it('can use transfer-encoding: chunked', async () => { |
454 | | - const { address, port } = global.server.address(); |
| 451 | + it('can use transfer-encoding: chunked', function (done) { |
| 452 | + const { address, port } = global.server.address(); |
| 453 | + |
| 454 | + const req = request({ |
| 455 | + hostname: address, |
| 456 | + port, |
| 457 | + path: this.suitePath(route), |
| 458 | + method: 'POST', |
| 459 | + headers: { |
| 460 | + 'Content-Type': 'application/x-www-form-urlencoded', |
| 461 | + 'Transfer-Encoding': 'chunked', |
| 462 | + }, |
| 463 | + }, (res) => { |
| 464 | + let data = ''; |
455 | 465 |
|
456 | | - const response = await got.post(`http://[${address}]:${port}${route}`, { |
457 | | - throwHttpErrors: false, |
458 | | - form: { |
459 | | - grant_type: 'foo', |
460 | | - client_id: 'client-post', |
461 | | - client_secret: 'secret', |
462 | | - }, |
463 | | - headers: { 'transfer-encoding': 'chunked' }, |
| 466 | + res.on('data', (chunk) => { |
| 467 | + data += chunk; |
| 468 | + }); |
| 469 | + |
| 470 | + res.on('end', () => { |
| 471 | + try { |
| 472 | + expect(JSON.parse(data)).to.deep.eql(tokenAuthSucceeded); |
| 473 | + done(); |
| 474 | + } catch (err) { |
| 475 | + done(err); |
| 476 | + } |
464 | 477 | }); |
465 | 478 |
|
466 | | - expect(JSON.parse(response.body)).to.deep.eql(tokenAuthSucceeded); |
| 479 | + res.on('error', done); |
467 | 480 | }); |
468 | | - } |
| 481 | + |
| 482 | + req.write('grant_type=foo&client_id'); |
| 483 | + req.write('=client-post&client_secret=secret'); |
| 484 | + req.end(); |
| 485 | + req.on('error', done); |
| 486 | + }); |
469 | 487 |
|
470 | 488 | it('accepts the auth (but client configured with basic)', function () { |
471 | 489 | return this.agent.post(route) |
|
0 commit comments