Bug 1119593 - Update identity tests, r=drno

--HG--
extra : rebase_source : ef6aeb4bf9223837db2e2763204be40c5ff6a74e
This commit is contained in:
Martin Thomson 2015-01-27 12:35:58 -08:00
Родитель bae5192e6e
Коммит 7f8f597ec4
4 изменённых файлов: 149 добавлений и 189 удалений

Просмотреть файл

@ -28,19 +28,17 @@ function theTest() {
test.setMediaConstraints([{audio: true}], [{audio: true}]);
test.chain.removeAfter('PC_REMOTE_CHECK_INITIAL_SIGNALINGSTATE');
test.chain.append([
[
"GET_IDENTITY_ASSERTION_FAILS_WITHOUT_PROVIDER",
function(test) {
function GET_IDENTITY_ASSERTION_FAILS_WITHOUT_PROVIDER(test) {
return new Promise(resolve => {
test.pcLocal._pc.onidpassertionerror = function(e) {
ok(e, "getIdentityAssertion must fail without provider");
test.next();
resolve();
};
test.pcLocal._pc.getIdentityAssertion();
});
},
],
[
"GET_IDENTITY_ASSERTION_FIRES_EVENTUALLY_AND_SUBSEQUENTLY",
function(test) {
function GET_IDENTITY_ASSERTION_FIRES_EVENTUALLY_AND_SUBSEQUENTLY(test) {
return new Promise(resolve => {
var fired = 0;
test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html');
test.pcLocal._pc.onidentityresult = function(e) {
@ -51,62 +49,59 @@ function theTest() {
} else if (fired == 2) {
ok(true, "identityresult fired 2x");
checkIdentity(e.assertion, 'someone@example.com');
test.next();
resolve();
}
};
test.pcLocal._pc.onidpassertionerror = function(e) {
ok(false, "error event fired");
test.next();
resolve();
};
test.pcLocal._pc.getIdentityAssertion();
test.pcLocal._pc.getIdentityAssertion();
}
],
[
"GET_IDENTITY_ASSERTION_FAILS",
function(test) {
});
},
function GET_IDENTITY_ASSERTION_FAILS(test) {
return new Promise(resolve => {
test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html#error');
test.pcLocal._pc.onidentityresult = function(e) {
ok(false, "Should not get an identity result");
test.next();
resolve();
};
test.pcLocal._pc.onidpassertionerror = function(err) {
ok(err, "Got error event from getIdentityAssertion");
test.next();
resolve();
};
test.pcLocal._pc.getIdentityAssertion();
}
],
[
"GET_IDENTITY_ASSERTION_IDP_NOT_READY",
function(test) {
});
},
function GET_IDENTITY_ASSERTION_IDP_NOT_READY(test) {
return new Promise(resolve => {
test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html#error:ready');
test.pcLocal._pc.onidentityresult = function(e) {
ok(false, "Should not get an identity result");
test.next();
resolve();
};
test.pcLocal._pc.onidpassertionerror = function(e) {
ok(e, "Got error callback from getIdentityAssertion");
test.next();
resolve();
};
test.pcLocal._pc.getIdentityAssertion();
}
],
[
"GET_IDENTITY_ASSERTION_WITH_SPECIFIC_NAME",
function(test) {
});
},
function GET_IDENTITY_ASSERTION_WITH_SPECIFIC_NAME(test) {
return new Promise(resolve => {
test.setIdentityProvider(test.pcLocal, 'example.com', 'idp.html', 'user@example.com');
test.pcLocal._pc.onidentityresult = function(e) {
checkIdentity(e.assertion, 'user@example.com');
test.next();
resolve();
};
test.pcLocal._pc.onidpassertionerror = function(e) {
ok(false, "Got error callback from getIdentityAssertion");
test.next();
resolve();
};
test.pcLocal._pc.getIdentityAssertion();
});
}
]
]);
test.run();
}

Просмотреть файл

@ -48,9 +48,8 @@ function theTest() {
test.setIdentityProvider(test.pcLocal, 'test1.example.com', 'idp.html');
test.setIdentityProvider(test.pcRemote, 'test2.example.com', 'idp.html');
test.chain.append([
[
"PEER_IDENTITY_IS_SET_CORRECTLY",
function(test) {
function PEER_IDENTITY_IS_SET_CORRECTLY(test) {
// no need to wait to check identity in this case,
// setRemoteDescription should wait for the IdP to complete
function checkIdentity(pc, pfx, idp, name) {
@ -60,26 +59,15 @@ function theTest() {
checkIdentity(test.pcLocal._pc, "local: ", "test2.example.com", "someone");
checkIdentity(test.pcRemote._pc, "remote: ", "test1.example.com", "someone");
test.next();
}
],
[
"REMOTE_STREAMS_ARE_RESTRICTED",
function(test) {
var remoteStream = test.pcLocal._pc.getRemoteStreams()[0];
var oneDone = false;
function done() {
if (!oneDone) {
oneDone = true;
return;
}
test.next();
}
},
audioIsSilence(true, remoteStream, done);
videoIsBlack(true, remoteStream, done);
function REMOTE_STREAMS_ARE_RESTRICTED(test) {
var remoteStream = test.pcLocal._pc.getRemoteStreams()[0];
return Promise.all([
new Promise(done => audioIsSilence(true, remoteStream, done)),
new Promise(done => videoIsBlack(true, remoteStream, done))
]);
}
],
]);
test.run();
}

Просмотреть файл

@ -27,48 +27,41 @@ function theTest() {
var remoteEvents = trapIdentityEvents(test.pcRemote._pc);
test.chain.append([
[
"PEER_IDENTITY_IS_SET_CORRECTLY",
function(test) {
function PEER_IDENTITY_IS_SET_CORRECTLY(test) {
var outstanding = 0;
// we have to wait for the identity result in order to get the actual
// identity information, since the call will complete before the identity
// provider has a chance to finish verifying... that's OK, but it makes
// testing more difficult
function checkOrSetupCheck(pc, pfx, idp, name) {
function checkOrSetupCheck(pc, prefix, idp, name) {
function checkIdentity() {
ok(pc.peerIdentity, pfx + "peerIdentity is set");
is(pc.peerIdentity.idp, idp, pfx + "IdP is correct");
is(pc.peerIdentity.name, name + "@" + idp, pfx + "identity is correct");
ok(pc.peerIdentity, prefix + "peerIdentity is set");
is(pc.peerIdentity.idp, idp, prefix + "IdP is correct");
is(pc.peerIdentity.name, name + "@" + idp, prefix + "identity is correct");
}
if (pc.peerIdentity) {
info(pfx + "peerIdentity already set");
info(prefix + "peerIdentity already set");
checkIdentity();
} else {
++outstanding;
info(pfx + "setting onpeeridentity handler");
pc.onpeeridentity = function checkIdentityEvent(e) {
info(pfx + "checking peerIdentity");
checkIdentity();
--outstanding;
if (outstanding <= 0) {
test.next();
}
};
}
return Promise.resolve();
}
checkOrSetupCheck(test.pcLocal._pc, "local: ", "test2.example.com", "someone");
checkOrSetupCheck(test.pcRemote._pc, "remote: ", "test1.example.com", "someone");
if (outstanding <= 0) {
test.next();
return new Promise(resolve => {
info(prefix + "setting onpeeridentity handler");
pc.onpeeridentity = e => {
checkIdentity();
resolve();
};
});
}
}
],
[
"CHECK_IDENTITY_EVENTS",
function(test) {
return Promise.all([
checkOrSetupCheck(test.pcLocal._pc, "local: ", "test2.example.com", "someone"),
checkOrSetupCheck(test.pcRemote._pc, "remote: ", "test1.example.com", "someone")
]);
},
function CHECK_IDENTITY_EVENTS(test) {
ok(!localEvents.idpassertionerror , "No assertion generation errors on local");
ok(!remoteEvents.idpassertionerror, "No assertion generation errors on remote");
ok(!localEvents.idpvalidationerror, "No assertion validation errors on local");
@ -77,20 +70,14 @@ function theTest() {
ok(remoteEvents.identityresult, "remote acquired identity assertions");
ok(localEvents.peeridentity, "local got peer identity");
ok(remoteEvents.peeridentity, "remote got peer identity");
test.next();
}
],
[
"OFFERS_AND_ANSWERS_INCLUDE_IDENTITY",
function(test) {
},
function OFFERS_AND_ANSWERS_INCLUDE_IDENTITY(test) {
ok(test.originalOffer.sdp.contains("a=identity"), "a=identity is in the offer SDP");
ok(test.originalAnswer.sdp.contains("a=identity"), "a=identity is in the answer SDP");
test.next();
}
],
[
"DESCRIPTIONS_CONTAIN_IDENTITY",
function(test) {
},
function DESCRIPTIONS_CONTAIN_IDENTITY(test) {
ok(test.pcLocal.localDescription.sdp.contains("a=identity"),
"a=identity is in the local copy of the offer");
ok(test.pcRemote.localDescription.sdp.contains("a=identity"),
@ -99,9 +86,7 @@ function theTest() {
"a=identity is in the local copy of the answer");
ok(test.pcRemote.remoteDescription.sdp.contains("a=identity"),
"a=identity is in the remote copy of the answer");
test.next();
}
]
]);
test.run();
}

Просмотреть файл

@ -28,9 +28,7 @@ runNetworkTest(function () {
var remoteEvents = trapIdentityEvents(test.pcRemote._pc);
test.chain.append([
[
'CHECK_IDENTITY_EVENTS',
function(test) {
function CHECK_IDENTITY_EVENTS(test) {
function checkEvents() {
ok(localEvents.idpassertionerror, 'local assertion generation should fail (idpassertionerror)');
is(localEvents.idpassertionerror.idp, 'example.com', 'event IdP is correct');
@ -46,35 +44,29 @@ runNetworkTest(function () {
is(localEvents.idpvalidationerror.protocol, 'idp.html#bad', 'event IdP protocol is #bad');
ok(!remoteEvents.idpvalidationerror, 'remote doesn\'t even see an assertion');
test.next();
}
// we actually have to wait on this because IdP validation happens asynchronously
if (localEvents.idpvalidationerror) {
checkEvents();
} else {
return Promise.resolve();
}
// have to let the other event handler have a chance to record success
// before we run the checks that rely on that recording
test.pcLocal._pc.onidpvalidationerror = setTimeout.bind(window, checkEvents, 1);
}
}
],
[
'PEER_IDENTITY_IS_EMPTY',
function(test) {
return new Promise(resolve => {
test.pcLocal._pc.onidpvalidationerror = resolve;
}).then(checkEvents);
},
function PEER_IDENTITY_IS_EMPTY(test) {
ok(!test.pcLocal._pc.peerIdentity, 'local peerIdentity is not set');
ok(!test.pcRemote._pc.peerIdentity, 'remote peerIdentity is not set');
test.next();
}
],
[
'ONLY_REMOTE_SDP_INCLUDES_IDENTITY_ASSERTION',
function(test) {
},
function ONLY_REMOTE_SDP_INCLUDES_IDENTITY_ASSERTION(test) {
ok(!test.originalOffer.sdp.contains('a=identity'), 'a=identity not contained in the offer SDP');
ok(test.originalAnswer.sdp.contains('a=identity'), 'a=identity is contained in the answer SDP');
test.next();
}
]
]);
test.run();
});