mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-30 22:34:10 -05:00
bae430fe24
chore: clean up comments remove commitlint update deps add new tests test separate ci test test test test test test chore: add preprelase test test test test test chore: update deps Update release-snapshot.yml Update .npmignore test chore: remove @verdaccio/commons-api dep chore: cleanup remove normalizeContributors remove validateMetadata fix test clean up getLocalRegistryTarballUri Update store.spec.ts clean up convertDistRemoteToLocalTarballUrls chore: update libraries reuse getPublic url clean up Update jest.config.js Update jest.config.js update nvmrc add tests
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import supertest from 'supertest';
|
|
|
|
import { HEADERS, HTTP_STATUS, TOKEN_BEARER } from '@verdaccio/core';
|
|
import { buildToken } from '@verdaccio/utils';
|
|
|
|
import { createUser, initializeServer } from './_helper';
|
|
|
|
describe('whoami', () => {
|
|
test('should return the logged username', async () => {
|
|
const app = await initializeServer('whoami.yaml');
|
|
// @ts-expect-error internal property
|
|
const { _body } = await createUser(app, 'test', 'test');
|
|
return supertest(app)
|
|
.get('/-/whoami')
|
|
.set('Accept', HEADERS.JSON)
|
|
.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, _body.token))
|
|
.expect('Content-Type', HEADERS.JSON_CHARSET)
|
|
.expect(HTTP_STATUS.OK)
|
|
.then((response) => {
|
|
expect(response.body.username).toEqual('test');
|
|
});
|
|
});
|
|
|
|
test.skip('should fails with 401 if is not logged in', async () => {
|
|
const app = await initializeServer('whoami.yaml');
|
|
// @ts-expect-error internal property
|
|
const { _body } = await createUser(app, 'test', 'test');
|
|
return supertest(app)
|
|
.get('/-/whoami')
|
|
.set('Accept', HEADERS.JSON)
|
|
.set(HEADERS.AUTHORIZATION, buildToken('invalid-token', _body.token))
|
|
.expect('Content-Type', HEADERS.JSON_CHARSET)
|
|
.expect(HTTP_STATUS.UNAUTHORIZED);
|
|
});
|
|
});
|