1
- import { createServer } from "http" ;
2
1
import { readFileSync } from "fs" ;
3
-
4
- import fetch from "node-fetch" ;
5
2
import { sign } from "@octokit/webhooks-methods" ;
6
3
7
- import { Webhooks , createNodeMiddleware } from "../../src" ;
4
+ import { Webhooks } from "../../src" ;
8
5
9
6
const pushEventPayloadString = readFileSync (
10
7
"test/fixtures/push-payload.json" ,
@@ -18,40 +15,6 @@ describe("Deprecations", () => {
18
15
pushEventPayloadString
19
16
) ;
20
17
} ) ;
21
- test ( "onUnhandledRequest" , async ( ) => {
22
- const spy = jest . spyOn ( console , "error" ) ;
23
- const webhooks = new Webhooks ( {
24
- secret : "mySecret" ,
25
- } ) ;
26
-
27
- const server = createServer (
28
- createNodeMiddleware ( webhooks , {
29
- onUnhandledRequest ( _request , response ) {
30
- response . writeHead ( 404 ) ;
31
- response . end ( "nope" ) ;
32
- } ,
33
- } )
34
- ) . listen ( ) ;
35
-
36
- // @ts -expect-error complains about { port } although it's included in returned AddressInfo interface
37
- const { port } = server . address ( ) ;
38
-
39
- await fetch ( `http://localhost:${ port } /api/github/webhooks` , {
40
- method : "PUT" ,
41
- headers : {
42
- "X-GitHub-Delivery" : "123e4567-e89b-12d3-a456-426655440000" ,
43
- "X-GitHub-Event" : "push" ,
44
- "X-Hub-Signature-256" : signatureSha256 ,
45
- } ,
46
- body : "invalid" ,
47
- } ) ;
48
-
49
- expect ( spy ) . toBeCalledWith (
50
- "[@octokit/webhooks] `onUnhandledRequest()` is deprecated and will be removed in a future release of `@octokit/webhooks`"
51
- ) ;
52
- spy . mockClear ( ) ;
53
- server . close ( ) ;
54
- } ) ;
55
18
56
19
test ( "webhooks.verify(payload, signature) with object payload" , async ( ) => {
57
20
const spy = jest . spyOn ( console , "error" ) ;
0 commit comments