I want to test using virtual authenticator for Webauthn passkey flow using Karate. So that it could be automated and won’t require actual authentication.
You can simply interact with chrome devtools to set virtual authenticator.
Karate has this capability DevTools Protocol Tips
Following is a simple feature file for webatuhn.io using virtual authenticator.
Feature: Authentication success flow for FIDO.
Background:
* configure driver = { type: 'chrome', showDriverLog: true }
Scenario: Verify authentication is successful
Given driver 'https://webauthn.io/'
* driver.send({ method: 'WebAuthn.enable' })
* driver.send({ method: 'WebAuthn.addVirtualAuthenticator', params: { options: {"protocol": 'ctap2', "transport": 'internal', "hasUserVerification": true, "isUserVerified": true, "hasResidentKey": true }}})
And input('#input-email', 'dummy')
And click('#register-button')
// wait here for a second or two
And click('#login-button')
This approach might work only for Chrome, I have not explored it further. Just wanted to add this if anyone needed.