-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: add support for in-memory client certificates #952
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e9ac3cb
feat: add support for in-memory client certificates
emilioalvap 48184f9
Fix unit test
emilioalvap 95e52e7
Add missing unit tests for stringified certificate
emilioalvap 1e39b5b
Add pfx to pw options reviver
emilioalvap e867d85
Adjust certificate unit test properties
emilioalvap 6145794
Merge branch 'main' into clientcert-in-memory-update
vigneshshanmugam c64818e
Add validation for cert paths when pushing to cloud
emilioalvap c8e6503
Apply suggestions from code review
emilioalvap 406fd6a
Update snapshots
emilioalvap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ export async function readConfig( | |
options = await optionsPromise; | ||
} | ||
} | ||
|
||
return options; | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -77,7 +77,15 @@ export async function normalizeOptions( | |
*/ | ||
const playwrightOpts = merge( | ||
config.playwrightOptions, | ||
cliArgs.playwrightOptions || {} | ||
cliArgs.playwrightOptions || {}, | ||
{ | ||
arrayMerge(target, source) { | ||
if (source && source.length > 0) { | ||
return [...new Set(source)]; | ||
} | ||
return target; | ||
}, | ||
} | ||
); | ||
options.playwrightOptions = { | ||
...playwrightOpts, | ||
|
@@ -195,7 +203,7 @@ export function getCommonCommandOpts() { | |
const playwrightOpts = createOption( | ||
'--playwright-options <jsonstring>', | ||
'JSON object to pass in custom Playwright options for the agent. Options passed will be merged with Playwright options defined in your synthetics.config.js file.' | ||
).argParser(JSON.parse); | ||
).argParser(parsePlaywrightOptions); | ||
|
||
const pattern = createOption( | ||
'--pattern <pattern>', | ||
|
@@ -237,3 +245,35 @@ export function getCommonCommandOpts() { | |
match, | ||
}; | ||
} | ||
|
||
export function parsePlaywrightOptions(playwrightOpts: string) { | ||
return JSON.parse(playwrightOpts, (key, value) => { | ||
if (key !== 'clientCertificates') { | ||
return value; | ||
} | ||
|
||
// Revive serialized clientCertificates buffer objects | ||
return (value ?? []).map(item => { | ||
const revived = { ...item }; | ||
if (item.cert && !Buffer.isBuffer(item.cert)) { | ||
revived.cert = parseAsBuffer(item.cert); | ||
} | ||
if (item.key && !Buffer.isBuffer(item.key)) { | ||
revived.key = parseAsBuffer(item.key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we need to do the same for |
||
} | ||
if (item.pfx && !Buffer.isBuffer(item.pfx)) { | ||
revived.pfx = parseAsBuffer(item.pfx); | ||
} | ||
|
||
return revived; | ||
}); | ||
}); | ||
} | ||
|
||
function parseAsBuffer(value: any): Buffer { | ||
try { | ||
return Buffer.from(value); | ||
} catch (e) { | ||
return value; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test for non-buffer values as we discussed.