mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
refactor(test): use secure random method in integration test util (#6139)
This commit is contained in:
parent
e548eeaa15
commit
97b8201a57
1 changed files with 3 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
||||||
import crypto from 'node:crypto';
|
import crypto, { randomInt } from 'node:crypto';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
import { generateStandardId } from '@logto/shared';
|
import { generateStandardId } from '@logto/shared';
|
||||||
|
@ -37,10 +37,8 @@ export const generatePhone = (isE164?: boolean) => {
|
||||||
'232',
|
'232',
|
||||||
];
|
];
|
||||||
const centralOfficeCode =
|
const centralOfficeCode =
|
||||||
validCentralOfficeCodes[Math.floor(Math.random() * validCentralOfficeCodes.length)] ?? '205';
|
validCentralOfficeCodes[randomInt(0, validCentralOfficeCodes.length)] ?? '205';
|
||||||
const phoneNumber = Math.floor(Math.random() * 10_000)
|
const phoneNumber = randomInt(0, 10_000).toString().padStart(4, '0');
|
||||||
.toString()
|
|
||||||
.padStart(4, '0');
|
|
||||||
|
|
||||||
return plus + countryAndAreaCode + centralOfficeCode + phoneNumber;
|
return plus + countryAndAreaCode + centralOfficeCode + phoneNumber;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue