Skip to content

Commit

Permalink
Don't generate examples for password with a random string (#1042)
Browse files Browse the repository at this point in the history
* generate a single known string for password related fields
  • Loading branch information
scbedd authored Jul 13, 2024
1 parent 4b59d8e commit d24383e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log - oav

## 07/12/2024 3.4.0

- During example generation, fields `password`, `adminPassword`, and `pwd` are all generated with a single value of "<a-password-goes-here>" instead of random characters.

## 06/17/2024 3.3.8

- Remove suppression of `additionalProperties` errors when `isArmCall === true`. (ARM liveValidation scenarios)
Expand Down
6 changes: 6 additions & 0 deletions lib/generator/mocker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ export default class Mocker {
}

private generateString(paramSpec: any, paramName: string) {
const pwdParams = ["password", "pwd", "adminPassword"];

if (paramSpec.name === "subscriptionId") {
return uuid.v4().toUpperCase();
}

if (pwdParams.includes(paramName)) {
return "<a-password-goes-here>";
}

if (paramSpec.format === "date") {
return new Date().toISOString().split("T")[0];
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oav",
"version": "3.3.8",
"version": "3.4.0",
"author": {
"name": "Microsoft Corporation",
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion test/liveValidatorTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ describe("Live Validator", () => {
const result = await liveValidator.validateLiveRequestResponse(payload);

assert.strictEqual(result.responseValidationResult.errors.length, 1);
assert.strictEqual(result.responseValidationResult.errors[0].code, "INVALID_TYPE")
assert.strictEqual(result.responseValidationResult.errors[0].code, "INVALID_TYPE");
assert.strictEqual(result.responseValidationResult.isSuccessful, false);
assert.strictEqual(result.requestValidationResult.isSuccessful, true);
});
Expand Down

0 comments on commit d24383e

Please sign in to comment.