it('should interpolate message from object', function () {
        var error = AuthErrors.toMissingParameterError('param name', AuthErrors);
        logger.error(error);

        assert.equal(window.console.error.args[0][0], 'Missing parameter: param name');
        assert.isNotNull(window.console.error.thisValues[0]);
      });
Example #2
0
      beforeEach(function () {
        sandbox.stub(ErrorUtils, 'getErrorMessage').callsFake(function () {
          throw new Error('Not able to interpolate');
        });

        err = AuthErrors.toMissingParameterError('email');
        origMessage = err.message;
      });
Example #3
0
    describe('getErrorPageTemplate', function () {
      var badRequestPageErrors = [
        AuthErrors.toInvalidParameterError('paramName'),
        AuthErrors.toMissingParameterError('paramName'),
        OAuthErrors.toInvalidParameterError('paramName'),
        OAuthErrors.toMissingParameterError('paramName'),
        OAuthErrors.toError('UNKNOWN_CLIENT')
      ];

      badRequestPageErrors.forEach(function (err) {
        it('400 template returned for ' + err.message, function () {
          var errorPageTemplate = ErrorUtils.getErrorPageTemplate(err);
          assert.strictEqual(errorPageTemplate, FourHundredTemplate);
        });
      });

      it('500 template returned by default', function () {
        var errorPageTemplate =
          ErrorUtils.getErrorPageTemplate(OAuthErrors.toError('INVALID_ASSERTION'));
        assert.strictEqual(errorPageTemplate, FiveHundredTemplate);
      });
    });
    describe('getErrorPageUrl', function () {
      var badRequestPageErrors = [
        AuthErrors.toInvalidParameterError('paramName'),
        AuthErrors.toMissingParameterError('paramName'),
        OAuthErrors.toInvalidParameterError('paramName'),
        OAuthErrors.toMissingParameterError('paramName'),
        OAuthErrors.toError('UNKNOWN_CLIENT')
      ];

      badRequestPageErrors.forEach(function (err) {
        it('redirects to BAD_REQUEST_PAGE for ' + err.message, function () {
          var errorPageUrl = ErrorUtils.getErrorPageUrl(err);
          assert.include(errorPageUrl, Constants.BAD_REQUEST_PAGE);
        });
      });

      it('returns INTERNAL_ERROR_PAGE by default', function () {
        var errorPageUrl =
          ErrorUtils.getErrorPageUrl(OAuthErrors.toError('INVALID_ASSERTION'));
        assert.include(errorPageUrl, Constants.INTERNAL_ERROR_PAGE);
      });
    });
Example #5
0
 before(function () {
   err = AuthErrors.toMissingParameterError('param name', AuthErrors);
 });
Example #6
0
 beforeEach(function () {
   err = AuthErrors.toMissingParameterError('email');
   origMessage = err.message;
   return ErrorUtils.captureError(err, sentry, metrics, windowMock);
 });
Example #7
0
 before(function () {
   err = AuthErrors.toMissingParameterError('email');
 });