|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <head> |
|
4 <meta charset="utf-8"/> |
|
5 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
|
6 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
7 <script type="application/javascript" src="../mochitest/head.js"></script> |
|
8 <script type="application/javascript" src="../mochitest/pc.js"></script> |
|
9 <script type="application/javascript" src="../mochitest/templates.js"></script> |
|
10 <script type="application/javascript" src="identityevent.js"></script> |
|
11 </head> |
|
12 <body> |
|
13 <pre id="test"> |
|
14 <script type="application/javascript"> |
|
15 createHTML({ |
|
16 title: "setIdentityProvider leads to peerIdentity and assertions in SDP" |
|
17 }); |
|
18 |
|
19 var test; |
|
20 function theTest() { |
|
21 test = new PeerConnectionTest(); |
|
22 test.setMediaConstraints([{audio: true}], [{audio: true}]); |
|
23 test.setIdentityProvider(test.pcLocal, "test1.example.com", "idp.html", "someone"); |
|
24 test.setIdentityProvider(test.pcRemote, "test2.example.com", "idp.html", "someone"); |
|
25 |
|
26 var localEvents = trapIdentityEvents(test.pcLocal._pc); |
|
27 var remoteEvents = trapIdentityEvents(test.pcRemote._pc); |
|
28 |
|
29 test.chain.append([ |
|
30 [ |
|
31 "PEER_IDENTITY_IS_SET_CORRECTLY", |
|
32 function(test) { |
|
33 var outstanding = 0; |
|
34 // we have to wait for the identity result in order to get the actual |
|
35 // identity information, since the call will complete before the identity |
|
36 // provider has a chance to finish verifying... that's OK, but it makes |
|
37 // testing more difficult |
|
38 |
|
39 function checkOrSetupCheck(pc, pfx, idp, name) { |
|
40 function checkIdentity() { |
|
41 ok(pc.peerIdentity, pfx + "peerIdentity is set"); |
|
42 is(pc.peerIdentity.idp, idp, pfx + "IdP is correct"); |
|
43 is(pc.peerIdentity.name, name + "@" + idp, pfx + "identity is correct"); |
|
44 } |
|
45 if (pc.peerIdentity) { |
|
46 info(pfx + "peerIdentity already set"); |
|
47 checkIdentity(); |
|
48 } else { |
|
49 ++outstanding; |
|
50 info(pfx + "setting onpeeridentity handler"); |
|
51 pc.onpeeridentity = function checkIdentityEvent(e) { |
|
52 info(pfx + "checking peerIdentity"); |
|
53 checkIdentity(); |
|
54 --outstanding; |
|
55 if (outstanding <= 0) { |
|
56 test.next(); |
|
57 } |
|
58 }; |
|
59 } |
|
60 } |
|
61 |
|
62 checkOrSetupCheck(test.pcLocal._pc, "local: ", "test2.example.com", "someone"); |
|
63 checkOrSetupCheck(test.pcRemote._pc, "remote: ", "test1.example.com", "someone"); |
|
64 if (outstanding <= 0) { |
|
65 test.next(); |
|
66 } |
|
67 } |
|
68 ], |
|
69 [ |
|
70 "CHECK_IDENTITY_EVENTS", |
|
71 function(test) { |
|
72 ok(!localEvents.idpassertionerror , "No assertion generation errors on local"); |
|
73 ok(!remoteEvents.idpassertionerror, "No assertion generation errors on remote"); |
|
74 ok(!localEvents.idpvalidationerror, "No assertion validation errors on local"); |
|
75 ok( !remoteEvents.idpvalidationerror, "No assertion validation errors on remote"); |
|
76 ok(localEvents.identityresult, "local acquired identity assertions"); |
|
77 ok(remoteEvents.identityresult, "remote acquired identity assertions"); |
|
78 ok(localEvents.peeridentity, "local got peer identity"); |
|
79 ok(remoteEvents.peeridentity, "remote got peer identity"); |
|
80 test.next(); |
|
81 } |
|
82 ], |
|
83 [ |
|
84 "OFFERS_AND_ANSWERS_INCLUDE_IDENTITY", |
|
85 function(test) { |
|
86 ok(test.pcLocal._last_offer.sdp.contains("a=identity"), "a=identity is in the offer SDP"); |
|
87 ok(test.pcRemote._last_answer.sdp.contains("a=identity"), "a=identity is in the answer SDP"); |
|
88 test.next(); |
|
89 } |
|
90 ], |
|
91 [ |
|
92 "DESCRIPTIONS_CONTAIN_IDENTITY", |
|
93 function(test) { |
|
94 ok(test.pcLocal.localDescription.sdp.contains("a=identity"), |
|
95 "a=identity is in the local copy of the offer"); |
|
96 ok(test.pcRemote.localDescription.sdp.contains("a=identity"), |
|
97 "a=identity is in the remote copy of the offer"); |
|
98 ok(test.pcLocal.remoteDescription.sdp.contains("a=identity"), |
|
99 "a=identity is in the local copy of the answer"); |
|
100 ok(test.pcRemote.remoteDescription.sdp.contains("a=identity"), |
|
101 "a=identity is in the remote copy of the answer"); |
|
102 test.next(); |
|
103 } |
|
104 ] |
|
105 ]); |
|
106 test.run(); |
|
107 } |
|
108 runTest(theTest); |
|
109 |
|
110 |
|
111 |
|
112 </script> |
|
113 </pre> |
|
114 </body> |
|
115 </html> |