Example #1
0
 .then((reason) => {
   assert.instanceOf(reason, NotAuthorized);
   assert.match(reason.code, 4401);
   assert.match(reason.reason, /Authorization Failed/);
   assert.match(reason.message, /Authorization Failed/);
   return s.close();
 });
Example #2
0
 .then((reason) => {
   assert.instanceOf(reason, Forbidden);
   assert.match(reason.code, 4403);
   assert.match(reason.reason, /Not entitled/);
   assert.match(reason.message, /Not entitled/);
   return s.close();
 });
Example #3
0
 .then((reason) => {
   assert.instanceOf(reason, AuthorizationError);
   assert.match(reason.code, 1008);
   assert.match(reason.reason, /Authentication Failed/);
   assert.match(reason.message, /Authentication Failed/);
   return s.close();
 });
Example #4
0
 .then((reason) => {
   assert.instanceOf(reason, ConnectionError);
   assert.match(reason.code, 4001);
   assert.match(reason.reason, /No/);
   assert.match(reason.message, /No/);
   return s.close();
 });
Example #5
0
 .then((reason) => {
   assert.instanceOf(reason, BadRequest);
   assert.match(reason.code, 4400);
   assert.match(reason.reason, /Service accounts can't use this endpoint/);
   assert.match(reason.message, /Service accounts can't use this endpoint/);
   return s.close();
 });
Example #6
0
 it(`gets overridden by derived classes`, () => {
   class MyException extends Exception {
     static defaultMessage = `My exception occurred`;
   }
   const exception = new MyException();
   assert.match(exception.message, /My exception occurred/);
   assert.match(exception.toString(), /My exception occurred/);
 });
 .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);
 }));
Example #8
0
    (bowser.msie ? it.skip : it)('includes the exception class name when stringified', () => {
      class MyException extends Exception {
        static defaultMessage = 'My exception occurred';
      }

      let m = new MyException();

      assert.match(m.toString(), /MyException: My exception occurred/);

      m = new MyException('Your exception occurred');
      assert.match(m.toString(), /MyException: Your exception occurred/);
    });
Example #9
0
 it(`ensures we always use text-mode WebSockets`, () => {
   let s = new Socket();
   s.open(`ws://example.com`, mockoptions);
   assert.match(s.url, /outboundWireFormat=text/);
   assert.equal(s.url, `ws://example.com?outboundWireFormat=text&bufferStates=true`);
   const p1 = s.close();
   s = new Socket();
   s.open(`ws://example.com?queryparam=something`, mockoptions);
   assert.match(s.url, /outboundWireFormat=text/);
   assert.equal(s.url, `ws://example.com?queryparam=something&outboundWireFormat=text&bufferStates=true`);
   return Promise.all([
     p1,
     s.close()
   ]);
 });
Example #10
0
    skipInBrowser(it)(`includes the exception class name when stringified`, () => {
      class MyException extends Exception {
        static defaultMessage = `My exception occurred`;
      }

      const m = new MyException();
      assert.match(m.toString(), /MyException:/);
    });
Example #11
0
          .then((conversation) => {
            assert.isConversation(conversation);
            assert.isOneOnOneConversation(conversation);
            assert.isNewEncryptedConversation(conversation);

            const participant = find(conversation.participants.items, {emailAddress: email});

            assert.include(participant.tags, 'SIDE_BOARDED');
            assert.match(participant.id, patterns.uuid);
          }));
Example #12
0
 .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);
 });
Example #13
0
          .then(() => {
            assert.called(spark.authorization.initiateAuthorizationCodeGrant);
            assert.include(spark.getWindow().location, 'response_type=code');
            const {query} = url.parse(spark.getWindow().location, true);
            let {state} = query;

            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);
          });
Example #14
0
 it(`buffers custom errors in a readable fashion`, () => {
   spark.config.logger.level = `trace`;
   const error = new SparkHttpError({
     statusCode: 500,
     body: {
       error: `Internal Error`
     },
     options: {
       service: ``,
       headers: {}
     }
   });
   spark.logger.log(error);
   assert.lengthOf(spark.logger.buffer, 1);
   assert.match(spark.logger.buffer[0][1], /SparkHttpError/g);
 });
Example #15
0
 browserOnly(it)(`prints custom errors in a readable fashion`, () => {
   spark.config.logger.level = `trace`;
   const error = new SparkHttpError({
     statusCode: 500,
     body: {
       error: `Internal Error`
     },
     options: {
       service: ``,
       headers: {}
     }
   });
   spark.logger.log(error);
   assert.lengthOf(spark.logger.buffer, 1);
   assert.match(console.log.args[0][0], /SparkHttpError/);
 });
Example #16
0
      it('gets used when no messsage is supplied', () => {
        let exception = new Exception();

        assert.match(exception.message, /An error occurred/);
        assert.match(exception.toString(), /An error occurred/);

        exception = new Exception(undefined);
        assert.match(exception.message, /An error occurred/);
        assert.match(exception.toString(), /An error occurred/);

        exception = new Exception(null);
        assert.match(exception.message, /An error occurred/);
        assert.match(exception.toString(), /An error occurred/);

        exception = new Exception('');
        assert.match(exception.message, /An error occurred/);
        assert.match(exception.toString(), /An error occurred/);
      });
Example #17
0
      it('enables derived classes to override the default message', () => {
        class NoParserException extends Exception {
          static defaultMessage = 'no parser'
        }

        class DerivedNoParserException extends NoParserException {

        }

        class StaticBadParserException extends DerivedNoParserException {
          static parse() {
            return 'not really parsed';
          }
        }

        class NonStaticBadParserException extends StaticBadParserException {
          static parse() {
            return 'not really parsed, but like, totally not static';
          }
        }

        let e = new NoParserException();

        assert.match(e.message, /no parser/);
        assert.match(e.toString(), /no parser/);

        e = new DerivedNoParserException();
        assert.match(e.message, /no parser/);
        assert.match(e.toString(), /no parser/);

        e = new StaticBadParserException();
        assert.match(e.message, /not really parsed/);
        assert.match(e.toString(), /not really parsed/);

        e = new NonStaticBadParserException();
        assert.match(e.message, /not really parsed, but like, totally not static/);
        assert.match(e.toString(), /not really parsed, but like, totally not static/);
      });
Example #18
0
 it(`stores the specified message in the log buffer`, () => {
   spark.logger.log(`test`);
   assert.lengthOf(spark.logger.buffer, 1);
   assert.isNumber(spark.logger.buffer[0][0]);
   assert.match(spark.logger.buffer[0][1], /test/);
 });
Example #19
0
 .then((res) => {
   assert.isFalse(mockRealtimeChannel.isSharingMercury);
   assert.deepEqual(res, replaceBindingRes);
   assert.match(socketOpenStub.args[0][0], new RegExp(replaceBindingRes.webSocketUrl));
   assert.calledWith(socketOpenStub, sinon.match(replaceBindingRes.webSocketUrl), sinon.match.any);
 })
Example #20
0
 .then((wsUrl) => assert.match(wsUrl, /multipleConnections/)));
Example #21
0
 it(`gets used when no messsage is supplied`, () => {
   const exception = new Exception();
   assert.match(exception.message, /An error occurred/);
   assert.match(exception.toString(), /An error occurred/);
 });
Example #22
0
 .then((wsUrl) => {
   assert.match(wsUrl, /mercuryRegistrationStatus=true/);
   assert.notMatch(wsUrl, /bufferStates/);
 }));
Example #23
0
 .then(returnFirstArg((f) => assert.match(f.type, hashTestText.type || /text\/plain/)))
Example #24
0
      it('gets ignored when a string is supplied to the constructor', () => {
        const exception = new Exception('Something bad happened');

        assert.match(exception.message, /Something bad happened/);
        assert.match(exception.toString(), /Something bad happened/);
      });
Example #25
0
 .then(returnFirstArg((f) => assert.match(f.type, /text\/plain/)))
Example #26
0
 it(`defaults to a uuid`, () => {
   const pattern = /.{8}(?:-.{4}){3}-.{12}/;
   assert.match(interceptor.base, pattern);
 });
Example #27
0
 .then((wsUrl) => assert.match(wsUrl, /isRegistrationRefreshEnabled=true/)));
Example #28
0
 .then((wsUrl) => assert.match(wsUrl, /mercuryRegistrationStatus=true/)));
Example #29
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);
 });
Example #30
0
 .then((wsUrl) => assert.match(wsUrl, /bufferStates=true/)));