コード例 #1
0
def create_rk_enabled_u2f_authenticator(driver) -> WebDriver:

    options = VirtualAuthenticatorOptions()
    options.protocol = VirtualAuthenticatorOptions.Protocol.U2F
    options.has_resident_key = True
    driver.add_virtual_authenticator(options)
    return driver
コード例 #2
0
def test_remove_all_credentials(driver):
    options = VirtualAuthenticatorOptions()
    options.has_resident_key = True

    driver.add_virtual_authenticator(options)
    assert driver.virtual_authenticator_id is not None

    credential = Credential.create_non_resident_credential(
        bytearray({1, 2, 3, 4}),
        "localhost",
        b64decode(BASE64__ENCODED_PK),
        0,
    )

    credential2 = Credential.create_resident_credential(
        bytearray({1, 2, 3, 4, 5}),
        "localhost",
        bytearray({1}),
        b64decode(BASE64__ENCODED_PK),
        1,
    )

    driver.add_credential(credential)
    assert len(driver.get_credentials()) == 1

    driver.add_credential(credential2)
    assert len(driver.get_credentials()) == 2

    driver.remove_all_credentials()
    assert len(driver.get_credentials()) == 0

    driver.remove_virtual_authenticator()
コード例 #3
0
ファイル: webdriver.py プロジェクト: emoshin/selenium
 def add_virtual_authenticator(
         self, options: VirtualAuthenticatorOptions) -> None:
     """
     Adds a virtual authenticator with the given options.
     """
     self._authenticator_id = self.execute(
         Command.ADD_VIRTUAL_AUTHENTICATOR, options.to_dict())['value']
コード例 #4
0
def create_rk_disabled_authenticator(driver) -> WebDriver:
    options = VirtualAuthenticatorOptions()
    options.protocol = VirtualAuthenticatorOptions.Protocol.CTAP2
    options.transport = VirtualAuthenticatorOptions.Transport.USB
    options.has_resident_key = False
    options.has_user_verification = True
    options.is_user_verified = True
    driver.add_virtual_authenticator(options)
    return driver
コード例 #5
0
def create_rk_enabled_ctap2_authenticator(driver) -> WebDriver:
    options = VirtualAuthenticatorOptions()
    options.protocol = VirtualAuthenticatorOptions.Protocol.CTAP2
    options.has_resident_key = True
    options.has_user_verification = True
    options.is_user_verified = True
    driver.add_virtual_authenticator(options)
    return driver
コード例 #6
0
def test_full_virtual_authenticator(driver):

    options = VirtualAuthenticatorOptions()
    options.is_user_consenting = True
    options.protocol = VirtualAuthenticatorOptions.Protocol.U2F
    options.transport = VirtualAuthenticatorOptions.Transport.USB

    driver.add_virtual_authenticator(options)

    driver.get("https://webauthn.io/")
    username = driver.find_element(By.ID, "input-email")
    username.send_keys("username")

    selectAttestation = Select(driver.find_element(By.ID,
                                                   "select-attestation"))
    selectAttestation.select_by_visible_text("Direct")

    selectAuthenticator = Select(
        driver.find_element(By.ID, "select-authenticator"))
    selectAuthenticator.select_by_value("cross-platform")

    driver.find_element(By.ID, "register-button").click()

    login = driver.find_element(By.ID, "login-button")
    WebDriverWait(driver, 50).until(
        lambda x: x.find_element(By.ID, "login-button").is_displayed())
    login.click()

    WebDriverWait(driver, 40).until(
        lambda x: x.find_element(By.CLASS_NAME, "col-lg-12").is_displayed())

    source: str = driver.page_source

    if "You're logged in!" in source:
        assert True
    else:
        assert False
コード例 #7
0
def options():
    return VirtualAuthenticatorOptions()