Skip to content

Commit

Permalink
refactor(test): use secure random method in integration test util
Browse files Browse the repository at this point in the history
  • Loading branch information
charIeszhao committed Jun 29, 2024
1 parent 7ba579f commit 22bff3d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/integration-tests/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import crypto from 'node:crypto';
import crypto, { randomInt } from 'node:crypto';
import path from 'node:path';

import { generateStandardId } from '@logto/shared';
Expand Down Expand Up @@ -37,10 +37,8 @@ export const generatePhone = (isE164?: boolean) => {
'232',
];
const centralOfficeCode =
validCentralOfficeCodes[Math.floor(Math.random() * validCentralOfficeCodes.length)] ?? '205';
const phoneNumber = Math.floor(Math.random() * 10_000)
.toString()
.padStart(4, '0');
validCentralOfficeCodes[randomInt(0, validCentralOfficeCodes.length)] ?? '205';
const phoneNumber = randomInt(0, 10_000).toString().padStart(4, '0');

return plus + countryAndAreaCode + centralOfficeCode + phoneNumber;
};
Expand Down

0 comments on commit 22bff3d

Please sign in to comment.