mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 13:35:42 +09:00
ci: add tests (#1141)
This commit is contained in:
1 parent
ad99de22bc
commit
545814abc1
152 files changed
+287
-532
No files matched your search
@@ -30,7 +30,12 @@ describe('Email verification flow', () => {
|
||||
await harness?.shutdown();
|
||||
});
|
||||
it('allows resending verification email and verifying email', async () => {
|
||||
const account = await createTestAccount(harness);
|
||||
const account = await createTestAccount(harness, {skipEmailVerification: true});
|
||||
await createBuilderWithoutAuth(harness)
|
||||
.post(`/test/users/${account.userId}/security-flags`)
|
||||
.body({email_verified: false})
|
||||
.expect(200)
|
||||
.execute();
|
||||
await createBuilder(harness, account.token).post('/auth/verify/resend').body({}).expect(204).execute();
|
||||
const emails = await listTestEmails(harness, {recipient: account.email});
|
||||
const verificationEmail = findLastTestEmail(emails, 'email_verification');
|
||||
|
||||
@@ -22,8 +22,17 @@ describe('MFA requires verified email', () => {
|
||||
afterAll(async () => {
|
||||
await harness?.shutdown();
|
||||
});
|
||||
it('rejects TOTP enablement for unverified accounts', async () => {
|
||||
async function createUnverifiedAccount() {
|
||||
const account = await createTestAccount(harness, {skipEmailVerification: true});
|
||||
await createBuilder(harness, '')
|
||||
.post(`/test/users/${account.userId}/security-flags`)
|
||||
.body({email_verified: false})
|
||||
.expect(200)
|
||||
.execute();
|
||||
return account;
|
||||
}
|
||||
it('rejects TOTP enablement for unverified accounts', async () => {
|
||||
const account = await createUnverifiedAccount();
|
||||
const secret = createTotpSecret();
|
||||
const {json} = await createBuilder<ErrorResponse>(harness, account.token)
|
||||
.post('/users/@me/mfa/totp/enable')
|
||||
@@ -33,7 +42,7 @@ describe('MFA requires verified email', () => {
|
||||
expect(json.code).toBe(APIErrorCodes.MFA_EMAIL_VERIFICATION_REQUIRED);
|
||||
});
|
||||
it('rejects WebAuthn registration setup for unverified accounts', async () => {
|
||||
const account = await createTestAccount(harness, {skipEmailVerification: true});
|
||||
const account = await createUnverifiedAccount();
|
||||
const {json} = await createBuilder<ErrorResponse>(harness, account.token)
|
||||
.post('/users/@me/mfa/webauthn/credentials/registration-options')
|
||||
.body({password: account.password})
|
||||
|
||||
@@ -187,7 +187,9 @@ describe('Phone verification flow', () => {
|
||||
await allowPhoneVerification(account.userId);
|
||||
const config = getConfig();
|
||||
const previousInboundNumber = config.sms.inboundChallengeNumber;
|
||||
const previousInboundPrefixes = config.abusePolicy.phoneVerification.inboundRequiredPrefixes;
|
||||
config.sms.inboundChallengeNumber = '+15551234567';
|
||||
config.abusePolicy.phoneVerification.inboundRequiredPrefixes = ['+998'];
|
||||
try {
|
||||
const response = await createBuilder<{
|
||||
channel: string;
|
||||
@@ -207,6 +209,7 @@ describe('Phone verification flow', () => {
|
||||
expect(response.challenge_code).toMatch(/^\d{6}$/);
|
||||
} finally {
|
||||
config.sms.inboundChallengeNumber = previousInboundNumber;
|
||||
config.abusePolicy.phoneVerification.inboundRequiredPrefixes = previousInboundPrefixes;
|
||||
}
|
||||
});
|
||||
it('does not let clients force SMS for inbound-only prefixes', async () => {
|
||||
@@ -214,7 +217,9 @@ describe('Phone verification flow', () => {
|
||||
await allowPhoneVerification(account.userId);
|
||||
const config = getConfig();
|
||||
const previousInboundNumber = config.sms.inboundChallengeNumber;
|
||||
const previousInboundPrefixes = config.abusePolicy.phoneVerification.inboundRequiredPrefixes;
|
||||
config.sms.inboundChallengeNumber = '+15551234567';
|
||||
config.abusePolicy.phoneVerification.inboundRequiredPrefixes = ['+593'];
|
||||
try {
|
||||
const response = await createBuilder<{
|
||||
channel: string;
|
||||
@@ -233,6 +238,7 @@ describe('Phone verification flow', () => {
|
||||
});
|
||||
} finally {
|
||||
config.sms.inboundChallengeNumber = previousInboundNumber;
|
||||
config.abusePolicy.phoneVerification.inboundRequiredPrefixes = previousInboundPrefixes;
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user