-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Rajdip Bhattacharya <[email protected]>
- Loading branch information
1 parent
443f8d4
commit ad9a808
Showing
7 changed files
with
337 additions
and
13 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { generateSecretValue } from './secret' | ||
|
||
describe('generateSecretValue', () => { | ||
test('should generate a string of exactly 20 characters', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toHaveLength(20) | ||
}) | ||
|
||
test('should include at least one digit', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/\d/) | ||
}) | ||
|
||
test('should include at least one lowercase letter', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/[a-z]/) | ||
}) | ||
|
||
test('should include at least one uppercase letter', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/[A-Z]/) | ||
}) | ||
|
||
test('should include at least one special character', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/[!@#$%^&*]/) | ||
}) | ||
|
||
test('should only include allowed characters', () => { | ||
const secret = generateSecretValue() | ||
expect(secret).toMatch(/^[0-9a-zA-Z!@#$%^&*]{20}$/) | ||
}) | ||
|
||
test('should generate different values for consecutive calls', () => { | ||
const secret1 = generateSecretValue() | ||
const secret2 = generateSecretValue() | ||
expect(secret1).not.toBe(secret2) | ||
}) | ||
}) |
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
2 changes: 2 additions & 0 deletions
2
apps/api/src/prisma/migrations/20250123150220_add_rotate_after_in_secret/migration.sql
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Secret" ADD COLUMN "rotateAfter" INTEGER; |
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
Oops, something went wrong.