How to use the @verdaccio/commons-api.HTTP_STATUS.UNAUTHORIZED function in @verdaccio/commons-api

To help you get started, we’ve selected a few @verdaccio/commons-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github verdaccio / verdaccio / test / unit / modules / logger / parser.spec.ts View on Github external
describe('test errors log', () => {
      const middlewareObject = { name: 'verdaccio',
        request: {
          method: 'POST',
          url: '/-/npm/v1/user'
        },
        user: 'userTest2001',
        remoteIP: '::ffff:127.0.0.1',
        status: HTTP_STATUS.UNAUTHORIZED,
        error: 'some error',
        msg: '@{status}, user: @{user}(@{remoteIP}), req: \'@{request.method} @{request.url}\', error: @{!error}'
      };

      test('should display error log', () => {
        const expectedErrorMessage = `401, user: userTest2001(::ffff:127.0.0.1), req: 'POST /-/npm/v1/user', error: some error`;
        expect(fillInMsgTemplate(LOG_VERDACCIO_ERROR, middlewareObject, false))
        .toEqual(expectedErrorMessage);
      });

      test('should display error log with colors', () => {
        const expectedErrorMessage = `401, user: g[userTest2001](g[::ffff:127.0.0.1]), req: 'g[POST] g[/-/npm/v1/user]', error: r[some error]`;
        expect(fillInMsgTemplate(LOG_VERDACCIO_ERROR, middlewareObject, true))
        .toEqual(expectedErrorMessage);
      });
    });