Skip to content

Commit 289923f

Browse files
Merge pull request #84 from bufferoverflow/refactor/upgrade-flow-types
refactor: upgrade to latest flow-types for verdaccio 4.x
2 parents d4e5d37 + 03db18d commit 289923f

File tree

4 files changed

+51
-18
lines changed

4 files changed

+51
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@commitlint/cli": "7.0.0",
5858
"@commitlint/config-conventional": "7.0.1",
5959
"@commitlint/travis-cli": "7.0.0",
60-
"@verdaccio/types": "3.5.1",
60+
"@verdaccio/types": "^4.1.5",
6161
"babel-cli": "6.26.0",
6262
"babel-core": "^6.26.3",
6363
"babel-eslint": "8.2.6",

src/gitlab.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ export default class VerdaccioGitLab implements IPluginAuth {
150150
return cb(null, true);
151151
}
152152

153+
changePassword(user: string, password: string, newPassword: string, cb: verdaccio$Callback) {
154+
this.logger.trace(`[gitlab] changePassword called for user: ${user}`);
155+
return cb(httperror[501]('You are using verdaccio-gitlab integration. Please change your password in gitlab'));
156+
}
157+
153158
allow_access(user: RemoteUser, _package: VerdaccioGitlabPackageAccess, cb: Callback) {
154159
if (!_package.gitlab) return cb(null, false);
155160

@@ -193,7 +198,7 @@ export default class VerdaccioGitLab implements IPluginAuth {
193198
} else {
194199
this.logger.debug(`[gitlab] user: ${user.name || ''} denied from publishing package: ${_package.name}`);
195200
const missingPerm = _package.name.indexOf('@') === 0 ? 'package-scope' : 'package-name';
196-
return cb(httperror[403](`must have required permissions: ${this.config.publish || ''} at ${missingPerm}`));
201+
return cb(httperror[403](`must have required permissions: ${this.publishLevel || ''} at ${missingPerm}`));
197202
}
198203
}
199204

test/unit/gitlab.spec.js

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
6161
const _package: VerdaccioGitlabPackageAccess = {
6262
name: '@myGroup/myPackage',
6363
access: ['$authenticated'],
64-
gitlab: true
64+
gitlab: true,
65+
publish: ['$authenticated'],
66+
proxy: ['npmjs']
6567
};
6668

6769
const cb: Callback = (err, data) => {
@@ -79,7 +81,9 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
7981
const _package: VerdaccioGitlabPackageAccess = {
8082
name: '@anotherGroup/myProject',
8183
access: ['$authenticated'],
82-
gitlab: true
84+
gitlab: true,
85+
publish: ['$authenticated'],
86+
proxy: ['npmjs']
8387
};
8488

8589
const cb: Callback = (err, data) => {
@@ -97,7 +101,9 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
97101
const _package: VerdaccioGitlabPackageAccess = {
98102
name: config.user,
99103
access: ['$authenticated'],
100-
gitlab: true
104+
gitlab: true,
105+
publish: ['$authenticated'],
106+
proxy: ['npmjs']
101107
};
102108

103109
const cb: Callback = (err, data) => {
@@ -114,8 +120,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
114120
const verdaccioGitlab: VerdaccioGitlab = new VerdaccioGitlab(config.verdaccioGitlabConfig, config.options);
115121
const _package: VerdaccioGitlabPackageAccess = {
116122
name: config.user,
117-
access: undefined,
118-
gitlab: true
123+
access: [],
124+
gitlab: true,
125+
publish: ['$authenticated'],
126+
proxy: ['npmjs']
119127
};
120128

121129
const cb: Callback = (err, data) => {
@@ -138,7 +146,9 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
138146
const _package: VerdaccioGitlabPackageAccess = {
139147
name: '@myGroup/myPackage',
140148
access: ['$authenticated'],
141-
gitlab: true
149+
gitlab: true,
150+
publish: ['$authenticated'],
151+
proxy: ['npmjs']
142152
};
143153

144154
const cb: Callback = (err, data) => {
@@ -154,7 +164,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
154164
const verdaccioGitlab: VerdaccioGitlab = new VerdaccioGitlab(config.verdaccioGitlabConfig, config.options);
155165
const _package: VerdaccioGitlabPackageAccess = {
156166
name: '@myGroup/myPackage',
157-
gitlab: true
167+
access: ['$all'],
168+
gitlab: true,
169+
publish: ['$authenticated'],
170+
proxy: ['npmjs']
158171
};
159172

160173
const cb: Callback = (err, data) => {
@@ -170,7 +183,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
170183
const verdaccioGitlab: VerdaccioGitlab = new VerdaccioGitlab(config.verdaccioGitlabConfig, config.options);
171184
const _package: VerdaccioGitlabPackageAccess = {
172185
name: '@anotherGroup/myProject',
173-
gitlab: true
186+
access: ['$all'],
187+
gitlab: true,
188+
publish: ['$authenticated'],
189+
proxy: ['npmjs']
174190
};
175191

176192
const cb: Callback = (err, data) => {
@@ -186,7 +202,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
186202
const verdaccioGitlab: VerdaccioGitlab = new VerdaccioGitlab(config.verdaccioGitlabConfig, config.options);
187203
const _package: VerdaccioGitlabPackageAccess = {
188204
name: config.user,
189-
gitlab: true
205+
access: ['$all'],
206+
gitlab: true,
207+
publish: ['$authenticated'],
208+
proxy: ['npmjs']
190209
};
191210

192211
const cb: Callback = (err, data) => {
@@ -207,7 +226,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
207226
};
208227
const _package: VerdaccioGitlabPackageAccess = {
209228
name: config.user,
210-
gitlab: true
229+
access: ['$all'],
230+
gitlab: true,
231+
publish: ['$authenticated'],
232+
proxy: ['npmjs']
211233
};
212234

213235
const cb: Callback = (err, data) => {
@@ -223,7 +245,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
223245
const verdaccioGitlab: VerdaccioGitlab = new VerdaccioGitlab(config.verdaccioGitlabConfig, config.options);
224246
const _package: VerdaccioGitlabPackageAccess = {
225247
name: '@anotherGroup/myPackage',
226-
gitlab: true
248+
access: ['$all'],
249+
gitlab: true,
250+
publish: ['$authenticated'],
251+
proxy: ['npmjs']
227252
};
228253

229254
const cb: Callback = (err, data) => {
@@ -239,7 +264,10 @@ describe('Gitlab Auth Plugin Unit Tests', () => {
239264
const verdaccioGitlab: VerdaccioGitlab = new VerdaccioGitlab(config.verdaccioGitlabConfig, config.options);
240265
const _package: VerdaccioGitlabPackageAccess = {
241266
name: 'anotherUser',
242-
gitlab: true
267+
access: ['$all'],
268+
gitlab: true,
269+
publish: ['$authenticated'],
270+
proxy: ['npmjs']
243271
};
244272

245273
const cb: Callback = (err, data) => {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@
350350
resolved "https://registry.yarnpkg.com/@verdaccio/streams/-/streams-2.0.0-beta.0.tgz#af8c7e673a3c368deacc8024c6f5671aa2ec32ac"
351351
integrity sha512-EdVF6RP0abRNT0RfgLCsqLNv7FOpm+BpzMZoaQuQGHSBQRj7OTM8ft5mpbJ40rYVXKv6D8xyU0vUnoRl09ah6g==
352352

353-
"@verdaccio/types@3.5.1":
354-
version "3.5.1"
355-
resolved "https://registry.yarnpkg.com/@verdaccio/types/-/types-3.5.1.tgz#1ddfb6e4d12680e6689e1fb189e25377f9e606a6"
356-
integrity sha512-qxqki7geilVfhk2Q5iIeWNrjr1d4EDzyoGeJortgex6kgIB2NTccXn7IrIk4dF7Gkt+0qpTzU5dd6hSbgAVKgw==
353+
"@verdaccio/types@^4.1.5":
354+
version "4.3.0"
355+
resolved "https://registry.yarnpkg.com/@verdaccio/types/-/types-4.3.0.tgz#e881ade5b4b0648ec72e81b23685f405fd07332e"
356+
integrity sha512-SXuN07exu315Q5nPduGWMZxkwAHL23skCEolmigvEWOOpcuaoJ59IrS/Jn7PrYFjbR3O1vcGWt4gJ6MjPRucoQ==
357357

358358
"@verdaccio/[email protected]":
359359
version "0.1.11"

0 commit comments

Comments
 (0)