mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	refactor: replace math.random with crypto
This commit is contained in:
		| @@ -102,7 +102,7 @@ describe('Utility Methods', () => { | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	describe('UUID generation', () => { | ||||
| 	describe('UUID generation / secureRandom', () => { | ||||
| 		it('return unique random value every time', () => { | ||||
| 			delete require.cache[require.resolve('../src/utils')]; | ||||
| 			const { generateUUID } = require('../src/utils'); | ||||
| @@ -110,6 +110,19 @@ describe('Utility Methods', () => { | ||||
| 			const uuid2 = generateUUID(); | ||||
| 			assert.notEqual(uuid1, uuid2, 'matches'); | ||||
| 		}); | ||||
|  | ||||
| 		it('should return a random number between 1-10 inclusive', () => { | ||||
| 			const { secureRandom } = require('../src/utils'); | ||||
| 			const r1 = secureRandom(1, 10); | ||||
| 			assert(r1 >= 1); | ||||
| 			assert(r1 <= 10); | ||||
| 		}); | ||||
|  | ||||
| 		it('should always return 3', () => { | ||||
| 			const { secureRandom } = require('../src/utils') | ||||
| 			const r1 = secureRandom(3, 3); | ||||
| 			assert.strictEqual(r1, 3); | ||||
| 		}); | ||||
| 	}); | ||||
|  | ||||
| 	describe('cleanUpTag', () => { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user