|
1 | 1 | import { TOTP } from 'totp-generator'; |
2 | 2 |
|
3 | | -afterEach(() => cy.db_getUserId().then((uid) => cy.task('queryDB', `DELETE FROM #__user_mfa WHERE user_id = ${uid}`))); |
4 | | - |
5 | 3 | describe('Test in backend that the user', () => { |
| 4 | + afterEach(() => cy.db_getUserId().then((uid) => cy.task('queryDB', `DELETE FROM #__user_mfa WHERE user_id = ${uid}`))); |
| 5 | + |
6 | 6 | it('can login with Multi-factor Authentication (email)', () => { |
7 | 7 | cy.doAdministratorLogin(); |
8 | 8 | cy.visit('/administrator/index.php?option=com_users&view=users'); |
@@ -80,6 +80,44 @@ describe('Test in backend that the user', () => { |
80 | 80 | cy.get('#com-users-methods-reset-message').contains('not enabled'); |
81 | 81 | }); |
82 | 82 |
|
| 83 | + it('can login with Multi-factor Authentication (passkey)', { browser: '!firefox' }, () => { |
| 84 | + Cypress.automation('remote:debugger:protocol', { command: 'WebAuthn.enable', params: {} }).then(() => { |
| 85 | + Cypress.automation('remote:debugger:protocol', { |
| 86 | + command: 'WebAuthn.addVirtualAuthenticator', |
| 87 | + params: { |
| 88 | + options: { |
| 89 | + protocol: 'ctap2', transport: 'internal', hasResidentKey: true, hasUserVerification: true, isUserVerified: true, |
| 90 | + }, |
| 91 | + }, |
| 92 | + }); |
| 93 | + }); |
| 94 | + cy.doAdministratorLogin(); |
| 95 | + cy.visit('/administrator/index.php?option=com_users&view=users'); |
| 96 | + cy.get('.header-profile:visible').click(); |
| 97 | + cy.get('.header-profile a.dropdown-item').contains('Edit Account').click(); |
| 98 | + cy.get('#myTab div[role="tablist"] button[aria-controls="multifactorauth"]').click(); |
| 99 | + cy.get('.com-users-methods-list-method-name-webauthn a.com-users-methods-list-method-addnew').click(); |
| 100 | + cy.get('#com-users-method-edit-title').clear().type('Test Passkey'); |
| 101 | + cy.get('#toolbar-user-mfa-edit-save').click(); |
| 102 | + cy.get('.com-users-methods-list-method-name-webauthn .com-users-methods-list-method-record').contains('Test Passkey'); |
| 103 | + cy.clickToolbarButton('Cancel'); |
| 104 | + cy.doAdministratorLogout(); |
| 105 | + cy.get('#mod-login-username').type(Cypress.env('username')); |
| 106 | + cy.get('#mod-login-password').type(Cypress.env('password')); |
| 107 | + cy.get('#form-login').submit(); |
| 108 | + cy.get('#users-mfa-title').contains('Passkey'); |
| 109 | + cy.get('#toolbar-user-mfa-submit').click(); |
| 110 | + cy.visit('/administrator/index.php?option=com_users&view=users'); |
| 111 | + cy.get('.header-profile:visible').click(); |
| 112 | + cy.get('.header-profile a.dropdown-item').contains('Edit Account').click(); |
| 113 | + cy.get('#myTab div[role="tablist"] button[aria-controls="multifactorauth"]').click(); |
| 114 | + cy.get('#com-users-methods-reset-message').contains('is enabled'); |
| 115 | + cy.get('.com-users-methods-list-method-name-webauthn a.com-users-methods-list-method-record-delete').click(); |
| 116 | + cy.on('window:confirm', (text) => expect(text).to.contains('Are you sure you want to delete?')); |
| 117 | + cy.get('#com-users-methods-reset-message').contains('not enabled'); |
| 118 | + cy.then(() => Cypress.automation('remote:debugger:protocol', { command: 'WebAuthn.disable', params: {} })); |
| 119 | + }); |
| 120 | + |
83 | 121 | it('can login with Multi-factor Authentication (backup codes)', () => { |
84 | 122 | cy.doAdministratorLogin(); |
85 | 123 | cy.visit('/administrator/index.php?option=com_users&view=users'); |
|
0 commit comments