我想使用空手道使用虚拟身份验证器来测试 Webauthn 密钥流程。这样它就可以自动化并且不需要实际的身份验证。
您可以简单地与 chrome devtools 交互来设置虚拟身份验证器。
Karate 有这个能力 DevTools 协议提示
以下是使用虚拟身份验证器的 webatuhn.io 的简单功能文件。
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')
这种方法可能只适用于 Chrome,我还没有进一步探索。只是想如果有人需要的话添加这个。