diff --git a/tests/test_verify_registration_response_android_key.py b/tests/test_verify_registration_response_android_key.py index 4608d38..9c08a55 100644 --- a/tests/test_verify_registration_response_android_key.py +++ b/tests/test_verify_registration_response_android_key.py @@ -1,5 +1,4 @@ from unittest import TestCase -from unittest.mock import MagicMock, patch from webauthn.helpers import base64url_to_bytes from webauthn.helpers.structs import AttestationFormat @@ -7,28 +6,32 @@ class TestVerifyRegistrationResponseAndroidKey(TestCase): - @patch("OpenSSL.crypto.X509StoreContext.verify_certificate") - def test_verify_attestation_android_key( - self, - mock_verify_certificate: MagicMock, - ) -> None: - # Mocked because response is from FIDO Conformance with unknown root certs - mock_verify_certificate.return_value = True + def test_verify_attestation_android_key_hardware_authority(self): + """ + This android-key attestation was generated on a Pixel 8a in January 2025 via an origin + trial. Google will be sunsetting android-safetynet attestation for android-key attestations + for device-bound passkeys (i.e. `"residentKey": "discouraged"`) in April 2025 + See here for more info: + https://android-developers.googleblog.com/2024/09/attestation-format-change-for-android-fido2-api.html + """ credential = """{ - "id": "V51GE29tGbhby7sbg1cZ_qL8V8njqEsXpAnwQBobvgw", - "rawId": "V51GE29tGbhby7sbg1cZ_qL8V8njqEsXpAnwQBobvgw", + "id": "AYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N0", + "rawId": "AYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N0", "response": { - "attestationObject": "o2NmbXRrYW5kcm9pZC1rZXlnYXR0U3RtdKNjYWxnJmNzaWdYRzBFAiAbZhfcF0KSXj5rdEevvnBcC8ZfRQlNl9XYWRTiIGKSHwIhAIerc7jWjOF_lJ71n_GAcaHwDUtPxkjAAdYugnZ4QxkmY3g1Y4JZAxowggMWMIICvaADAgECAgEBMAoGCCqGSM49BAMCMIHkMUUwQwYDVQQDDDxGQUtFIEFuZHJvaWQ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Q604izBQ_9Wp3lJiAAiYwB9jxT3-IiCRCPpPZboWxJzL3gg318WETVS3OYugEi5QWxVckxPP4m5y2H4iqhYW5r2_VH3f-T3ynjWmO0Vf4fwOyVWB8_T3u-O7goOWo3rjFXWCvDdkuXgKI578D3Wh4ubZQc6rrCfd6wHivYQhApvqNNUa7mxgJx1alevQBRWpwAE92Av4fuomC4HDT2iObrE0ivDY6hysMqy52T-iSv8DCoTI8rD1acyVCAsgrDWs4MbY29T2hHcZUZ0yRQFm60vxW4WQRFAa3q9DY4LDSxXjtUyS5htpwr_HJkWJFys8k9vjXOBtCP1cATIsoId7HRJ0OvH61ZQOobwC3YkcaGF1dGhEYXRhWMVJlg3liA6MaHQ0Fw9kdmBbj-SuuaKGMseZXPO6gx2XY0UAAAAAuT_ZYfLmRi-xIoIAIkfeeABBAYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N2lAQIDJiABIVgg11Yt_p_qwbKz9wOD4_T_HujzYd3jXQt_D2hYgmcjFnUiWCBFQOj2xOvfOT0lAw3J5Nyp56cnOuifxxTrv4HrqolrQA", + "clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoidDRMV0kwaVlKU1RXUGw5V1hVZE5oZEhBbnJQRExGOWVXQVA5bEhnbUhQOCIsIm9yaWdpbiI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMCIsImNyb3NzT3JpZ2luIjpmYWxzZX0" }, "type": "public-key", - "clientExtensionResults": {} + "clientExtensionResults": { + "credProps": { "rk": false } + }, + "authenticatorAttachment": "platform" }""" - challenge = base64url_to_bytes("4ab7dfd1-a695-4777-985f-ad2993828e99") - rp_id = "dev.dontneeda.pw" - expected_origin = "https://dev.dontneeda.pw" + challenge = base64url_to_bytes("t4LWI0iYJSTWPl9WXUdNhdHAnrPDLF9eWAP9lHgmHP8") + rp_id = "localhost" + expected_origin = "http://localhost:8000" verification = verify_registration_response( credential=credential, @@ -39,5 +42,5 @@ def test_verify_attestation_android_key( assert verification.fmt == AttestationFormat.ANDROID_KEY assert verification.credential_id == base64url_to_bytes( - "V51GE29tGbhby7sbg1cZ_qL8V8njqEsXpAnwQBobvgw" + "AYNe4CBKc8H30FuAb8uaht6JbEQfbSBnS0SX7B6MFg8ofI92oR5lheRDJCgwY-JqB_QSJtezdhMbf8Wzt_La5N0" )