tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_setIdentityProviderWithErrors.html (2010B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <script type="application/javascript">var scriptRelativePath = "../";</script>
      5  <script type="application/javascript" src="../pc.js"></script>
      6 </head>
      7 <body>
      8 <pre id="test">
      9 <script type="application/javascript">
     10 'use strict';
     11  createHTML({
     12    title: "Identity Provider returning errors is handled correctly",
     13    bug: "942367"
     14  });
     15 
     16 runNetworkTest(function () {
     17  var test = new PeerConnectionTest();
     18  test.setMediaConstraints([{audio: true}], [{audio: true}]);
     19  // No IdP for local.
     20  // Remote generates a bad assertion, but that only fails to validate
     21  test.pcRemote.setIdentityProvider('example.com',
     22                                    { protocol: 'idp.js#bad-validate',
     23                                      usernameHint: 'nobody' });
     24 
     25  // Save the peerIdentity promises now, since when they reject they are
     26  // replaced and we expect them to be rejected this time
     27  var peerIdentityLocal = test.pcLocal._pc.peerIdentity;
     28  var peerIdentityRemote = test.pcRemote._pc.peerIdentity;
     29 
     30  test.chain.append([
     31    function ONLY_REMOTE_SDP_INCLUDES_IDENTITY_ASSERTION(t) {
     32      ok(!t.originalOffer.sdp.includes('a=identity'),
     33         'a=identity not contained in the offer SDP');
     34      ok(t.originalAnswer.sdp.includes('a=identity'),
     35         'a=identity is contained in the answer SDP');
     36    },
     37    function PEER_IDENTITY_IS_EMPTY(t) {
     38      // we are only waiting for the local side to complete
     39      // an error on the remote side is immediately fatal though
     40      return Promise.race([
     41        peerIdentityLocal.then(
     42          () => ok(false, t.pcLocal + ' incorrectly received valid peer identity'),
     43          e => ok(e, t.pcLocal + ' correctly failed to validate peer identity')),
     44        peerIdentityRemote.then(
     45          () => ok(false, t.pcRemote + ' incorrecly received a valid peer identity'),
     46          e => ok(false, t.pcRemote + ' incorrectly rejected peer identity'))
     47      ]);
     48    }
     49  ]);
     50 
     51  return test.run();
     52 });
     53 
     54 </script>
     55 </pre>
     56 </body>
     57 </html>