@verdaccio/api 7.0.0-next.6 → 7.0.1-next-8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +281 -0
- package/build/dist-tags.js +1 -1
- package/build/dist-tags.js.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/package.js +6 -3
- package/build/package.js.map +1 -1
- package/build/ping.js.map +1 -1
- package/build/publish.d.ts +21 -4
- package/build/publish.js +35 -9
- package/build/publish.js.map +1 -1
- package/build/search.js.map +1 -1
- package/build/stars.js +1 -1
- package/build/stars.js.map +1 -1
- package/build/user.js +19 -3
- package/build/user.js.map +1 -1
- package/build/v1/profile.js +6 -3
- package/build/v1/profile.js.map +1 -1
- package/build/v1/search.js +4 -3
- package/build/v1/search.js.map +1 -1
- package/build/v1/token.js +1 -1
- package/build/v1/token.js.map +1 -1
- package/build/whoami.js +2 -2
- package/build/whoami.js.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +3 -2
- package/src/package.ts +3 -1
- package/src/publish.ts +31 -6
- package/src/user.ts +17 -0
- package/src/v1/profile.ts +5 -3
- package/src/v1/search.ts +2 -1
- package/test/integration/_helper.ts +33 -1
- package/test/integration/config/owner.yaml +24 -0
- package/test/integration/config/profile.yaml +27 -0
- package/test/integration/config/user.jwt.yaml +1 -1
- package/test/integration/config/user.yaml +1 -1
- package/test/integration/distTag.spec.ts +1 -0
- package/test/integration/owner.spec.ts +119 -0
- package/test/integration/package.spec.ts +3 -2
- package/test/integration/ping.spec.ts +1 -0
- package/test/integration/profile.spec.ts +112 -0
- package/test/integration/publish.spec.ts +1 -0
- package/test/integration/search.spec.ts +13 -0
- package/test/integration/star.spec.ts +1 -0
- package/test/integration/token.spec.ts +1 -0
- package/test/integration/user.spec.ts +54 -1
- package/test/integration/whoami.spec.ts +1 -0
- package/test/unit/validate.api.params.middleware.spec.ts +1 -0
- package/jest.config.js +0 -10
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import supertest from 'supertest';
|
|
2
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
2
3
|
|
|
3
4
|
import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '@verdaccio/core';
|
|
4
5
|
import { buildToken } from '@verdaccio/utils';
|
|
@@ -7,7 +8,7 @@ import { createUser, getPackage, initializeServer } from './_helper';
|
|
|
7
8
|
|
|
8
9
|
const FORBIDDEN_VUE = 'authorization required to access package vue';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
vi.setConfig({ testTimeout: 20000 });
|
|
11
12
|
|
|
12
13
|
describe('token', () => {
|
|
13
14
|
describe('basics', () => {
|
|
@@ -148,6 +149,25 @@ describe('token', () => {
|
|
|
148
149
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
149
150
|
.expect(HTTP_STATUS.OK);
|
|
150
151
|
expect(response2.body.ok).toBe(`you are authenticated as '${credentials.name}'`);
|
|
152
|
+
expect(response2.body.name).toBe(credentials.name);
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
test.each([['user.yaml'], ['user.jwt.yaml']])(
|
|
157
|
+
'should return name of requested user',
|
|
158
|
+
async (conf) => {
|
|
159
|
+
const app = await initializeServer(conf);
|
|
160
|
+
const username = 'yeti';
|
|
161
|
+
const credentials = { name: 'jota', password: 'secretPass' };
|
|
162
|
+
const response = await createUser(app, credentials.name, credentials.password);
|
|
163
|
+
expect(response.body.ok).toMatch(`user '${credentials.name}' created`);
|
|
164
|
+
const response3 = await supertest(app)
|
|
165
|
+
.get(`/-/user/org.couchdb.user:${username}`)
|
|
166
|
+
.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, response.body.token))
|
|
167
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
168
|
+
.expect(HTTP_STATUS.OK);
|
|
169
|
+
expect(response3.body.ok).toBe(`you are authenticated as '${credentials.name}'`);
|
|
170
|
+
expect(response3.body.name).toBe(username);
|
|
151
171
|
}
|
|
152
172
|
);
|
|
153
173
|
|
|
@@ -165,5 +185,38 @@ describe('token', () => {
|
|
|
165
185
|
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
166
186
|
.expect(HTTP_STATUS.OK);
|
|
167
187
|
});
|
|
188
|
+
|
|
189
|
+
test.each([['user.yaml'], ['user.jwt.yaml']])(
|
|
190
|
+
'should return "false" if user is not logged in',
|
|
191
|
+
async (conf) => {
|
|
192
|
+
const app = await initializeServer(conf);
|
|
193
|
+
const credentials = { name: 'jota', password: '' };
|
|
194
|
+
const response = await supertest(app)
|
|
195
|
+
.get(`/-/user/org.couchdb.user:${credentials.name}`)
|
|
196
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
197
|
+
.expect(HTTP_STATUS.OK);
|
|
198
|
+
expect(response.body.ok).toBe(false);
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
|
|
202
|
+
test.each([['user.yaml'], ['user.jwt.yaml']])(
|
|
203
|
+
'should fail if URL does not match user in request body',
|
|
204
|
+
async (conf) => {
|
|
205
|
+
const app = await initializeServer(conf);
|
|
206
|
+
const credentials = { name: 'jota', password: 'secretPass' };
|
|
207
|
+
const response = await createUser(app, credentials.name, credentials.password);
|
|
208
|
+
expect(response.body.ok).toMatch(`user '${credentials.name}' created`);
|
|
209
|
+
const response2 = await supertest(app)
|
|
210
|
+
.put('/-/user/org.couchdb.user:yeti') // different user
|
|
211
|
+
.set(HEADERS.AUTHORIZATION, buildToken(TOKEN_BEARER, response.body.token))
|
|
212
|
+
.send({
|
|
213
|
+
name: credentials.name,
|
|
214
|
+
password: credentials.password,
|
|
215
|
+
})
|
|
216
|
+
.expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
217
|
+
.expect(HTTP_STATUS.BAD_REQUEST);
|
|
218
|
+
expect(response2.body.error).toBe(API_ERROR.USERNAME_MISMATCH);
|
|
219
|
+
}
|
|
220
|
+
);
|
|
168
221
|
});
|
|
169
222
|
});
|