dom/media/tests/identity/test_getIdentityAssertion.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <script type="application/javascript" src="../mochitest/head.js"></script>
michael@0 7 <script type="application/javascript" src="../mochitest/pc.js"></script>
michael@0 8 <script type="application/javascript" src="../mochitest/templates.js"></script>
michael@0 9 </head>
michael@0 10 <body>
michael@0 11 <pre id="test">
michael@0 12 <script type="application/javascript">
michael@0 13 createHTML({
michael@0 14 title: "getIdentityAssertion Tests"
michael@0 15 });
michael@0 16
michael@0 17 function checkIdentity(assertion, identity) {
michael@0 18 // here we dig into the payload, which means we need to know something
michael@0 19 // about how the IdP actually works (not good in general, but OK here)
michael@0 20 var assertion = JSON.parse(atob(assertion)).assertion;
michael@0 21 var user = JSON.parse(assertion).username;
michael@0 22 is(user, identity, "id should be '" + identity + "' is '" + user + "'");
michael@0 23 }
michael@0 24
michael@0 25 var test;
michael@0 26 function theTest() {
michael@0 27 test = new PeerConnectionTest();
michael@0 28 test.setMediaConstraints([{audio: true}], [{audio: true}]);
michael@0 29 test.chain.append([
michael@0 30 [
michael@0 31 "GET_IDENTITY_ASSERTION_FAILS_WITHOUT_PROVIDER",
michael@0 32 function(test) {
michael@0 33 test.pcLocal._pc.onidpassertionerror = function(e) {
michael@0 34 ok(e, "getIdentityAssertion must fail without provider");
michael@0 35 test.next();
michael@0 36 };
michael@0 37 test.pcLocal._pc.getIdentityAssertion();
michael@0 38 },
michael@0 39 ],
michael@0 40 [
michael@0 41 "GET_IDENTITY_ASSERTION_FIRES_EVENTUALLY_AND_SUBSEQUENTLY",
michael@0 42 function(test) {
michael@0 43 var fired = 0;
michael@0 44 test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html');
michael@0 45 test.pcLocal._pc.onidentityresult = function(e) {
michael@0 46 fired++;
michael@0 47 if (fired == 1) {
michael@0 48 ok(true, "identityresult fired");
michael@0 49 checkIdentity(e.assertion, 'someone@example.com');
michael@0 50 } else if (fired == 2) {
michael@0 51 ok(true, "identityresult fired 2x");
michael@0 52 checkIdentity(e.assertion, 'someone@example.com');
michael@0 53 test.next();
michael@0 54 }
michael@0 55 };
michael@0 56 test.pcLocal._pc.onidpassertionerror = function(e) {
michael@0 57 ok(false, "error event fired");
michael@0 58 test.next();
michael@0 59 };
michael@0 60 test.pcLocal._pc.getIdentityAssertion();
michael@0 61 test.pcLocal._pc.getIdentityAssertion();
michael@0 62 }
michael@0 63 ],
michael@0 64 [
michael@0 65 "GET_IDENTITY_ASSERTION_FAILS",
michael@0 66 function(test) {
michael@0 67 test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html#error');
michael@0 68 test.pcLocal._pc.onidentityresult = function(e) {
michael@0 69 ok(false, "Should not get an identity result");
michael@0 70 test.next();
michael@0 71 };
michael@0 72 test.pcLocal._pc.onidpassertionerror = function(err) {
michael@0 73 ok(err, "Got error event from getIdentityAssertion");
michael@0 74 test.next();
michael@0 75 };
michael@0 76 test.pcLocal._pc.getIdentityAssertion();
michael@0 77 }
michael@0 78 ],
michael@0 79 [
michael@0 80 "GET_IDENTITY_ASSERTION_IDP_NOT_READY",
michael@0 81 function(test) {
michael@0 82 test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html#error:ready');
michael@0 83 test.pcLocal._pc.onidentityresult = function(e) {
michael@0 84 ok(false, "Should not get an identity result");
michael@0 85 test.next();
michael@0 86 };
michael@0 87 test.pcLocal._pc.onidpassertionerror = function(e) {
michael@0 88 ok(e, "Got error callback from getIdentityAssertion");
michael@0 89 test.next();
michael@0 90 };
michael@0 91 test.pcLocal._pc.getIdentityAssertion();
michael@0 92 }
michael@0 93 ],
michael@0 94 [
michael@0 95 "GET_IDENTITY_ASSERTION_WITH_SPECIFIC_NAME",
michael@0 96 function(test) {
michael@0 97 test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html', 'user@example.com');
michael@0 98 test.pcLocal._pc.onidentityresult = function(e) {
michael@0 99 checkIdentity(e.assertion, 'user@example.com');
michael@0 100 test.next();
michael@0 101 };
michael@0 102 test.pcLocal._pc.onidpassertionerror = function(e) {
michael@0 103 ok(false, "Got error callback from getIdentityAssertion");
michael@0 104 test.next();
michael@0 105 };
michael@0 106 test.pcLocal._pc.getIdentityAssertion();
michael@0 107 }
michael@0 108 ]
michael@0 109 ]);
michael@0 110 test.run();
michael@0 111 }
michael@0 112 runTest(theTest);
michael@0 113
michael@0 114 </script>
michael@0 115 </pre>
michael@0 116 </body>
michael@0 117 </html>

mercurial