Changeset 236625 in webkit


Ignore:
Timestamp:
Sep 28, 2018 5:02:39 PM (6 years ago)
Author:
jiewen_tan@apple.com
Message:

[WebAuthN] Polish WebAuthN auto-test environment
https://bugs.webkit.org/show_bug.cgi?id=189283
<rdar://problem/44117828>

Reviewed by Chris Dumez.

Source/WebCore:

This patch removes the old mocking mechanism.

Tests: http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https.html

http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https.html
http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html

  • DerivedSources.make:
  • WebCore.xcodeproj/project.pbxproj:
  • testing/Internals.cpp:

(WebCore::Internals::Internals):
(WebCore::Internals::mockAuthenticatorCoordinator const): Deleted.

  • testing/Internals.h:
  • testing/Internals.idl:
  • testing/MockAuthenticatorCoordinator.cpp: Removed.
  • testing/MockAuthenticatorCoordinator.h: Removed.
  • testing/MockAuthenticatorCoordinator.idl: Removed.

Source/WebKit:

This patch changes MockWebAuthenticationConfiguration.local to optional such that tests can express
absence of local authenticators.

  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreSetWebAuthenticationMockConfiguration):

  • UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:

(WebKit::MockLocalConnection::getUserConsent const):
(WebKit::MockLocalConnection::getAttestation const):

  • UIProcess/WebAuthentication/Mock/MockLocalService.cpp:

(WebKit::MockLocalService::platformStartDiscovery const):

  • UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h:

Tools:

  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setWebAuthenticationMockConfiguration):

LayoutTests:

This patch does the following few things:

  1. Update tests that employ old mocking mechnism to the new one.
  2. Move tests from http/tests/webauthn to http/wpt/webauthn. As a result, we have one unified place for

all WebAuthN tests: http/wpt/webauthn.

  1. Add a helper function to check DOMException message as well.
  • TestExpectations:
  • http/tests/webauthn/public-key-credential-create-with-invalid-parameters.https-expected.txt: Removed.
  • http/tests/webauthn/public-key-credential-get-with-invalid-parameters.https-expected.txt: Removed.
  • http/tests/webauthn/public-key-credential-same-origin-with-ancestors-2.https-expected.txt: Removed.
  • http/tests/webauthn/public-key-credential-same-origin-with-ancestors-2.https.html: Removed.
  • http/tests/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt: Removed.
  • http/tests/webauthn/public-key-credential-same-origin-with-ancestors.https.html: Removed.
  • http/tests/webauthn/resources/last-layer-frame.https.html: Removed.
  • http/tests/webauthn/resources/util.js: Removed.
  • http/wpt/credential-management/credentialscontainer-store-basics.https.html:
  • http/wpt/webauthn/idl.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
  • http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt:
  • http/wpt/webauthn/public-key-credential-create-failure.https.html:
  • http/wpt/webauthn/public-key-credential-create-success.https-expected.txt: Removed.
  • http/wpt/webauthn/public-key-credential-create-success.https.html: Removed.
  • http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https-expected.txt: Added.
  • http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https.html: Renamed from LayoutTests/http/tests/webauthn/public-key-credential-create-with-invalid-parameters.https.html.
  • http/wpt/webauthn/public-key-credential-get-failure-local.https.html:
  • http/wpt/webauthn/public-key-credential-get-failure.https-expected.txt:
  • http/wpt/webauthn/public-key-credential-get-failure.https.html:
  • http/wpt/webauthn/public-key-credential-get-success.https-expected.txt: Removed.
  • http/wpt/webauthn/public-key-credential-get-success.https.html: Removed.
  • http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https-expected.txt: Added.
  • http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https.html: Renamed from LayoutTests/http/tests/webauthn/public-key-credential-get-with-invalid-parameters.https.html.
  • http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt: Added.
  • http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html: Added.
  • http/wpt/webauthn/resources/last-layer-frame.https.html: Added.
  • http/wpt/webauthn/resources/second-layer-frame.https.html: Renamed from LayoutTests/http/tests/webauthn/resources/second-layer-frame.https.html.
  • http/wpt/webauthn/resources/util.js:
  • platform/gtk/TestExpectations:
  • platform/ios-wk1/TestExpectations:
  • platform/mac-wk1/TestExpectations:
  • platform/mac-wk2/TestExpectations:
  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:
  • platform/wpe/TestExpectations:
Location:
trunk
Files:
5 added
8 deleted
31 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r236624 r236625  
     12018-09-28  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Polish WebAuthN auto-test environment
     4        https://bugs.webkit.org/show_bug.cgi?id=189283
     5        <rdar://problem/44117828>
     6
     7        Reviewed by Chris Dumez.
     8
     9        This patch does the following few things:
     10        1. Update tests that employ old mocking mechnism to the new one.
     11        2. Move tests from http/tests/webauthn to http/wpt/webauthn. As a result, we have one unified place for
     12        all WebAuthN tests: http/wpt/webauthn.
     13        3. Add a helper function to check DOMException message as well.
     14
     15        * TestExpectations:
     16        * http/tests/webauthn/public-key-credential-create-with-invalid-parameters.https-expected.txt: Removed.
     17        * http/tests/webauthn/public-key-credential-get-with-invalid-parameters.https-expected.txt: Removed.
     18        * http/tests/webauthn/public-key-credential-same-origin-with-ancestors-2.https-expected.txt: Removed.
     19        * http/tests/webauthn/public-key-credential-same-origin-with-ancestors-2.https.html: Removed.
     20        * http/tests/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt: Removed.
     21        * http/tests/webauthn/public-key-credential-same-origin-with-ancestors.https.html: Removed.
     22        * http/tests/webauthn/resources/last-layer-frame.https.html: Removed.
     23        * http/tests/webauthn/resources/util.js: Removed.
     24        * http/wpt/credential-management/credentialscontainer-store-basics.https.html:
     25        * http/wpt/webauthn/idl.https.html:
     26        * http/wpt/webauthn/public-key-credential-create-failure-local.https.html:
     27        * http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt:
     28        * http/wpt/webauthn/public-key-credential-create-failure.https.html:
     29        * http/wpt/webauthn/public-key-credential-create-success.https-expected.txt: Removed.
     30        * http/wpt/webauthn/public-key-credential-create-success.https.html: Removed.
     31        * http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https-expected.txt: Added.
     32        * http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https.html: Renamed from LayoutTests/http/tests/webauthn/public-key-credential-create-with-invalid-parameters.https.html.
     33        * http/wpt/webauthn/public-key-credential-get-failure-local.https.html:
     34        * http/wpt/webauthn/public-key-credential-get-failure.https-expected.txt:
     35        * http/wpt/webauthn/public-key-credential-get-failure.https.html:
     36        * http/wpt/webauthn/public-key-credential-get-success.https-expected.txt: Removed.
     37        * http/wpt/webauthn/public-key-credential-get-success.https.html: Removed.
     38        * http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https-expected.txt: Added.
     39        * http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https.html: Renamed from LayoutTests/http/tests/webauthn/public-key-credential-get-with-invalid-parameters.https.html.
     40        * http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https-expected.txt: Added.
     41        * http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html: Added.
     42        * http/wpt/webauthn/resources/last-layer-frame.https.html: Added.
     43        * http/wpt/webauthn/resources/second-layer-frame.https.html: Renamed from LayoutTests/http/tests/webauthn/resources/second-layer-frame.https.html.
     44        * http/wpt/webauthn/resources/util.js:
     45        * platform/gtk/TestExpectations:
     46        * platform/ios-wk1/TestExpectations:
     47        * platform/mac-wk1/TestExpectations:
     48        * platform/mac-wk2/TestExpectations:
     49        * platform/win/TestExpectations:
     50        * platform/wincairo/TestExpectations:
     51        * platform/wpe/TestExpectations:
     52
    1532018-09-28  Jer Noble  <jer.noble@apple.com>
    254
  • trunk/LayoutTests/TestExpectations

    r236614 r236625  
    28762876webkit.org/b/187773 http/tests/webAPIStatistics [ Skip ]
    28772877
    2878 # Temporary disables old WebAuthN tests, will either reenable or remove them in webkit.org/b/189283
    2879 http/wpt/credential-management/credentialscontainer-store-basics.https.html [ Skip ]
    2880 http/wpt/webauthn/public-key-credential-create-failure.https.html [ Skip ]
    2881 http/wpt/webauthn/public-key-credential-create-success.https.html [ Skip ]
    2882 http/wpt/webauthn/public-key-credential-get-failure.https.html [ Skip ]
    2883 http/wpt/webauthn/public-key-credential-get-success.https.html [ Skip ]
    2884 http/wpt/webauthn/idl.https.html [ Skip ]
    2885 
    28862878webkit.org/b/189997 imported/w3c/web-platform-tests/resource-timing/resource_timing.worker.html [ Failure ]
    28872879
  • trunk/LayoutTests/http/wpt/credential-management/credentialscontainer-store-basics.https.html

    r235888 r236625  
    44<script src="/resources/testharnessreport.js"></script>
    55<script>
     6    const testES256PrivateKeyBase64 =
     7        "BDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749VBJPgqUIwfhWHJ91nb7U" +
     8        "PH76c0+WFOzZKslPyyFse4goGIW2R7k9VHLPEZl5nfnBgEVFh5zev+/xpHQIvuq6" +
     9        "RQ==";
     10    const testRpId = "localhost";
    611    function asciiToUint8Array(str)
    712    {
     
    4348        };
    4449        // A mock attestation object
    45         internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
     50        if (window.testRunner)
     51            testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: true, acceptAttestation: true, privateKeyBase64: testES256PrivateKeyBase64 } });
    4652        const credential = await navigator.credentials.create(options);
    4753
    4854        return promise_rejects(t, "NotSupportedError",
    49             navigator.credentials.store(credential));
     55            navigator.credentials.store(credential)).then(() => {
     56                if (window.testRunner)
     57                    testRunner.cleanUpKeychain(testRpId);
     58        });
    5059    }, "navigator.credentials.store().");
    5160</script>
  • trunk/LayoutTests/http/wpt/webauthn/idl.https.html

    r235889 r236625  
    2020
    2121<script>
     22if (window.testRunner)
     23    testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: true, acceptAttestation: true, privateKeyBase64: testES256PrivateKeyBase64 } });
     24
    2225promise_test(async () => {
    2326    const idlURL = ["WebAuthN.idl"];
     
    4548            user: {
    4649                name: "John Appleseed",
    47                 id: asciiToUint8Array("123456"),
     50                id: Base64URL.parse(testUserhandleBase64),
    4851                displayName: "Appleseed",
    4952            },
     
    5255        }
    5356    };
    54     // A mock attestation object
    55     internals.mockAuthenticatorCoordinator.setCreationReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'));
    5657    createdCredential = await navigator.credentials.create(creationOptions);
    5758
     
    6263        }
    6364    };
    64     // A mock assertion return bundle.
    65     internals.mockAuthenticatorCoordinator.setAssertionReturnBundle(hexStringToUint8Array('00'), hexStringToUint8Array('01'), hexStringToUint8Array('02'), hexStringToUint8Array('03'));
    6665    requestedCredential = await navigator.credentials.get(requestOptions);
    6766
    6867    idlArray.add_objects({"PublicKeyCredential": ["createdCredential"], "AuthenticatorAttestationResponse": ["createdCredential.response"], "AuthenticatorAssertionResponse": ["requestedCredential.response"]});
    6968    idlArray.test();
     69
     70    if (window.testRunner)
     71        testRunner.cleanUpKeychain(testRpId);
    7072}, "Setup for WebAuthN API IDL tests.");
    7173</script>
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure-local.https.html

    r236481 r236625  
    2424            }
    2525        };
    26         return promise_rejects(t, "NotSupportedError", navigator.credentials.create(options), "The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters.");
     26        return promiseRejects(t, "NotSupportedError", navigator.credentials.create(options), "The platform attached authenticator doesn't support any provided PublicKeyCredentialParameters.");
    2727    }, "PublicKeyCredential's [[create]] with unsupported public key credential parameters in a mock local authenticator.");
    2828
     
    4545        if (window.testRunner)
    4646            testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
    47         return promise_rejects(t, "NotAllowedError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
     47        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
    4848            if (window.testRunner)
    4949                testRunner.cleanUpKeychain(testRpId);
     
    7474        if (window.testRunner)
    7575            testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
    76         return promise_rejects(t, "NotAllowedError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
     76        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "At least one credential matches an entry of the excludeCredentials list in the platform attached authenticator.").then(() => {
    7777            if (window.testRunner)
    7878                testRunner.cleanUpKeychain(testRpId);
     
    9595            }
    9696        };
    97         return promise_rejects(t, "NotAllowedError", navigator.credentials.create(options), "Couldn't get user consent.");
     97        return promiseRejects(t, "NotAllowedError", navigator.credentials.create(options), "Couldn't get user consent.");
    9898    }, "PublicKeyCredential's [[create]] without user consent in a mock local authenticator.");
    9999
     
    115115        if (window.testRunner)
    116116            testRunner.setWebAuthenticationMockConfiguration({ local: { acceptAuthentication: true, acceptAttestation: false, privateKeyBase64: "" } });
    117         return promise_rejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.");
     117        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.");
    118118    }, "PublicKeyCredential's [[create]] without attestation in a mock local authenticator.");
    119119
     
    137137            testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
    138138        }
    139         return promise_rejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.").then(() => {
     139        return promiseRejects(t, "UnknownError", navigator.credentials.create(options), "Unknown internal error.").then(() => {
    140140            if (window.testRunner)
    141141                assert_false(testRunner.keyExistsInKeychain(testRpId, testUserhandleBase64));
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https-expected.txt

    r227382 r236625  
    11
    2 PASS PublicKeyCredential's [[create]] with timeout
    32PASS PublicKeyCredential's [[create]] with a mismatched RP ID
    43PASS PublicKeyCredential's [[create]] with an empty pubKeyCredParams
    5 PASS PublicKeyCredential's [[create]] with user cancellations
    64
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-failure.https.html

    r235888 r236625  
    55<script src="./resources/util.js"></script>
    66<script>
    7     promise_test(function(t) {
    8         const options = {
    9             publicKey: {
    10                 rp: {
    11                     name: "example.com"
    12                 },
    13                 user: {
    14                     name: "John Appleseed",
    15                     id: asciiToUint8Array("123456"),
    16                     displayName: "John",
    17                 },
    18                 challenge: asciiToUint8Array("123456"),
    19                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
    20                 timeout: 0,
    21             }
    22         };
    23         internals.mockAuthenticatorCoordinator.setDidTimeOut();
     7    // Default mock configuration. Tests need to override if they need different configuration.
     8    if (window.testRunner)
     9        testRunner.setWebAuthenticationMockConfiguration({ });
    2410
    25         return promise_rejects(t, "NotAllowedError",
    26             navigator.credentials.create(options));
    27     }, "PublicKeyCredential's [[create]] with timeout");
     11    // FIXME(189642): Re-enable the following test.
     12    // promise_test(function(t) {
     13    //     const options = {
     14    //         publicKey: {
     15    //             rp: {
     16    //                 name: "example.com"
     17    //             },
     18    //             user: {
     19    //                 name: "John Appleseed",
     20    //                 id: asciiToUint8Array("123456"),
     21    //                 displayName: "John",
     22    //             },
     23    //             challenge: asciiToUint8Array("123456"),
     24    //             pubKeyCredParams: [{ type: "public-key", alg: -7 }],
     25    //             timeout: 0,
     26    //         }
     27    //     };
     28    //
     29    //     return promiseRejects(t, "NotAllowedError",
     30    //         navigator.credentials.create(options), "Operation timed out.");
     31    // }, "PublicKeyCredential's [[create]] with timeout");
    2832
    2933    promise_test(function(t) {
     
    4347            }
    4448        };
    45         return promise_rejects(t, "SecurityError",
    46             navigator.credentials.create(options));
     49
     50        return promiseRejects(t, "SecurityError",
     51            navigator.credentials.create(options), "The origin of the document is not a registrable domain suffix of the provided RP ID.");
    4752    }, "PublicKeyCredential's [[create]] with a mismatched RP ID");
    4853
     
    6368            }
    6469        };
    65         return promise_rejects(t, "NotSupportedError",
    66             navigator.credentials.create(options));
     70
     71        return promiseRejects(t, "NotSupportedError",
     72            navigator.credentials.create(options), "No desired properties of the to be created credential are provided.");
    6773    }, "PublicKeyCredential's [[create]] with an empty pubKeyCredParams");
    68 
    69     promise_test(function(t) {
    70         const options = {
    71             publicKey: {
    72                 rp: {
    73                     name: "localhost",
    74                     id: "localhost"
    75                 },
    76                 user: {
    77                     name: "John Appleseed",
    78                     id: asciiToUint8Array("123456"),
    79                     displayName: "John",
    80                 },
    81                 challenge: asciiToUint8Array("123456"),
    82                 pubKeyCredParams: [{ type: "public-key", alg: -7 }],
    83             }
    84         };
    85         internals.mockAuthenticatorCoordinator.setDidUserCancel();
    86 
    87         return promise_rejects(t, "NotAllowedError",
    88             navigator.credentials.create(options));
    89     }, "PublicKeyCredential's [[create]] with user cancellations");
    9074</script>
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https.html

    r236624 r236625  
    11<!DOCTYPE html>
    2 <html>
    3 <head>
    4     <script src="/js-test-resources/js-test.js"></script>
    5     <script src="./resources/util.js"></script>
    6 </head>
    7 <body>
    8 <p id="description"></p>
    9 <div id="console"></div>
     2<title>Web Authentication API: PublicKeyCredential's [[create]] with invalid parameters.</title>
     3<script src="/resources/testharness.js"></script>
     4<script src="/resources/testharnessreport.js"></script>
     5<script src="./resources/util.js"></script>
    106<script>
    11     description("Tests that PublicKeyCredential's [[create]] throws TypeError when invalid options are passed.");
    12 
    13     jsTestIsAsync = true;
    14 
    157    const rp = {
    168        name: "example.com"
     
    9587        [rp, user, challenge, [pubKeyCredParam], undefined, [{ type: excludeCredentials.type, id: [ ] }]],
    9688        [rp, user, challenge, [pubKeyCredParam], undefined, [{ type: excludeCredentials.type, id: { } }]]
    97     ]
     89    ];
    9890
    9991    function makeOptions(attributes)
     
    10496    }
    10597
     98    let index = 1;
    10699    function runTest(attributesVectors) {
    107100        attributesVectors.forEach(function(attributesVector) {
    108101            attributesVector.forEach(async function(attributes) {
    109                 invalidOptions = makeOptions(attributes);
    110                 await shouldReject('navigator.credentials.create(invalidOptions)');
     102                promise_test(function(t) {
     103                    return promise_rejects(t, new TypeError(),
     104                        navigator.credentials.create(makeOptions(attributes)));
     105                }, "PublicKeyCredential's [[create]] with with invalid parameters. " + index);
     106                index = index + 1;
    111107            });
    112108        });
    113 
    114         finishJSTest();
    115109    }
    116110
     
    120114    runTest(vectors);
    121115</script>
    122 </body>
    123 </html>
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure-local.https.html

    r236481 r236625  
    2222        };
    2323
    24         return promise_rejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.");
     24        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.");
    2525    }, "PublicKeyCredential's [[get]] with no matched credentials in a mock local authenticator.");
    2626
     
    3737        if (window.testRunner)
    3838            testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
    39         return promise_rejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.").then(() => {
     39        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "No matched credentials are found in the platform attached authenticator.").then(() => {
    4040                if (window.testRunner)
    4141                    testRunner.cleanUpKeychain(testRpId);
     
    5252        if (window.testRunner)
    5353            testRunner.addTestKeyToKeychain(testES256PrivateKeyBase64, testRpId, testUserhandleBase64);
    54         return promise_rejects(t, "NotAllowedError", navigator.credentials.get(options), "Couldn't get user consent.").then(() => {
     54        return promiseRejects(t, "NotAllowedError", navigator.credentials.get(options), "Couldn't get user consent.").then(() => {
    5555            if (window.testRunner)
    5656                testRunner.cleanUpKeychain(testRpId);
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https-expected.txt

    r227589 r236625  
    11
    2 PASS PublicKeyCredential's [[get]] with timeout
    32PASS PublicKeyCredential's [[get]] with a mismatched RP ID
    4 PASS PublicKeyCredential's [[get]] with user cancellations
    53
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-failure.https.html

    r235888 r236625  
    55<script src="./resources/util.js"></script>
    66<script>
    7     promise_test(function(t) {
    8         const options = {
    9             publicKey: {
    10                 challenge: asciiToUint8Array("123456"),
    11                 timeout: 0,
    12             }
    13         };
    14         internals.mockAuthenticatorCoordinator.setDidTimeOut();
     7    // Default mock configuration. Tests need to override if they need different configuration.
     8    if (window.testRunner)
     9        testRunner.setWebAuthenticationMockConfiguration({ });
    1510
    16         return promise_rejects(t, "NotAllowedError",
    17             navigator.credentials.get(options));
    18     }, "PublicKeyCredential's [[get]] with timeout");
     11    // FIXME(189642): Re-enable the following test.
     12    // promise_test(function(t) {
     13    //     const options = {
     14    //         publicKey: {
     15    //             challenge: asciiToUint8Array("123456"),
     16    //             timeout: 0,
     17    //         }
     18    //     };
     19    //
     20    //     return promiseRejects(t, "NotAllowedError",
     21    //         navigator.credentials.get(options), "Operation timed out.");
     22    // }, "PublicKeyCredential's [[get]] with timeout");
    1923
    2024    promise_test(function(t) {
     
    2529            }
    2630        };
    27         return promise_rejects(t, "SecurityError",
    28             navigator.credentials.get(options));
     31        return promiseRejects(t, "SecurityError",
     32            navigator.credentials.get(options), "The origin of the document is not a registrable domain suffix of the provided RP ID.");
    2933    }, "PublicKeyCredential's [[get]] with a mismatched RP ID");
    30 
    31     promise_test(function(t) {
    32         const options = {
    33             publicKey: {
    34                 challenge: asciiToUint8Array("123456"),
    35                 allowCredentials: [{ type: "public-key", id: asciiToUint8Array("123456") }],
    36             }
    37         };
    38         internals.mockAuthenticatorCoordinator.setDidUserCancel();
    39 
    40         return promise_rejects(t, "NotAllowedError",
    41             navigator.credentials.get(options));
    42     }, "PublicKeyCredential's [[get]] with user cancellations");
    4334</script>
  • trunk/LayoutTests/http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https.html

    r236624 r236625  
    11<!DOCTYPE html>
    2 <html>
    3 <head>
    4     <script src="/js-test-resources/js-test.js"></script>
    5     <script src="./resources/util.js"></script>
    6 </head>
    7 <body>
    8 <p id="description"></p>
    9 <div id="console"></div>
     2<title>Web Authentication API: PublicKeyCredential's [[get]] with invalid parameters.</title>
     3<script src="/resources/testharness.js"></script>
     4<script src="/resources/testharnessreport.js"></script>
     5<script src="./resources/util.js"></script>
    106<script>
    11     description("Tests that PublicKeyCredential's [[get]] throws TypeError when invalid options are passed.");
    12 
    13     jsTestIsAsync = true;
    14 
    157    const challenge = asciiToUint8Array("123456");
    168    const allowCredential = { type: "public-key", id: asciiToUint8Array("123456") };
     
    6153    }
    6254
     55    let index = 1;
    6356    function runTest(attributesVectors) {
    6457        attributesVectors.forEach(function(attributesVector) {
    6558            attributesVector.forEach(async function(attributes) {
    66                 invalidOptions = makeOptions(attributes);
    67                 await shouldReject('navigator.credentials.get(invalidOptions)');
     59                promise_test(function(t) {
     60                    return promise_rejects(t, new TypeError(),
     61                        navigator.credentials.get(makeOptions(attributes)));
     62                }, "PublicKeyCredential's [[get]] with with invalid parameters. " + index);
     63                index = index + 1;
    6864            });
    6965        });
    70 
    71         finishJSTest();
    7266    }
    7367
     
    7771    runTest(vectors);
    7872</script>
    79 </body>
    80 </html>
  • trunk/LayoutTests/http/wpt/webauthn/resources/util.js

    r236481 r236625  
     1const testCredentialIdBase64url = "SMSXHngF7hEOsElA73C3RY-8bR4";
     2const testES256PrivateKeyBase64 =
     3    "BDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749VBJPgqUIwfhWHJ91nb7U" +
     4    "PH76c0+WFOzZKslPyyFse4goGIW2R7k9VHLPEZl5nfnBgEVFh5zev+/xpHQIvuq6" +
     5    "RQ==";
     6const testES256PublicKeyBase64url =
     7    "BDj_zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF_Qm1749VBJPgqUIwfhWHJ91nb7U" +
     8    "PH76c0-WFOzZKslPyyFse4g";
     9const testRpId = "localhost";
     10const testUserhandleBase64 = "AAECAwQFBgcICQ==";
     11
     12const RESOURCES_DIR = "/WebKit/webauthn/resources/";
     13
    114function asciiToUint8Array(str)
    215{
     
    139152}
    140153
    141 const testCredentialIdBase64url = "SMSXHngF7hEOsElA73C3RY-8bR4";
    142 const testES256PrivateKeyBase64 =
    143     "BDj/zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF/Qm1749VBJPgqUIwfhWHJ91nb7U" +
    144     "PH76c0+WFOzZKslPyyFse4goGIW2R7k9VHLPEZl5nfnBgEVFh5zev+/xpHQIvuq6" +
    145     "RQ==";
    146 const testES256PublicKeyBase64url =
    147     "BDj_zxSkzKgaBuS3cdWDF558of8AaIpgFpsjF_Qm1749VBJPgqUIwfhWHJ91nb7U" +
    148     "PH76c0-WFOzZKslPyyFse4g";
    149 const testRpId = "localhost";
    150 const testUserhandleBase64 = "AAECAwQFBgcICQ==";
     154function waitForLoad()
     155{
     156    return new Promise((resolve) => {
     157        window.addEventListener('message', (message) => {
     158            resolve(message);
     159        });
     160    });
     161}
     162
     163function withCrossOriginIframe(resourceFile)
     164{
     165    return new Promise((resolve) => {
     166        waitForLoad().then((message) => {
     167            resolve(message);
     168        });
     169        const frame = document.createElement("iframe");
     170        frame.src = get_host_info().HTTPS_REMOTE_ORIGIN + RESOURCES_DIR + resourceFile;
     171        document.body.appendChild(frame);
     172    });
     173}
     174
     175function promiseRejects(test, expected, promise, description)
     176{
     177    return promise.then(test.unreached_func("Should have rejected: " + description)).catch(function(e) {
     178        assert_throws(expected, function() { throw e }, description);
     179        assert_equals(e.message, description);
     180    });
     181}
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r236543 r236625  
    11511151
    11521152# Skip anything related to WebAuthN
    1153 http/tests/webauthn/ [ Skip ]
    11541153http/wpt/credential-management/ [ Skip ]
    11551154http/wpt/webauthn/ [ Skip ]
  • trunk/LayoutTests/platform/ios-wk1/TestExpectations

    r236424 r236625  
    19701970
    19711971# Skip anything related to WebAuthN
    1972 http/tests/webauthn/ [ Skip ]
    19731972http/wpt/credential-management/ [ Skip ]
    19741973http/wpt/webauthn/ [ Skip ]
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r236461 r236625  
    546546
    547547# Skip anything related to WebAuthN
    548 http/tests/webauthn/ [ Skip ]
    549548http/wpt/credential-management/ [ Skip ]
    550549http/wpt/webauthn/ [ Skip ]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r236570 r236625  
    888888http/wpt/webauthn/public-key-credential-get-failure-local.https.html [ Skip ]
    889889http/wpt/webauthn/public-key-credential-get-success-local.https.html [ Skip ]
     890# The following tests require PublicKeyCredential objects. We can only produce them via local authenticators now.
     891http/wpt/credential-management/credentialscontainer-store-basics.https.html [ Skip ]
     892http/wpt/webauthn/idl.https.html [ Skip ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r236541 r236625  
    655655
    656656# Skip anything related to WebAuthN
    657 http/tests/webauthn/ [ Skip ]
    658657http/wpt/credential-management/ [ Skip ]
    659658http/wpt/webauthn/ [ Skip ]
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r236431 r236625  
    925925http/tests/subresource-integrity [ Skip ]
    926926http/tests/webarchive [ Skip ]
    927 http/tests/webauthn [ Skip ]
    928927http/tests/webgl [ Skip ]
    929928http/tests/webrtc [ Skip ]
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r236418 r236625  
    121121# Skip anything related to WebAuthN
    122122# ---------------------------------
    123 http/tests/webauthn/ [ Skip ]
    124123http/wpt/credential-management/ [ Skip ]
    125124http/wpt/webauthn/ [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r236624 r236625  
     12018-09-28  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Polish WebAuthN auto-test environment
     4        https://bugs.webkit.org/show_bug.cgi?id=189283
     5        <rdar://problem/44117828>
     6
     7        Reviewed by Chris Dumez.
     8
     9        This patch removes the old mocking mechanism.
     10
     11        Tests: http/wpt/webauthn/public-key-credential-create-with-invalid-parameters.https.html
     12               http/wpt/webauthn/public-key-credential-get-with-invalid-parameters.https.html
     13               http/wpt/webauthn/public-key-credential-same-origin-with-ancestors.https.html
     14
     15        * DerivedSources.make:
     16        * WebCore.xcodeproj/project.pbxproj:
     17        * testing/Internals.cpp:
     18        (WebCore::Internals::Internals):
     19        (WebCore::Internals::mockAuthenticatorCoordinator const): Deleted.
     20        * testing/Internals.h:
     21        * testing/Internals.idl:
     22        * testing/MockAuthenticatorCoordinator.cpp: Removed.
     23        * testing/MockAuthenticatorCoordinator.h: Removed.
     24        * testing/MockAuthenticatorCoordinator.idl: Removed.
     25
    1262018-09-28  Jer Noble  <jer.noble@apple.com>
    227
  • trunk/Source/WebCore/DerivedSources.make

    r236552 r236625  
    979979    $(WebCore)/testing/MallocStatistics.idl \
    980980    $(WebCore)/testing/MemoryInfo.idl \
    981     $(WebCore)/testing/MockAuthenticatorCoordinator.idl \
    982981    $(WebCore)/testing/MockCDMFactory.idl \
    983982    $(WebCore)/testing/MockContentFilterSettings.idl \
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r236552 r236625  
    17701770                5754719F1ECE628300DD63B2 /* JSRsaPssParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 575471991ECE5D2A00DD63B2 /* JSRsaPssParams.h */; };
    17711771                5760827220215A5500116678 /* AuthenticatorCoordinatorClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1772                 5760827A2024EA5C00116678 /* MockAuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */; };
    1773                 5760827B2024ED2900116678 /* MockAuthenticatorCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */; };
    17741772                5768142A1E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 576814291E6F99C100E77754 /* CryptoAlgorithmEcdhKeyDeriveParams.h */; };
    17751773                576814411E709FA400E77754 /* JSEcdhKeyDeriveParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5768143E1E709C3600E77754 /* JSEcdhKeyDeriveParams.h */; };
     
    17931791                57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D8462B1FEAF68F00CA3682 /* PublicKeyCredential.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17941792                57D846351FEAFCD300CA3682 /* JSPublicKeyCredential.h in Headers */ = {isa = PBXBuildFile; fileRef = 57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */; };
    1795                 57DCED672140775B0016B847 /* JSMockAuthenticatorCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */; };
    1796                 57DCED69214077640016B847 /* JSMockAuthenticatorCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */; };
    17971793                57DCED74214305F00016B847 /* PublicKeyCredentialData.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED72214305F00016B847 /* PublicKeyCredentialData.h */; settings = {ATTRIBUTES = (Private, ); }; };
    17981794                57DCED9021487FF70016B847 /* AuthenticatorTransport.h in Headers */ = {isa = PBXBuildFile; fileRef = 57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    85698565                576082562011BE0200116678 /* JSAuthenticatorResponseCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSAuthenticatorResponseCustom.cpp; sourceTree = "<group>"; };
    85708566                576082702021513F00116678 /* AuthenticatorCoordinatorClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorCoordinatorClient.h; sourceTree = "<group>"; };
    8571                 5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MockAuthenticatorCoordinator.h; sourceTree = "<group>"; };
    8572                 5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MockAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
    8573                 57608280202556F400116678 /* MockAuthenticatorCoordinator.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MockAuthenticatorCoordinator.idl; sourceTree = "<group>"; };
    85748567                57608293202BA95300116678 /* AuthenticatorCoordinatorClient.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticatorCoordinatorClient.cpp; sourceTree = "<group>"; };
    85758568                576814281E6F98AD00E77754 /* EcdhKeyDeriveParams.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = EcdhKeyDeriveParams.idl; sourceTree = "<group>"; };
     
    86268619                57D846301FEAFC2F00CA3682 /* JSPublicKeyCredential.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPublicKeyCredential.h; sourceTree = "<group>"; };
    86278620                57D846311FEAFC2F00CA3682 /* JSPublicKeyCredential.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPublicKeyCredential.cpp; sourceTree = "<group>"; };
    8628                 57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMockAuthenticatorCoordinator.h; sourceTree = "<group>"; };
    8629                 57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMockAuthenticatorCoordinator.cpp; sourceTree = "<group>"; };
    86308621                57DCED72214305F00016B847 /* PublicKeyCredentialData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PublicKeyCredentialData.h; sourceTree = "<group>"; };
    86318622                57DCED8C21487EDB0016B847 /* AuthenticatorTransport.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuthenticatorTransport.h; sourceTree = "<group>"; };
     
    1703817029                                CD5393CB175DCCE600C07123 /* MemoryInfo.h */,
    1703917030                                CD5393CC175DCCE600C07123 /* MemoryInfo.idl */,
    17040                                 5760827920244DAC00116678 /* MockAuthenticatorCoordinator.cpp */,
    17041                                 5760827820244DAB00116678 /* MockAuthenticatorCoordinator.h */,
    17042                                 57608280202556F400116678 /* MockAuthenticatorCoordinator.idl */,
    1704317031                                CDF4B7211E03BF8100E235A2 /* MockCDMFactory.cpp */,
    1704417032                                CDF4B7221E03BF8100E235A2 /* MockCDMFactory.h */,
     
    1709717085                                CD5393D1175E018600C07123 /* JSMemoryInfo.cpp */,
    1709817086                                CD5393D2175E018600C07123 /* JSMemoryInfo.h */,
    17099                                 57DCED632140763C0016B847 /* JSMockAuthenticatorCoordinator.cpp */,
    17100                                 57DCED622140763C0016B847 /* JSMockAuthenticatorCoordinator.h */,
    1710117087                                CDF4B72D1E03CA4A00E235A2 /* JSMockCDMFactory.cpp */,
    1710217088                                CDF4B72E1E03CA4A00E235A2 /* JSMockCDMFactory.h */,
     
    1881518801                        isa = PBXGroup;
    1881618802                        children = (
    18817                                 574F55DE204F3744002948C6 /* LocalAuthenticator.h */,
    18818                                 574F55DF204F3744002948C6 /* LocalAuthenticator.mm */,
    1881918803                        );
    1882018804                        path = cocoa;
     
    2713927123                                A740B59514C935AB00A77FA4 /* JSMallocStatistics.h in Headers */,
    2714027124                                CD5393D4175E018600C07123 /* JSMemoryInfo.h in Headers */,
    27141                                 57DCED672140775B0016B847 /* JSMockAuthenticatorCoordinator.h in Headers */,
    2714227125                                538EC9331F99B9F7004D22A8 /* JSMockCDMFactory.h in Headers */,
    2714327126                                A19AEA211AAA808600B52B25 /* JSMockContentFilterSettings.h in Headers */,
     
    2714927132                                EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */,
    2715027133                                CDC26B41160A8CCE0026757B /* LegacyMockCDM.h in Headers */,
    27151                                 5760827A2024EA5C00116678 /* MockAuthenticatorCoordinator.h in Headers */,
    2715227134                                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */,
    2715327135                                A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */,
     
    3156831550                                538EC9321F99B9F7004D22A8 /* JSMallocStatistics.cpp in Sources */,
    3156931551                                CD5393D3175E018600C07123 /* JSMemoryInfo.cpp in Sources */,
    31570                                 57DCED69214077640016B847 /* JSMockAuthenticatorCoordinator.cpp in Sources */,
    3157131552                                CDF4B7321E03D06000E235A2 /* JSMockCDMFactory.cpp in Sources */,
    3157231553                                A19AEA221AAA808A00B52B25 /* JSMockContentFilterSettings.cpp in Sources */,
     
    3157831559                                EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */,
    3157931560                                CDC26B40160A8CC60026757B /* LegacyMockCDM.cpp in Sources */,
    31580                                 5760827B2024ED2900116678 /* MockAuthenticatorCoordinator.cpp in Sources */,
    3158131561                                CDF4B7311E03D00700E235A2 /* MockCDMFactory.cpp in Sources */,
    3158231562                                A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */,
  • trunk/Source/WebCore/testing/Internals.cpp

    r236561 r236625  
    269269#endif
    270270
    271 #if ENABLE(WEB_AUTHN)
    272 #include "AuthenticatorCoordinator.h"
    273 #include "MockAuthenticatorCoordinator.h"
    274 #endif
    275 
    276271#if PLATFORM(MAC) && USE(LIBWEBRTC)
    277272#include <webrtc/sdk/WebKit/VideoProcessingSoftLink.h>
     
    552547        m_mockPaymentCoordinator = new MockPaymentCoordinator(*frame->page());
    553548        frame->page()->setPaymentCoordinator(std::make_unique<PaymentCoordinator>(*m_mockPaymentCoordinator));
    554     }
    555 #endif
    556 
    557 #if ENABLE(WEB_AUTHN)
    558     // FIXME(189283)
    559     if (document.page()) {
    560         auto mockAuthenticatorCoordinator = std::make_unique<MockAuthenticatorCoordinator>();
    561         m_mockAuthenticatorCoordinator = makeWeakPtr(mockAuthenticatorCoordinator.get());
    562 //        document.page()->authenticatorCoordinator().setClient(WTFMove(mockAuthenticatorCoordinator));
    563549    }
    564550#endif
     
    46414627#endif
    46424628
    4643 #if ENABLE(WEB_AUTHN)
    4644 MockAuthenticatorCoordinator& Internals::mockAuthenticatorCoordinator() const
    4645 {
    4646     return *m_mockAuthenticatorCoordinator;
    4647 }
    4648 #endif
    4649 
    46504629bool Internals::isSystemPreviewLink(Element& element) const
    46514630{
  • trunk/Source/WebCore/testing/Internals.h

    r236546 r236625  
    8080class MockCDMFactory;
    8181class MockContentFilterSettings;
    82 class MockAuthenticatorCoordinator;
    8382class MockPageOverlay;
    8483class MockPaymentCoordinator;
     
    705704    void setTimelineCurrentTime(AnimationTimeline&, double);
    706705
    707 #if ENABLE(WEB_AUTHN)
    708     MockAuthenticatorCoordinator& mockAuthenticatorCoordinator() const;
    709 #endif
    710 
    711706    bool isSystemPreviewLink(Element&) const;
    712707    bool isSystemPreviewImage(Element&) const;
     
    807802    MockPaymentCoordinator* m_mockPaymentCoordinator { nullptr };
    808803#endif
    809 
    810 #if ENABLE(WEB_AUTHN)
    811     WeakPtr<MockAuthenticatorCoordinator> m_mockAuthenticatorCoordinator;
    812 #endif
    813804};
    814805
  • trunk/Source/WebCore/testing/Internals.idl

    r236546 r236625  
    685685    [EnabledAtRuntime=WebAnimations] void setTimelineCurrentTime(AnimationTimeline timeline, double currentTime);
    686686    [Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
    687     [Conditional=WEB_AUTHN] readonly attribute MockAuthenticatorCoordinator mockAuthenticatorCoordinator;
    688687
    689688    boolean isSystemPreviewLink(Element element);
  • trunk/Source/WebKit/ChangeLog

    r236624 r236625  
     12018-09-28  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Polish WebAuthN auto-test environment
     4        https://bugs.webkit.org/show_bug.cgi?id=189283
     5        <rdar://problem/44117828>
     6
     7        Reviewed by Chris Dumez.
     8
     9        This patch changes MockWebAuthenticationConfiguration.local to optional such that tests can express
     10        absence of local authenticators.
     11
     12        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     13        (WKWebsiteDataStoreSetWebAuthenticationMockConfiguration):
     14        * UIProcess/WebAuthentication/Mock/MockLocalConnection.mm:
     15        (WebKit::MockLocalConnection::getUserConsent const):
     16        (WebKit::MockLocalConnection::getAttestation const):
     17        * UIProcess/WebAuthentication/Mock/MockLocalService.cpp:
     18        (WebKit::MockLocalService::platformStartDiscovery const):
     19        * UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h:
     20
    1212018-09-28  Jer Noble  <jer.noble@apple.com>
    222
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r236481 r236625  
    576576{
    577577#if ENABLE(WEB_AUTHN)
     578    MockWebAuthenticationConfiguration configuration;
     579
    578580    auto localRef = static_cast<WKDictionaryRef>(WKDictionaryGetItemForKey(configurationRef, adoptWK(WKStringCreateWithUTF8CString("Local")).get()));
    579 
    580     MockWebAuthenticationConfiguration configuration;
    581     configuration.local.acceptAuthentication = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("AcceptAuthentication")).get())));
    582     configuration.local.acceptAttestation = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("AcceptAttestation")).get())));
    583     configuration.local.privateKeyBase64 = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("PrivateKeyBase64")).get())))->string();
     581    if (localRef) {
     582        MockWebAuthenticationConfiguration::Local local;
     583        local.acceptAuthentication = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("AcceptAuthentication")).get())));
     584        local.acceptAttestation = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("AcceptAttestation")).get())));
     585        local.privateKeyBase64 = WebKit::toImpl(static_cast<WKStringRef>(WKDictionaryGetItemForKey(localRef, adoptWK(WKStringCreateWithUTF8CString("PrivateKeyBase64")).get())))->string();
     586        configuration.local = WTFMove(local);
     587    }
    584588
    585589    WebKit::toImpl(dataStoreRef)->websiteDataStore().setMockWebAuthenticationConfiguration(WTFMove(configuration));
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalConnection.mm

    r236481 r236625  
    7474    // Mock async operations.
    7575    RunLoop::main().dispatch([configuration = m_configuration, callback = WTFMove(callback)]() mutable {
    76         if (!configuration.local.acceptAuthentication) {
     76        ASSERT(configuration.local);
     77        if (!configuration.local->acceptAuthentication) {
    7778            callback(UserConsent::No);
    7879            return;
     
    8687    // Mock async operations.
    8788    RunLoop::main().dispatch([configuration = m_configuration, callback = WTFMove(callback)]() mutable {
    88         if (!configuration.local.acceptAuthentication) {
     89        ASSERT(configuration.local);
     90        if (!configuration.local->acceptAuthentication) {
    8991            callback(UserConsent::No, nil);
    9092            return;
     
    100102    // Mock async operations.
    101103    RunLoop::main().dispatch([configuration = m_configuration, rpId, username, hash, callback = WTFMove(callback)]() mutable {
    102         if (!configuration.local.acceptAttestation) {
     104        ASSERT(configuration.local);
     105        if (!configuration.local->acceptAttestation) {
    103106            callback(NULL, NULL, [NSError errorWithDomain:NSOSStatusErrorDomain code:-1 userInfo:nil]);
    104107            return;
     
    113116        CFErrorRef errorRef = nullptr;
    114117        auto key = adoptCF(SecKeyCreateWithData(
    115             (__bridge CFDataRef)adoptNS([[NSData alloc] initWithBase64EncodedString:configuration.local.privateKeyBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get(),
     118            (__bridge CFDataRef)adoptNS([[NSData alloc] initWithBase64EncodedString:configuration.local->privateKeyBase64 options:NSDataBase64DecodingIgnoreUnknownCharacters]).get(),
    116119            (__bridge CFDictionaryRef)options,
    117120            &errorRef
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockLocalService.cpp

    r236481 r236625  
    4343bool MockLocalService::platformStartDiscovery() const
    4444{
    45     // FIXME(189642): we should test false case.
    46     return true;
     45    return !!m_configuration.local;
    4746}
    4847
  • trunk/Source/WebKit/UIProcess/WebAuthentication/Mock/MockWebAuthenticationConfiguration.h

    r236481 r236625  
    3737    };
    3838
    39     Local local;
     39    std::optional<Local> local;
    4040};
    4141
  • trunk/Tools/ChangeLog

    r236623 r236625  
     12018-09-28  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        [WebAuthN] Polish WebAuthN auto-test environment
     4        https://bugs.webkit.org/show_bug.cgi?id=189283
     5        <rdar://problem/44117828>
     6
     7        Reviewed by Chris Dumez.
     8
     9        * WebKitTestRunner/InjectedBundle/TestRunner.cpp:
     10        (WTR::TestRunner::setWebAuthenticationMockConfiguration):
     11
    1122018-09-28  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r236481 r236625  
    23592359    JSObjectRef configuration = JSValueToObject(context, configurationValue, 0);
    23602360
     2361    Vector<WKRetainPtr<WKStringRef>> configurationKeys;
     2362    Vector<WKRetainPtr<WKTypeRef>> configurationValues;
     2363
    23612364    JSRetainPtr<JSStringRef> localPropertyName(Adopt, JSStringCreateWithUTF8CString("local"));
    23622365    JSValueRef localValue = JSObjectGetProperty(context, configuration, localPropertyName.get(), 0);
    2363     if (!JSValueIsObject(context, localValue))
    2364         return;
    2365     JSObjectRef local = JSValueToObject(context, localValue, 0);
    2366 
    2367     JSRetainPtr<JSStringRef> acceptAuthenticationPropertyName(Adopt, JSStringCreateWithUTF8CString("acceptAuthentication"));
    2368     JSValueRef acceptAuthenticationValue = JSObjectGetProperty(context, local, acceptAuthenticationPropertyName.get(), 0);
    2369     if (!JSValueIsBoolean(context, acceptAuthenticationValue))
    2370         return;
    2371     bool acceptAuthentication = JSValueToBoolean(context, acceptAuthenticationValue);
    2372 
    2373     JSRetainPtr<JSStringRef> acceptAttestationPropertyName(Adopt, JSStringCreateWithUTF8CString("acceptAttestation"));
    2374     JSValueRef acceptAttestationValue = JSObjectGetProperty(context, local, acceptAttestationPropertyName.get(), 0);
    2375     if (!JSValueIsBoolean(context, acceptAttestationValue))
    2376         return;
    2377     bool acceptAttestation = JSValueToBoolean(context, acceptAttestationValue);
    2378 
    2379     JSRetainPtr<JSStringRef> privateKeyBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("privateKeyBase64"));
    2380     JSValueRef privateKeyBase64Value = JSObjectGetProperty(context, local, privateKeyBase64PropertyName.get(), 0);
    2381     if (!JSValueIsString(context, privateKeyBase64Value))
    2382         return;
    2383 
    2384     Vector<WKRetainPtr<WKStringRef>> localKeys;
    2385     Vector<WKRetainPtr<WKTypeRef>> localValues;
    2386     localKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("AcceptAuthentication") });
    2387     localValues.append(adoptWK(WKBooleanCreate(acceptAuthentication)).get());
    2388     localKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("AcceptAttestation") });
    2389     localValues.append(adoptWK(WKBooleanCreate(acceptAttestation)).get());
    2390     localKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("PrivateKeyBase64") });
    2391     localValues.append(toWK(adopt(JSValueToStringCopy(context, privateKeyBase64Value, 0)).get()));
    2392 
    2393     Vector<WKStringRef> rawLocalKeys;
    2394     Vector<WKTypeRef> rawLocalValues;
    2395     rawLocalKeys.resize(localKeys.size());
    2396     rawLocalValues.resize(localValues.size());
    2397     for (size_t i = 0; i < localKeys.size(); ++i) {
    2398         rawLocalKeys[i] = localKeys[i].get();
    2399         rawLocalValues[i] = localValues[i].get();
    2400     }
    2401 
    2402     Vector<WKRetainPtr<WKStringRef>> configurationKeys;
    2403     Vector<WKRetainPtr<WKTypeRef>> configurationValues;
    2404     configurationKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("Local") });
    2405     configurationValues.append({ AdoptWK, WKDictionaryCreate(rawLocalKeys.data(), rawLocalValues.data(), rawLocalKeys.size()) });
     2366    if (!JSValueIsNull(context, localValue)) {
     2367        if (!JSValueIsObject(context, localValue))
     2368            return;
     2369        JSObjectRef local = JSValueToObject(context, localValue, 0);
     2370
     2371        JSRetainPtr<JSStringRef> acceptAuthenticationPropertyName(Adopt, JSStringCreateWithUTF8CString("acceptAuthentication"));
     2372        JSValueRef acceptAuthenticationValue = JSObjectGetProperty(context, local, acceptAuthenticationPropertyName.get(), 0);
     2373        if (!JSValueIsBoolean(context, acceptAuthenticationValue))
     2374            return;
     2375        bool acceptAuthentication = JSValueToBoolean(context, acceptAuthenticationValue);
     2376
     2377        JSRetainPtr<JSStringRef> acceptAttestationPropertyName(Adopt, JSStringCreateWithUTF8CString("acceptAttestation"));
     2378        JSValueRef acceptAttestationValue = JSObjectGetProperty(context, local, acceptAttestationPropertyName.get(), 0);
     2379        if (!JSValueIsBoolean(context, acceptAttestationValue))
     2380            return;
     2381        bool acceptAttestation = JSValueToBoolean(context, acceptAttestationValue);
     2382
     2383        JSRetainPtr<JSStringRef> privateKeyBase64PropertyName(Adopt, JSStringCreateWithUTF8CString("privateKeyBase64"));
     2384        JSValueRef privateKeyBase64Value = JSObjectGetProperty(context, local, privateKeyBase64PropertyName.get(), 0);
     2385        if (!JSValueIsString(context, privateKeyBase64Value))
     2386            return;
     2387
     2388        Vector<WKRetainPtr<WKStringRef>> localKeys;
     2389        Vector<WKRetainPtr<WKTypeRef>> localValues;
     2390        localKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("AcceptAuthentication") });
     2391        localValues.append(adoptWK(WKBooleanCreate(acceptAuthentication)).get());
     2392        localKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("AcceptAttestation") });
     2393        localValues.append(adoptWK(WKBooleanCreate(acceptAttestation)).get());
     2394        localKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("PrivateKeyBase64") });
     2395        localValues.append(toWK(adopt(JSValueToStringCopy(context, privateKeyBase64Value, 0)).get()));
     2396
     2397        Vector<WKStringRef> rawLocalKeys;
     2398        Vector<WKTypeRef> rawLocalValues;
     2399        rawLocalKeys.resize(localKeys.size());
     2400        rawLocalValues.resize(localValues.size());
     2401        for (size_t i = 0; i < localKeys.size(); ++i) {
     2402            rawLocalKeys[i] = localKeys[i].get();
     2403            rawLocalValues[i] = localValues[i].get();
     2404        }
     2405
     2406        configurationKeys.append({ AdoptWK, WKStringCreateWithUTF8CString("Local") });
     2407        configurationValues.append({ AdoptWK, WKDictionaryCreate(rawLocalKeys.data(), rawLocalValues.data(), rawLocalKeys.size()) });
     2408    }
    24062409
    24072410    Vector<WKStringRef> rawConfigurationKeys;
Note: See TracChangeset for help on using the changeset viewer.