mirror of
https://github.com/mozilla/fxa.git
synced 2025-12-13 20:36:41 +01:00
Because: * Test all didn't run in parallel to take advantage of more cores and a few older tests were flakey. * Tests would hang as packages had a default test that was in watch mode. This commit: * Updates several flakey tests and runs the test all in parallel for a shorter completion time. * Updates settings and payment-server packages to have new watch command and deafult test command that runs the tests. Closes #FXA-6096
137 lines
4.1 KiB
JavaScript
137 lines
4.1 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/* global describe,it,before,after */
|
|
|
|
var IdP = require('browserid-local-verify/testing').IdP,
|
|
Client = require('browserid-local-verify/testing').Client,
|
|
Verifier = require('./lib/verifier.js'),
|
|
should = require('should'),
|
|
shouldReturnSecurityHeaders = require('./lib/should-return-security-headers.js'),
|
|
request = require('request');
|
|
|
|
describe('unverified email', function () {
|
|
var fallback = new IdP();
|
|
var verifier = new Verifier();
|
|
var client;
|
|
|
|
before(async () => {
|
|
await new Promise((resolve) => fallback.start(resolve));
|
|
verifier.setFallback(fallback);
|
|
await new Promise((resolve) => verifier.start(resolve));
|
|
});
|
|
|
|
after(async () => {
|
|
await new Promise((resolve) => verifier.stop(resolve));
|
|
await new Promise((resolve) => fallback.stop(resolve));
|
|
});
|
|
|
|
it('(v1) assertion with unverified email address should fail to verify', function (done) {
|
|
client = new Client({
|
|
idp: fallback,
|
|
principal: { 'unverified-email': 'bob@example.com' },
|
|
});
|
|
// clear email
|
|
client.email(null);
|
|
client.assertion(
|
|
{ audience: 'http://example.com' },
|
|
function (_, assertion) {
|
|
request(
|
|
{
|
|
method: 'post',
|
|
url: verifier.v1url(),
|
|
json: true,
|
|
body: {
|
|
assertion: assertion,
|
|
audience: 'http://example.com',
|
|
},
|
|
},
|
|
function (err, r) {
|
|
should.not.exist(err);
|
|
r.statusCode.should.equal(200);
|
|
r.body.status.should.equal('failure');
|
|
r.body.reason.should.startWith('untrusted assertion');
|
|
shouldReturnSecurityHeaders(r);
|
|
done();
|
|
}
|
|
);
|
|
}
|
|
);
|
|
});
|
|
|
|
it('(v1) assertion with unverified email address and forceIssuer should verify', function (done) {
|
|
client = new Client({
|
|
idp: fallback,
|
|
principal: { 'unverified-email': 'bob@example.com' },
|
|
});
|
|
client.assertion(
|
|
{ audience: 'http://example.com' },
|
|
function (_, assertion) {
|
|
request(
|
|
{
|
|
method: 'post',
|
|
url: verifier.url(),
|
|
json: true,
|
|
body: {
|
|
assertion: assertion,
|
|
audience: 'http://example.com',
|
|
experimental_forceIssuer: fallback.domain(),
|
|
},
|
|
},
|
|
function (err, r) {
|
|
should.not.exist(err);
|
|
r.statusCode.should.equal(200);
|
|
r.body.status.should.equal('okay');
|
|
r.body.idpClaims.should.be.type('object');
|
|
r.body.idpClaims['unverified-email'].should.equal(
|
|
'bob@example.com'
|
|
);
|
|
r.body.should.not.have.property('unverified-email');
|
|
shouldReturnSecurityHeaders(r);
|
|
done();
|
|
}
|
|
);
|
|
}
|
|
);
|
|
});
|
|
|
|
it('(v1) allowUnverified causes extraction of unverified email addresses', function (done) {
|
|
client = new Client({
|
|
idp: fallback,
|
|
principal: { 'unverified-email': 'bob@example.com' },
|
|
});
|
|
|
|
client.assertion(
|
|
{ audience: 'http://example.com' },
|
|
function (_, assertion) {
|
|
request(
|
|
{
|
|
method: 'post',
|
|
url: verifier.v1url(),
|
|
json: true,
|
|
body: {
|
|
assertion: assertion,
|
|
audience: 'http://example.com',
|
|
experimental_forceIssuer: fallback.domain(),
|
|
experimental_allowUnverified: true,
|
|
},
|
|
},
|
|
function (err, r) {
|
|
should.not.exist(err);
|
|
r.statusCode.should.equal(200);
|
|
r.body.status.should.equal('okay');
|
|
r.body.idpClaims.should.be.type('object');
|
|
r.body.idpClaims['unverified-email'].should.equal(
|
|
'bob@example.com'
|
|
);
|
|
r.body.should.have.property('unverified-email');
|
|
shouldReturnSecurityHeaders(r);
|
|
done();
|
|
}
|
|
);
|
|
}
|
|
);
|
|
});
|
|
});
|