.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);
 }));
 .then(() => {
   assert.called(spark.authorization.initiateAuthorizationCodeGrant);
   assert.include(spark.getWindow().location, `response_type=code`);
   const query = url.parse(spark.getWindow().location, true).query;
   let state = query.state;
   state = JSON.parse(base64.decode(state));
   assert.property(state, `csrf_token`);
   assert.isDefined(state.csrf_token);
   assert.match(state.csrf_token, patterns.uuid);
   assert.called(spark.getWindow().sessionStorage.setItem);
   assert.calledWith(spark.getWindow().sessionStorage.setItem, `oauth2-csrf-token`, state.csrf_token);
 });
      it('returns "documents" if a whiteboard mimeType is found in item.actions', () => {
        const items = [
          {
            mimeType: 'image/png',
            actions: [{
              mimeType: 'application/x-cisco-spark-whiteboard',
              type: 'edit',
              url: 'https://boards.example.com/boards/1'
            }]
          }
        ];

        assert.equal(sa._determineContentCategory(items), 'documents');
      });
      it(`emits a change event`, () => {
        spark.internal.device.features.developer.add({
          key: `another-developer-feature`,
          val: `true`,
          value: true,
          mutable: false
        });

        assert.calledOnce(deviceFeaturesChangeDeveloperSpy);
        assert.calledOnce(deviceChangeFeaturesDeveloperSpy);
        assert.calledOnce(deviceChangeFeaturesSpy);
        assert.calledOnce(deviceChangeSpy);
        assert.calledOnce(sparkChangeSpy);
        assert.calledOnce(sparkChangeDeviceSpy);
        assert.calledOnce(sparkChangeDeviceFeaturesSpy);
        assert.calledOnce(sparkChangeDeviceFeaturesDeveloperSpy);
      });
Beispiel #5
0
        it(`emits \`change:${keyType}\` on ${keyType} feature change`, () => {
          const mockEventHandler = sinon.spy();

          spark.internal.feature.on(`change:${keyType}`, mockEventHandler);
          const key = 'featureName';
          const feature = {
            key,
            mutable: true,
            type: 'boolean',
            val: 'true',
            value: true
          };

          spark.internal.device.features[keyType].add(feature);

          return assert.called(mockEventHandler);
        });
      it(`emits a change event`, () => {
        const data = cloneDeep(deviceFixture);
        data.features.developer[1] = {
          key: `another-feature`,
          val: `false`,
          value: false,
          mutable: false
        };
        spark.internal.device._processRegistrationSuccess({body: data});

        assert.calledOnce(deviceFeaturesChangeDeveloperSpy);
        assert.calledOnce(deviceChangeFeaturesDeveloperSpy);
        assert.calledOnce(deviceChangeFeaturesSpy);
        assert.calledOnce(deviceChangeSpy);
        assert.calledOnce(sparkChangeSpy);
        assert.calledOnce(sparkChangeDeviceSpy);
        assert.calledOnce(sparkChangeDeviceFeaturesSpy);
        assert.calledOnce(sparkChangeDeviceFeaturesDeveloperSpy);
      });
Beispiel #7
0
 .then(() => {
   assert.called(spark.internal.device.features[keyType].add);
   assert.equal(spark.request.getCall(0).args[0].resource, `features/users/${spark.internal.device.userId} /${keyType}`);
 });
Beispiel #8
0
 it('does not allow entitlement keyType to be set', () => assert.isRejected(
   spark.internal.feature.setFeature('entitlement', 'featureName', true),
   /Only `developer` and `user` feature toggles can be set./
 ));
Beispiel #9
0
 .then((res) => {
   assert.equal(res, id);
 });
Beispiel #10
0
 it(`returns a tracking id`, () => {
   const pattern = /spark-js-sdk--http-core_.{8}(?:-.{4}){3}-.{12}_\d+/;
   assert.match(interceptor._generateTrackingId(), pattern);
   assert.match(interceptor._generateTrackingId(), pattern);
   assert.match(interceptor._generateTrackingId(), pattern);
 });
Beispiel #11
0
 it(`is an integer`, () => {
   assert.isNumber(interceptor.sequence);
 });
Beispiel #12
0
 it(`defaults to a uuid`, () => {
   const pattern = /.{8}(?:-.{4}){3}-.{12}/;
   assert.match(interceptor.base, pattern);
 });
Beispiel #13
0
 .then((err) => {
   assert.instanceOf(err, SparkHttpError);
   assert.instanceOf(err, SparkHttpError.BadRequest);
 });
Beispiel #14
0
 it('requires a `password`', () => assert.isRejected(userService.setPassword(), /`options.password` is required/));
Beispiel #15
0
 it('requires the `emailAddress` to be a uuid', () => assert.isRejected(userService.recordUUID({
   id: uuid.v4(),
   emailAddress: 'not an email address'
 }), /`user.emailAddress` must be an email address/));
Beispiel #16
0
 it('requires an `emailAddress`', () => assert.isRejected(userService.recordUUID({
   id: uuid.v4()
 }), /`user.emailAddress` is required/));
Beispiel #17
0
 it('requires the `id` to be a uuid', () => assert.isRejected(userService.recordUUID({
   id: 'not a uuid'
 }), /`user.id` must be a uuid/));
Beispiel #18
0
 it('requires an `id`', () => assert.isRejected(userService.recordUUID({}), /`user.id` is required/));
Beispiel #19
0
 it('requires a `user`', () => assert.isRejected(userService.recordUUID(), /`user` is required/));
Beispiel #20
0
 it(`has just enough of a test suite to not crash the test suite`, () => {
   assert.isTrue(true);
 });
Beispiel #21
0
 .then((res) => {
   assert.property(res.options.headers, `trackingid`);
 });
Beispiel #22
0
 it('requires a `displayName`', () => assert.isRejected(userService.update(), /`options.displayName` is required/));
Beispiel #23
0
 it(`requires an options object`, () => {
   assert.throws(() => {
     interceptor = SparkTrackingIdInterceptor.create();
   }, /`options.prefix` is required/);
 });
Beispiel #24
0
 it('requires an `email` param', () => assert.isRejected(userService.verify(), /`options.email` is required/));
Beispiel #25
0
 it(`is not mutable`, () => {
   assert.throws(() => {
     interceptor.prefix = `this will throw`;
   });
 });
Beispiel #26
0
 it('requires a valid keyType', () => assert.isRejected(
   spark.internal.feature.getFeature('none', 'featureName', {}),
   /Invalid feature keyType provided. Only `developer`, `user`, and `entitlement` feature toggles are permitted./
 ));
Beispiel #27
0
 it(`increases on every every access`, () => {
   const seq = interceptor.sequence;
   assert.equal(interceptor.sequence, seq + 1);
   assert.equal(interceptor.sequence, seq + 2);
   assert.equal(interceptor.sequence, seq + 3);
 });
Beispiel #28
0
 .then((result) => assert.deepEqual(result, feature.value));
Beispiel #29
0
 it(`defaults to true`, () => {
   assert.isTrue(interceptor.requiresTrackingId({headers: {}}));
 });
Beispiel #30
0
 it('requires a valid email', () => assert.isRejected(userService.asUUID('not valid email'), /Provided user object does not appear to identify a user/));