it(`validates the csrf token`, () => { const csrfToken = `abcd`; assert.throws(() => { // eslint-disable-next-line no-unused-vars const spark = makeSpark(`http://example.com/?code=5&state=${base64.encode(JSON.stringify({csrf_token: `someothertoken`}))}`, csrfToken); }, /CSRF token someothertoken does not match stored token abcd/); assert.throws(() => { // eslint-disable-next-line no-unused-vars const spark = makeSpark(`http://example.com/?code=5&state=${base64.encode(JSON.stringify({}))}`, csrfToken); }, /Expected CSRF token abcd, but not found in redirect query/); assert.throws(() => { // eslint-disable-next-line no-unused-vars const spark = makeSpark(`http://example.com/?code=5`, csrfToken); }, /Expected CSRF token abcd, but not found in redirect query/); const spark = makeSpark(`http://example.com/?code=5&state=${base64.encode(JSON.stringify({csrf_token: csrfToken}))}`, csrfToken); return spark.authorization.when(`change:ready`) .then(() => { assert.isTrue(spark.credentials.canAuthorize); assert.called(spark.getWindow().sessionStorage.removeItem); }); });
it(`requires an prefix option`, () => { assert.throws(() => { interceptor = SparkTrackingIdInterceptor.create({}); }, /`options.prefix` is required/); assert.doesNotThrow(() => { interceptor = SparkTrackingIdInterceptor.create({prefix: `spark-js-sdk--http-core`}); }, /`options.prefix` is required/); });
.then((err) => { assert.statusCode(err, 400); assert.throws(() => { base64.decode(err.body.message.split(`.`)[0]); }); assert.match(err.toString(), /POST .+\s/); assert.match(err.toString(), /WEBEX_TRACKING_ID: .+\s/); assert.match(err.toString(), /KMS_RESPONSE_STATUS: .+\s/); assert.match(err.toString(), /KMS_REQUEST_ID: .+/); assert.instanceOf(err, DryError); }));
it(`is not mutable`, () => { assert.throws(() => { interceptor.prefix = `this will throw`; }); });
it(`requires an options object`, () => { assert.throws(() => { interceptor = SparkTrackingIdInterceptor.create(); }, /`options.prefix` is required/); });
it(`throws a grant error`, () => { assert.throws(() => { makeSpark(`http://127.0.0.1:8000/?error=invalid_scope&error_description=The%20requested%20scope%20is%20invalid.`); }, /The requested scope is invalid./); });
it('should throw an error', () => { assert.throws(() => meeting.reconnect(), Error, 'Cannot reconnect, ReconnectionManager must first be defined.'); });
it('emptyActivity', async () => { assert.throws(() => generator.map()); });
it('initializeError', async () => { assert.throws(() => new ReportGenerator()); });
skipInNode(it)('emptyActivities', async () => { assert.throws(() => generator.add(undefined)); });