Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add new tests for TOTP formDetector (#1788)
Leendert de Borst5a63ea7803ba
diff --git a/apps/browser-extension/src/utils/formDetector/FieldPatterns.ts b/apps/browser-extension/src/utils/formDetector/FieldPatterns.tsindex 6ee06e11e..c9f371222 100644--- a/apps/browser-extension/src/utils/formDetector/FieldPatterns.ts+++ b/apps/browser-extension/src/utils/formDetector/FieldPatterns.ts@@ -50,7 +50,7 @@ export const EnglishFieldPatterns: FieldPatterns = {birthDateDay: ['-day', 'birthdate_d', 'birthdayday', '_day', 'day'],birthDateMonth: ['-month', 'birthdate_m', 'birthdaymonth', '_month', 'month'],birthDateYear: ['-year', 'birthdate_y', 'birthdayyear', '_year', 'year'],- totp: ['totp', 'otp', 'one-time', 'onetime', 'token', 'authenticator', '2fa', 'twofa', 'two-factor', 'mfa', 'security-code', 'auth-code', 'passcode', 'pin-code', 'pincode']+ totp: ['totp', 'otp', 'one-time', 'onetime', 'token', 'authenticator', '2fa', 'twofa', 'two-factor', 'mfa', 'security-code', 'auth-code', 'passcode', 'pin-code', 'pincode', 'google_code', 'verification-code', 'verificationcode']};/**diff --git a/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.totp.test.ts b/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.totp.test.tsindex e1ebfda3f..91d8b64a6 100644--- a/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.totp.test.ts+++ b/apps/browser-extension/src/utils/formDetector/__tests__/FormDetector.totp.test.ts@@ -24,4 +24,10 @@ describe('FormDetector TOTP tests', () => {testField(FormField.Totp, 'two-fa-challenge-authenticator_pc_input_0', htmlFile);});++ describe('English TOTP form 3 detection (Google Authenticator style)', () => {+ const htmlFile = 'en-totp-form3.html';++ testField(FormField.Totp, 'google_code', htmlFile);+ });});diff --git a/apps/browser-extension/src/utils/formDetector/__tests__/test-forms/en-totp-form3.html b/apps/browser-extension/src/utils/formDetector/__tests__/test-forms/en-totp-form3.htmlnew file mode 100644index 000000000..7517a635c--- /dev/null+++ b/apps/browser-extension/src/utils/formDetector/__tests__/test-forms/en-totp-form3.html@@ -0,0 +1,23 @@+<!DOCTYPE html>+<html>+<head>+ <title>Google Authenticator (TFA)</title>+</head>+<body>+ <div class="login-container-box" id="signin-section">+ <div class="login-box">+ <h3 class="ph-title"><span>Google Authenticator (TFA)</span></h3>+ <div style="padding-left: 0">+ <p>Exécutez l'application Google Authenticator sur votre appareil mobile et entrez le code de vérification dans le champ ci-dessous.</p>+ </div>+ <form action="/validate_google_token" method="post">+ <input type="hidden" name="authenticity_token" value="asdasdasdasd+vyR/2jVQ==" />+ <div class="col-12 form-group">+ <input id="google_code" name="google_code" type="text" value="" class="form-control" required autocomplete="off" placeholder="Saisir le Code" />+ </div>+ <input type="submit" id="loginbutt" class="ph-default-button orange-button" value="Se connecter"/>+ </form>+ </div>+ </div>+</body>+</html>