-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(signups): add more allowed hosts than fflogs
- Loading branch information
1 parent
87ec756
commit 08fbadd
Showing
8 changed files
with
85 additions
and
20 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { plainToInstance } from 'class-transformer'; | ||
import { validate } from 'class-validator'; | ||
import { Encounter } from '../../encounters/encounters.consts.js'; | ||
import { SignupInteractionDto } from './signup-interaction.dto.js'; | ||
import { PROG_PROOF_HOSTS_WHITELIST } from './signup.consts.js'; | ||
|
||
function createBaseObject(proofOfProgLink: string) { | ||
return { | ||
availability: 'test', | ||
character: 'test', | ||
discordId: 'test', | ||
role: 'test', | ||
progPointRequested: 'test', | ||
encounter: Encounter.TOP, | ||
proofOfProgLink, | ||
username: 'test', | ||
world: 'test', | ||
}; | ||
} | ||
|
||
describe('SignupInteractionDto', () => { | ||
it.each(PROG_PROOF_HOSTS_WHITELIST)( | ||
'should allow URLs from host %s', | ||
async (host) => { | ||
const dto = plainToInstance( | ||
SignupInteractionDto, | ||
createBaseObject(`${host.source.replace(/\\/g, '')}`), | ||
); | ||
const errors = await validate(dto); | ||
expect(errors).toHaveLength(0); | ||
}, | ||
); | ||
|
||
it('should not allow URLs not in the whitelist', async () => { | ||
const dto = plainToInstance( | ||
SignupInteractionDto, | ||
createBaseObject('https://not-in-whitelist.com/test'), | ||
); | ||
const errors = await validate(dto); | ||
expect(errors).toHaveLength(1); | ||
expect(errors[0].property).toBe('proofOfProgLink'); | ||
}); | ||
}); |
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
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