well-known-client-metadata-validation.https.html (4548B)
1 <!DOCTYPE html> 2 <title>FedCM Well-Known Client Metadata Validation</title> 3 <meta name="timeout" content="long"> 4 <link rel="help" href="https://fedidcg.github.io/FedCM"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-vendor.js"></script> 9 10 <script type="module"> 11 import {fedcm_test, 12 set_well_known_format, 13 request_options_with_mediation_required, 14 select_manifest, 15 fedcm_get_and_select_first_account} from '../support/fedcm-helper.sub.js'; 16 17 // Test 1: Direct format(account_endpoint and login_url defined) should work with client_metadata 18 fedcm_test(async t => { 19 await set_well_known_format('direct'); 20 21 const options = request_options_with_mediation_required(); 22 const credential = await fedcm_get_and_select_first_account(t, options); 23 assert_equals(credential.token, "token", "Should get credential with token"); 24 }, 'FedCM should succeed with direct well-known format and client_metadata'); 25 26 // Test 2: Missing format(account_endpoint and login_url are empty) should fail with client_metadata 27 fedcm_test(async t => { 28 await set_well_known_format('missing'); 29 30 const options = request_options_with_mediation_required(); 31 return promise_rejects_dom(t, "NetworkError", navigator.credentials.get(options), 32 "Should fail when well-known has missing endpoints with client_metadata"); 33 }, 'FedCM should fail with missing well-known endpoints and client_metadata'); 34 35 // Test 3: Partial_accounts format(account_endpoint defined) should fail with client_metadata 36 fedcm_test(async t => { 37 await set_well_known_format('partial_accounts'); 38 39 const options = request_options_with_mediation_required(); 40 return promise_rejects_dom(t, "NetworkError", navigator.credentials.get(options), 41 "Should fail when well-known has only accounts_endpoint with client_metadata"); 42 }, 'FedCM should fail with partial accounts endpoint and client_metadata'); 43 44 // Test 4: Partial_login format(login_url defined) should fail with client_metadata 45 fedcm_test(async t => { 46 await set_well_known_format('partial_login'); 47 48 const options = request_options_with_mediation_required(); 49 return promise_rejects_dom(t, "NetworkError", navigator.credentials.get(options), 50 "Should fail when well-known has only login_url with client_metadata"); 51 }, 'FedCM should fail with partial login endpoint and client_metadata'); 52 53 // Test 5: Provider_urls format(provider_urls defined) should fail with client_metadata 54 fedcm_test(async t => { 55 await set_well_known_format('provider_urls'); 56 57 const options = request_options_with_mediation_required(); 58 return promise_rejects_dom(t, "NetworkError", navigator.credentials.get(options), 59 "Should fail when using provider_urls format with client_metadata"); 60 }, 'FedCM should fail with provider_urls format and client_metadata (validation enforced)'); 61 62 // Test 6: Missing format(account_endpoint and login_url are empty) should work without client_metadata 63 fedcm_test(async t => { 64 await set_well_known_format('missing'); 65 66 const options = request_options_with_mediation_required("manifest_with_no_client_metadata.json"); 67 await select_manifest(t, options); 68 const credential = await fedcm_get_and_select_first_account(t, options); 69 assert_equals(credential.token, "token", "Should get credential with token"); 70 }, 'FedCM should succeed with missing well-known endpoints without client_metadata'); 71 72 // Test 7: Empty format(account_endpoint and login_url entries doesnt exist) should work without client_metadata 73 fedcm_test(async t => { 74 await set_well_known_format('empty'); 75 76 const options = request_options_with_mediation_required("manifest_with_no_client_metadata.json"); 77 await select_manifest(t, options); 78 const credential = await fedcm_get_and_select_first_account(t, options); 79 assert_equals(credential.token, "token", "Should get credential with token"); 80 }, 'FedCM should succeed with empty well-known endpoints without client_metadata'); 81 82 // Test 8: Default format (provider_urls) should work without client_metadata 83 fedcm_test(async t => { 84 const options = request_options_with_mediation_required("manifest_with_no_client_metadata.json"); 85 await select_manifest(t, options); 86 const credential = await fedcm_get_and_select_first_account(t, options); 87 assert_equals(credential.token, "token", "Should get credential with token"); 88 }, 'FedCM should succeed with provider_urls format without client_metadata (no validation)'); 89 90 </script>