-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from AikidoSec/undici-v7
Test all supported undici versions: v4, v5, v6 and v7
- Loading branch information
Showing
16 changed files
with
525 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import type { ReportingAPI } from "../agent/api/ReportingAPI"; | ||
import type { Token } from "../agent/api/Token"; | ||
import { __internalRewritePackageName } from "../agent/hooks/wrapRequire"; | ||
import type { Logger } from "../agent/logger/Logger"; | ||
import { Wrapper } from "../agent/Wrapper"; | ||
import { createTestAgent } from "./createTestAgent"; | ||
|
||
type PackageName = string; | ||
type AliasToRequire = string; | ||
|
||
/** | ||
* Start a test agent for testing purposes | ||
*/ | ||
export function startTestAgent(opts: { | ||
block?: boolean; | ||
logger?: Logger; | ||
api?: ReportingAPI; | ||
token?: Token; | ||
serverless?: string; | ||
wrappers: Wrapper[]; | ||
rewrite: Record<PackageName, AliasToRequire>; | ||
}) { | ||
const agent = createTestAgent(opts); | ||
agent.start(opts.wrappers); | ||
|
||
// In order to support multiple versions of the same package, we need to rewrite the package name | ||
// e.g. In our sources and sinks, we use the real package name `hooks.addPackage("undici")` | ||
// but in the tests we want to `require("undici-v6")` instead of `require("undici")` | ||
// The `__internalRewritePackageName` function allows us to do this | ||
Object.keys(opts.rewrite).forEach((packageName) => { | ||
__internalRewritePackageName(packageName, opts.rewrite[packageName]); | ||
}); | ||
|
||
return agent; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.