@@ -11,6 +11,7 @@ import * as github from '@actions/github'
1111import { mockFulcio , mockRekor , mockTSA } from '@sigstore/mock'
1212import * as oci from '@sigstore/oci'
1313import nock from 'nock'
14+ import { MockAgent , setGlobalDispatcher } from 'undici'
1415import { SEARCH_PUBLIC_GOOD_URL } from '../src/endpoints'
1516import * as main from '../src/main'
1617
@@ -31,6 +32,10 @@ summaryWriteMock.mockImplementation(async () => Promise.resolve(core.summary))
3132// Mock the action's main function
3233const runMock = jest . spyOn ( main , 'run' )
3334
35+ // MockAgent for mocking @actions /github
36+ const mockAgent = new MockAgent ( )
37+ setGlobalDispatcher ( mockAgent )
38+
3439describe ( 'action' , ( ) => {
3540 // Capture original environment variables and GitHub context so we can restore
3641 // them after each test
@@ -63,8 +68,12 @@ describe('action', () => {
6368 . query ( { audience : 'sigstore' } )
6469 . reply ( 200 , { value : oidcToken } )
6570
66- nock ( 'https://api.github.com' )
67- . post ( / ^ \/ r e p o s \/ .* \/ .* \/ a t t e s t a t i o n s $ / )
71+ mockAgent
72+ . get ( 'https://api.github.com' )
73+ . intercept ( {
74+ path : / ^ \/ r e p o s \/ .* \/ .* \/ a t t e s t a t i o n s $ / ,
75+ method : 'post'
76+ } )
6877 . reply ( 201 , { id : attestationID } )
6978
7079 process . env = {
0 commit comments