Update web-platform-tests to revision d3cf77a7b8c20c678b725238eaa8a72eca3787ae

This commit is contained in:
WPT Sync Bot 2019-04-25 22:18:37 -04:00
parent 880f3b8b7a
commit efca990ffe
541 changed files with 8000 additions and 2276 deletions

View file

@ -72,14 +72,14 @@
assert_equals(args.origin, window.origin,
'Expect args.origin argument to be the origin of this window');
assert_equals(env.location,
`https://${idpHost}/.well-known/idp-proxy/idp-test.js?foo=bar`,
assert_equals(env.location.href,
`https://${idpHost}/.well-known/idp-proxy/mock-idp.js?foo=bar`,
'Expect IdP proxy to be loaded with full well-known URL constructed from provider and protocol');
assert_equals(env.origin, `https://${idpHost}`,
assert_equals(env.location.origin, `https://${idpHost}`,
'Expect IdP to have its own origin');
assert_equals(args.options.protocol, 'idp-test.js?foo=bar',
assert_equals(args.options.protocol, 'mock-idp.js?foo=bar',
'Expect options.protocol to be the same value as being passed from here');
assert_equals(args.options.usernameHint, `alice@${idpDomain}`,
@ -114,7 +114,7 @@
const { idp, assertion } = parseAssertionResult(assertionResultStr);
assert_equals(idp.domain, idpDomain2);
assert_equals(idp.protocol, 'foo');
assert_equals(assertion.options.usernameHint, `alice@${idpDomain2}`);
assert_equals(assertion.args.options.usernameHint, `alice@${idpDomain2}`);
});
}, 'getIdentityAssertion() should succeed if mock-idp.js return different domain and protocol in assertion');
@ -350,12 +350,17 @@
}, 'createOffer() should return SDP containing identity assertion string if identity provider is set');
/*
4.4.2. Steps to create an offer
1. If the need for an identity assertion was identified when createOffer was
invoked, wait for the identity assertion request process to complete.
2. If the identity provider was unable to produce an identity assertion, reject p
with a newly created NotReadableError and abort these steps.
*/
6. Requesting Identity Assertions
The identity assertion request process is triggered by a call to
createOffer, createAnswer, or getIdentityAssertion. When these calls are
invoked and an identity provider has been set, the following steps are
executed:
...
If assertion generation fails, then the promise for the corresponding
function call is rejected with a newly created OperationError. */
promise_test(t => {
const pc = new RTCPeerConnection();
const port = window.location.port;
@ -366,18 +371,10 @@
usernameHint: `alice@${idpDomain}`
});
return promise_rejects(t, 'NotReadableError',
return promise_rejects(t, 'OperationError',
pc.createOffer());
}, 'createOffer() should reject with NotReadableError if identitity assertion request fails');
}, 'createOffer() should reject with OperationError if identity assertion request fails');
/*
4.4.2. Steps to create an answer
1. If the need for an identity assertion was identified when createAnswer was
invoked, wait for the identity assertion request process to complete.
2. If the identity provider was unable to produce an identity assertion, reject p
with a newly created NotReadableError and abort these steps.
*/
promise_test(t => {
const pc = new RTCPeerConnection();
const port = window.location.port;
@ -392,9 +389,9 @@
.createOffer()
.then(offer => pc.setRemoteDescription(offer))
.then(() =>
promise_rejects(t, 'NotReadableError',
promise_rejects(t, 'OperationError',
pc.createAnswer()));
}, 'createAnswer() should reject with NotReadableError if identitity assertion request fails');
}, 'createAnswer() should reject with OperationError if identity assertion request fails');
</script>

View file

@ -8,7 +8,7 @@
'use strict';
// Test is based on the following editor draft:
// https://w3c.github.io/webrtc-pc/archives/20170605/webrtc.html
// https://w3c.github.io/webrtc-identity/identity.html
// The tests here interacts with the mock identity provider located at
// /.well-known/idp-proxy/mock-idp.js
@ -54,7 +54,7 @@
is, there is a current value for peerIdentity ), then this also establishes a
target peer identity.
*/
promise_test(t => {
promise_test(async t => {
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
const pc2 = new RTCPeerConnection();
@ -70,51 +70,57 @@
usernameHint: `alice@${idpDomain}`
});
return pc1.createOffer()
.then(offer => pc2.setRemoteDescription(offer))
.then(() => pc2.peerIdentity)
.then(identityAssertion => {
const { idp, name } = identityAssertion;
assert_equals(idp, idpDomain, `Expect IdP domain to be ${idpDomain}`);
assert_equals(identityAssertion, `alice@${idpDomain}`,
`Expect validated identity from mock-idp.js to be same as specified in usernameHint`);
});
const peerIdentity = pc2.peerIdentity;
await pc2.setRemoteDescription(await pc1.createOffer());
const { idp, name } = await peerIdentity;
assert_equals(idp, idpHost, `Expect IdP to be ${idpHost}`);
assert_equals(name, `alice@${idpDomain}`,
`Expect validated identity from mock-idp.js to be same as specified in usernameHint`);
}, 'setRemoteDescription() on offer with a=identity should establish peerIdentity');
/*
4.3.2. setRemoteDescription
The target peer identity cannot be changed once set. Once set, if a different
value is provided, the user agent MUST reject the returned promise with a newly
created InvalidModificationError and abort this operation. The RTCPeerConnection
MUST be closed if the validated peer identity does not match the target peer
identity.
*/
promise_test(t => {
If the peerIdentity configuration is applied to the RTCPeerConnection, this
establishes a target peer identity of the provided value. Alternatively, if the
RTCPeerConnection has previously authenticated the identity of the peer (that
is, the peerIdentity promise is resolved), then this also establishes a
target peer identity.
The target peer identity cannot be changed once set.
*/
promise_test(async t => {
const port = window.location.port;
const [idpDomain] = getIdpDomains();
const idpHost = hostString(idpDomain, port);
const pc1 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
pc1.setIdentityProvider(idpHost, {
protocol: 'mock-idp.js',
usernameHint: `doesnt_matter@${idpDomain}`
});
const pc2 = new RTCPeerConnection({
peerIdentity: `bob@${idpDomain}`
});
t.add_cleanup(() => pc2.close());
pc1.setIdentityProvider(idpHost, {
pc2.setIdentityProvider(idpHost, {
protocol: 'mock-idp.js',
usernameHint: `alice@${idpDomain}`
});
return pc1.createOffer()
.then(offer =>
promise_rejects(t, 'InvalidModificationError',
pc2.setRemoteDescription(offer)))
.then(() => {
assert_true(pc2.signalingState, 'closed',
'Expect peer connection to be closed after mismatch peer identity');
});
const offer = await pc1.createOffer();
try {
await pc2.setRemoteDescription(offer);
assert_true(false, "Previous line (sRD) should have thrown!");
} catch (e) {
assert_equals(e.name, 'InvalidModificationError');
}
assert_true(pc2.signalingState, 'closed',
'Expect peer connection to be closed after mismatch peer identity');
}, 'setRemoteDescription() on offer with a=identity that resolve to value different from target peer identity should reject with InvalidModificationError');
/*
@ -154,7 +160,7 @@
return pc1.createOffer()
.then(offer => Promise.all([
promise_rejects(t, 'OperationError',
promise_rejects(t, 'IdpError',
pc2.setRemoteDescription(offer)),
promise_rejects(t, 'OperationError',
peerIdentityPromise)
@ -194,10 +200,10 @@
.then(assertionResultStr => {
const { idp, assertion } = parseAssertionResult(assertionResultStr);
assert_equals(idp.domain, idpDomain1,
'Sanity check domain of assertion is domain1');
assert_equals(idp.domain, idpHost1,
'Sanity check domain of assertion is host1');
assert_equals(assertion.options.usernameHint, `alice@${idpDomain2}`,
assert_equals(assertion.args.options.usernameHint, `alice@${idpDomain2}`,
'Sanity check domain1 is going to validate a domain2 identity');
return pc1.createOffer();