0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-06 22:40:26 -05:00

feat: upgrade plugin htpassw major (#3712)

Replaces default auth plugin verdaccio-htpasswd@10.x by verdaccio-htpasswd@11.x which is being used in verdaccio 6.x (almost identical)
Apply backward compabiity
Reduces maintenance (monorepo plugin can be removed)
One more step to switch v6.x
Add Node.js 12 GH Action for check backward compatibility
This commit is contained in:
Juan Picado 2023-04-22 11:08:59 +02:00 committed by GitHub
parent b3ea8162ac
commit e939ca24af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 378 additions and 110 deletions

View file

@ -14,10 +14,10 @@ jobs:
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: 'Use Node.js 12.x' - name: 'Use Node.js 16.x'
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with: with:
node-version: 12.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn install run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
@ -30,7 +30,7 @@ jobs:
run: | run: |
source scripts/e2e-setup-ci.sh source scripts/e2e-setup-ci.sh
yarn init --yes yarn init --yes
yarn add jest@26.0.0 --registry http://localhost:4873 yarn add jest@29.5.0 --registry http://localhost:4873
echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js
yarn jest pass.test.js yarn jest pass.test.js
@ -45,10 +45,10 @@ jobs:
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: 'Use Node.js 12.x' - name: 'Use Node.js 16.x'
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with: with:
node-version: 12.x node-version: 16.x
- name: Install Dependencies - name: Install Dependencies
run: yarn install run: yarn install
- name: 'Run verdaccio in the background' - name: 'Run verdaccio in the background'
@ -64,7 +64,7 @@ jobs:
yarn set version berry yarn set version berry
yarn config set npmRegistryServer "http://localhost:4873" yarn config set npmRegistryServer "http://localhost:4873"
yarn config set unsafeHttpWhitelist --json '["localhost"]' yarn config set unsafeHttpWhitelist --json '["localhost"]'
yarn add jest@26.0.0 yarn add jest@29.5.0
echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js
yarn jest pass.test.js yarn jest pass.test.js
@ -79,10 +79,10 @@ jobs:
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: 'Use Node.js 12.x' - name: 'Use Node.js 16.x'
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with: with:
node-version: 12.x node-version: 16.x
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm@latest-6 run: npm i -g npm@latest-6
- name: Install Dependencies - name: Install Dependencies
@ -97,7 +97,7 @@ jobs:
run: | run: |
source scripts/e2e-setup-ci.sh source scripts/e2e-setup-ci.sh
npm init --force npm init --force
npm install jest@26.0.0 --registry http://localhost:4873 npm install jest@29.5.0 --registry http://localhost:4873
echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js
yarn jest pass.test.js yarn jest pass.test.js
@ -112,10 +112,10 @@ jobs:
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: 'Use Node.js 12.x' - name: 'Use Node.js 16.x'
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with: with:
node-version: 12.x node-version: 16.x
- name: 'install latest npm' - name: 'install latest npm'
run: npm i -g npm@next-8 run: npm i -g npm@next-8
- name: Install Dependencies - name: Install Dependencies
@ -130,7 +130,7 @@ jobs:
run: | run: |
source scripts/e2e-setup-ci.sh source scripts/e2e-setup-ci.sh
npm init --force npm init --force
npm install jest@26.0.0 --registry http://localhost:4873 npm install jest@29.5.0 --registry http://localhost:4873
echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js
yarn jest pass.test.js yarn jest pass.test.js
@ -179,10 +179,10 @@ jobs:
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: 'Use Node.js 12.x' - name: 'Use Node.js 16.x'
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with: with:
node-version: 12.x node-version: 16.x
- name: 'install latest pnpm' - name: 'install latest pnpm'
run: npm i -g pnpm@latest-6 run: npm i -g pnpm@latest-6
- name: Install Dependencies - name: Install Dependencies
@ -197,7 +197,7 @@ jobs:
run: | run: |
source scripts/e2e-setup-ci.sh source scripts/e2e-setup-ci.sh
pnpm init --force pnpm init --force
pnpm install jest@26.0.0 --registry http://localhost:4873 pnpm install jest@29.5.0 --registry http://localhost:4873
echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js
yarn jest pass.test.js yarn jest pass.test.js
@ -212,7 +212,7 @@ jobs:
steps: steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: 'Use Node.js 12.x' - name: 'Use Node.js 16.x'
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1 uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with: with:
node-version: 16.x node-version: 16.x
@ -230,7 +230,7 @@ jobs:
run: | run: |
source scripts/e2e-setup-ci.sh source scripts/e2e-setup-ci.sh
pnpm init pnpm init
pnpm install jest@26.0.0 --registry http://localhost:4873 pnpm install jest@29.5.0 --registry http://localhost:4873
echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js echo "it('should pass', () => { expect(true).toBeTruthy(); });" | tee pass.test.js
yarn jest pass.test.js yarn jest pass.test.js

View file

@ -0,0 +1,41 @@
name: Module Smoke Test Node.js 12
on:
workflow_dispatch:
pull_request:
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2
- name: Use Node (latest)
uses: actions/setup-node@1f8c6b94b26d0feae1e387ca63ccbdc44d27b561 # tag=v2.5.1
with:
node-version: 12
- name: Docker test
run: |
docker run -d -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio:5
- name: login
run: npx npm-cli-login -u test -p 1234 -e test@domain.test -r http://localhost:4873
- name: Build
run: yarn build
- name: Types
run: yarn code:types
- name: Bump up package
run: npm version prerelease --no-git-tag-version --preid $(date +%s%N)
- name: publish verdaccio
run: npm publish --registry http://localhost:4873
- name: install verdaccio
run: npm i -g verdaccio --loglevel info --registry http://localhost:4873
- name: verdaccio version
run: verdaccio --version
- name: 'Running the integration test'
run: |
source scripts/e2e-setup-ci.sh
npm init --force
npm install jest@27.5.1 --registry http://localhost:4873
npm install verdaccio --registry http://localhost:4873
echo "test('require module should works', () => { const {runServer} = require('verdaccio') });" | tee module.spec.js
cat module.spec.js
yarn jest

View file

@ -2,7 +2,6 @@ name: Module Smoke Test 5.x
on: on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
push:
permissions: permissions:
contents: read contents: read
jobs: jobs:

158
.pnp.cjs generated
View file

@ -68,18 +68,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\ ["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\
["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\ ["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\
["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\ ["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\ ["@verdaccio/config", "npm:6.0.0-6-next.68"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/local-storage", "npm:10.3.3"],\ ["@verdaccio/local-storage", "npm:10.3.3"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.12"],\ ["@verdaccio/logger-7", "npm:6.0.0-6-next.13"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.46"],\ ["@verdaccio/middleware", "npm:6.0.0-6-next.47"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\ ["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.1"],\ ["@verdaccio/streams", "npm:10.2.1"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.36"],\ ["@verdaccio/tarball", "npm:11.0.0-6-next.37"],\
["@verdaccio/types", "npm:11.0.0-6-next.25"],\ ["@verdaccio/types", "npm:11.0.0-6-next.25"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.67"],\ ["@verdaccio/ui-theme", "npm:6.0.0-6-next.68"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\ ["@verdaccio/url", "npm:11.0.0-6-next.34"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\ ["@verdaccio/utils", "npm:6.0.0-6-next.36"],\
["JSONStream", "npm:1.3.5"],\ ["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\ ["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\ ["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -137,9 +137,9 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\ ["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=23ec76"],\ ["typescript", "patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=23ec76"],\
["validator", "npm:13.9.0"],\ ["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.30"],\ ["verdaccio-audit", "npm:11.0.0-6-next.31"],\
["verdaccio-auth-memory", "npm:10.2.2"],\ ["verdaccio-auth-memory", "npm:10.2.2"],\
["verdaccio-htpasswd", "npm:10.5.5"],\ ["verdaccio-htpasswd", "npm:11.0.0-6-next.38"],\
["verdaccio-memory", "npm:10.3.2"]\ ["verdaccio-memory", "npm:10.3.2"]\
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
@ -5120,12 +5120,12 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/config", [\ ["@verdaccio/config", [\
["npm:6.0.0-6-next.67", {\ ["npm:6.0.0-6-next.68", {\
"packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.67-6558a1c7e5-822fd5d63d.zip/node_modules/@verdaccio/config/",\ "packageLocation": "./.yarn/cache/@verdaccio-config-npm-6.0.0-6-next.68-7334112725-aa527a6f4a.zip/node_modules/@verdaccio/config/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\ ["@verdaccio/config", "npm:6.0.0-6-next.68"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\ ["@verdaccio/utils", "npm:6.0.0-6-next.36"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\ ["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["js-yaml", "npm:4.1.0"],\ ["js-yaml", "npm:4.1.0"],\
["lodash", "npm:4.17.21"],\ ["lodash", "npm:4.17.21"],\
@ -5136,10 +5136,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/core", [\ ["@verdaccio/core", [\
["npm:6.0.0-6-next.67", {\ ["npm:6.0.0-6-next.68", {\
"packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.67-982000a47a-c039318870.zip/node_modules/@verdaccio/core/",\ "packageLocation": "./.yarn/cache/@verdaccio-core-npm-6.0.0-6-next.68-f3485a7c2a-cbc581d047.zip/node_modules/@verdaccio/core/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["ajv", "npm:8.11.2"],\ ["ajv", "npm:8.11.2"],\
["core-js", "npm:3.28.0"],\ ["core-js", "npm:3.28.0"],\
["http-errors", "npm:1.8.1"],\ ["http-errors", "npm:1.8.1"],\
@ -5158,6 +5158,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["lockfile", "npm:1.0.4"]\ ["lockfile", "npm:1.0.4"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\
["npm:11.0.0-6-next.7", {\
"packageLocation": "./.yarn/cache/@verdaccio-file-locking-npm-11.0.0-6-next.7-b6bd1d57fa-86cf13ab75.zip/node_modules/@verdaccio/file-locking/",\
"packageDependencies": [\
["@verdaccio/file-locking", "npm:11.0.0-6-next.7"],\
["lockfile", "npm:1.0.4"]\
],\
"linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@verdaccio/local-storage", [\ ["@verdaccio/local-storage", [\
@ -5178,22 +5186,22 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/logger-7", [\ ["@verdaccio/logger-7", [\
["npm:6.0.0-6-next.12", {\ ["npm:6.0.0-6-next.13", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.12-1a78df2245-3585b19083.zip/node_modules/@verdaccio/logger-7/",\ "packageLocation": "./.yarn/cache/@verdaccio-logger-7-npm-6.0.0-6-next.13-f831a911ae-718cb0b289.zip/node_modules/@verdaccio/logger-7/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/logger-7", "npm:6.0.0-6-next.12"],\ ["@verdaccio/logger-7", "npm:6.0.0-6-next.13"],\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.35"],\ ["@verdaccio/logger-commons", "npm:6.0.0-6-next.36"],\
["pino", "npm:7.11.0"]\ ["pino", "npm:7.11.0"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@verdaccio/logger-commons", [\ ["@verdaccio/logger-commons", [\
["npm:6.0.0-6-next.35", {\ ["npm:6.0.0-6-next.36", {\
"packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.35-a2c2cd0eaf-1726111f2b.zip/node_modules/@verdaccio/logger-commons/",\ "packageLocation": "./.yarn/cache/@verdaccio-logger-commons-npm-6.0.0-6-next.36-b211171bd3-85947d9598.zip/node_modules/@verdaccio/logger-commons/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/logger-commons", "npm:6.0.0-6-next.35"],\ ["@verdaccio/logger-commons", "npm:6.0.0-6-next.36"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/logger-prettify", "npm:6.0.0-6-next.9"],\ ["@verdaccio/logger-prettify", "npm:6.0.0-6-next.9"],\
["colorette", "npm:2.0.19"],\ ["colorette", "npm:2.0.19"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"]\ ["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"]\
@ -5216,14 +5224,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/middleware", [\ ["@verdaccio/middleware", [\
["npm:6.0.0-6-next.46", {\ ["npm:6.0.0-6-next.47", {\
"packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.46-18be481d80-a53154f3b5.zip/node_modules/@verdaccio/middleware/",\ "packageLocation": "./.yarn/cache/@verdaccio-middleware-npm-6.0.0-6-next.47-767adadf8b-a14a997ef3.zip/node_modules/@verdaccio/middleware/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/middleware", "npm:6.0.0-6-next.46"],\ ["@verdaccio/middleware", "npm:6.0.0-6-next.47"],\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\ ["@verdaccio/config", "npm:6.0.0-6-next.68"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\ ["@verdaccio/url", "npm:11.0.0-6-next.34"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\ ["@verdaccio/utils", "npm:6.0.0-6-next.36"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\ ["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["express", "npm:4.18.2"],\ ["express", "npm:4.18.2"],\
["express-rate-limit", "npm:5.5.1"],\ ["express-rate-limit", "npm:5.5.1"],\
@ -5256,13 +5264,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/tarball", [\ ["@verdaccio/tarball", [\
["npm:11.0.0-6-next.36", {\ ["npm:11.0.0-6-next.37", {\
"packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.36-06d2d9ff39-857d74fbb1.zip/node_modules/@verdaccio/tarball/",\ "packageLocation": "./.yarn/cache/@verdaccio-tarball-npm-11.0.0-6-next.37-dc849ead2d-c400432a17.zip/node_modules/@verdaccio/tarball/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/tarball", "npm:11.0.0-6-next.36"],\ ["@verdaccio/tarball", "npm:11.0.0-6-next.37"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\ ["@verdaccio/url", "npm:11.0.0-6-next.34"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\ ["@verdaccio/utils", "npm:6.0.0-6-next.36"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\ ["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"]\ ["lodash", "npm:4.17.21"]\
],\ ],\
@ -5279,20 +5287,20 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/ui-theme", [\ ["@verdaccio/ui-theme", [\
["npm:6.0.0-6-next.67", {\ ["npm:6.0.0-6-next.68", {\
"packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.67-b1aee354b9-5e6a8deca7.zip/node_modules/@verdaccio/ui-theme/",\ "packageLocation": "./.yarn/cache/@verdaccio-ui-theme-npm-6.0.0-6-next.68-99120e3a98-1f8f361cf7.zip/node_modules/@verdaccio/ui-theme/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.67"]\ ["@verdaccio/ui-theme", "npm:6.0.0-6-next.68"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
]],\ ]],\
["@verdaccio/url", [\ ["@verdaccio/url", [\
["npm:11.0.0-6-next.33", {\ ["npm:11.0.0-6-next.34", {\
"packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.33-64ed74304b-e138638e0f.zip/node_modules/@verdaccio/url/",\ "packageLocation": "./.yarn/cache/@verdaccio-url-npm-11.0.0-6-next.34-003548794d-63adf681d8.zip/node_modules/@verdaccio/url/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\ ["@verdaccio/url", "npm:11.0.0-6-next.34"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\ ["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["lodash", "npm:4.17.21"],\ ["lodash", "npm:4.17.21"],\
["validator", "npm:13.9.0"]\ ["validator", "npm:13.9.0"]\
@ -5301,11 +5309,11 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["@verdaccio/utils", [\ ["@verdaccio/utils", [\
["npm:6.0.0-6-next.35", {\ ["npm:6.0.0-6-next.36", {\
"packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.35-5c76e3b578-97f04effaf.zip/node_modules/@verdaccio/utils/",\ "packageLocation": "./.yarn/cache/@verdaccio-utils-npm-6.0.0-6-next.36-931feacba5-d6dbd7b476.zip/node_modules/@verdaccio/utils/",\
"packageDependencies": [\ "packageDependencies": [\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\ ["@verdaccio/utils", "npm:6.0.0-6-next.36"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["lodash", "npm:4.17.21"],\ ["lodash", "npm:4.17.21"],\
["minimatch", "npm:3.1.2"],\ ["minimatch", "npm:3.1.2"],\
["semver", "npm:7.3.8"]\ ["semver", "npm:7.3.8"]\
@ -11301,10 +11309,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}],\ }],\
["virtual:2c0413d013d95d792b4734fb5ba2b862c449db8f59693f269cdf9e3bf579fb5c5441b1fba98d8e06ba2937e2a5a71c997d9ebf245147018bc6b0d9897ab45083#npm:2.6.7", {\ ["virtual:5b1ec82c597946a9cab5ff6462dd0319f4bddb816fb07702ea903ea5c4f6162c956ee44edcb7dd9eaa765aae33b49fd5eca0a4dfc2b9d28782e9e3491afbc9e7#npm:2.6.7", {\
"packageLocation": "./.yarn/__virtual__/node-fetch-virtual-c70b7cc8e9/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\ "packageLocation": "./.yarn/__virtual__/node-fetch-virtual-74c984840a/0/cache/node-fetch-npm-2.6.7-777aa2a6df-8d816ffd1e.zip/node_modules/node-fetch/",\
"packageDependencies": [\ "packageDependencies": [\
["node-fetch", "virtual:2c0413d013d95d792b4734fb5ba2b862c449db8f59693f269cdf9e3bf579fb5c5441b1fba98d8e06ba2937e2a5a71c997d9ebf245147018bc6b0d9897ab45083#npm:2.6.7"],\ ["node-fetch", "virtual:5b1ec82c597946a9cab5ff6462dd0319f4bddb816fb07702ea903ea5c4f6162c956ee44edcb7dd9eaa765aae33b49fd5eca0a4dfc2b9d28782e9e3491afbc9e7#npm:2.6.7"],\
["@types/encoding", null],\ ["@types/encoding", null],\
["encoding", null],\ ["encoding", null],\
["whatwg-url", "npm:5.0.0"]\ ["whatwg-url", "npm:5.0.0"]\
@ -13989,18 +13997,18 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\ ["@typescript-eslint/eslint-plugin", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\
["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\ ["@typescript-eslint/parser", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:5.59.0"],\
["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\ ["@verdaccio-scope/verdaccio-auth-foo", "npm:0.0.2"],\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\ ["@verdaccio/config", "npm:6.0.0-6-next.68"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/local-storage", "npm:10.3.3"],\ ["@verdaccio/local-storage", "npm:10.3.3"],\
["@verdaccio/logger-7", "npm:6.0.0-6-next.12"],\ ["@verdaccio/logger-7", "npm:6.0.0-6-next.13"],\
["@verdaccio/middleware", "npm:6.0.0-6-next.46"],\ ["@verdaccio/middleware", "npm:6.0.0-6-next.47"],\
["@verdaccio/signature", "npm:6.0.0-6-next.2"],\ ["@verdaccio/signature", "npm:6.0.0-6-next.2"],\
["@verdaccio/streams", "npm:10.2.1"],\ ["@verdaccio/streams", "npm:10.2.1"],\
["@verdaccio/tarball", "npm:11.0.0-6-next.36"],\ ["@verdaccio/tarball", "npm:11.0.0-6-next.37"],\
["@verdaccio/types", "npm:11.0.0-6-next.25"],\ ["@verdaccio/types", "npm:11.0.0-6-next.25"],\
["@verdaccio/ui-theme", "npm:6.0.0-6-next.67"],\ ["@verdaccio/ui-theme", "npm:6.0.0-6-next.68"],\
["@verdaccio/url", "npm:11.0.0-6-next.33"],\ ["@verdaccio/url", "npm:11.0.0-6-next.34"],\
["@verdaccio/utils", "npm:6.0.0-6-next.35"],\ ["@verdaccio/utils", "npm:6.0.0-6-next.36"],\
["JSONStream", "npm:1.3.5"],\ ["JSONStream", "npm:1.3.5"],\
["async", "npm:3.2.4"],\ ["async", "npm:3.2.4"],\
["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\ ["babel-eslint", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.1.0"],\
@ -14058,24 +14066,24 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\ ["ts-node", "virtual:7f7b3df50ee4b7b1719ad19fad11505dc2788f3227a7e5cc9ca19f71d8cb309c9d33b532ea2b2b60ab65abf6cc12153df4643c5e6e17d01ea0ae0492723bb4b4#npm:10.9.1"],\
["typescript", "patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=23ec76"],\ ["typescript", "patch:typescript@npm%3A4.9.5#~builtin<compat/typescript>::version=4.9.5&hash=23ec76"],\
["validator", "npm:13.9.0"],\ ["validator", "npm:13.9.0"],\
["verdaccio-audit", "npm:11.0.0-6-next.30"],\ ["verdaccio-audit", "npm:11.0.0-6-next.31"],\
["verdaccio-auth-memory", "npm:10.2.2"],\ ["verdaccio-auth-memory", "npm:10.2.2"],\
["verdaccio-htpasswd", "npm:10.5.5"],\ ["verdaccio-htpasswd", "npm:11.0.0-6-next.38"],\
["verdaccio-memory", "npm:10.3.2"]\ ["verdaccio-memory", "npm:10.3.2"]\
],\ ],\
"linkType": "SOFT"\ "linkType": "SOFT"\
}]\ }]\
]],\ ]],\
["verdaccio-audit", [\ ["verdaccio-audit", [\
["npm:11.0.0-6-next.30", {\ ["npm:11.0.0-6-next.31", {\
"packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.30-2c0413d013-3cfd734653.zip/node_modules/verdaccio-audit/",\ "packageLocation": "./.yarn/cache/verdaccio-audit-npm-11.0.0-6-next.31-5b1ec82c59-f5a2afb2ba.zip/node_modules/verdaccio-audit/",\
"packageDependencies": [\ "packageDependencies": [\
["verdaccio-audit", "npm:11.0.0-6-next.30"],\ ["verdaccio-audit", "npm:11.0.0-6-next.31"],\
["@verdaccio/config", "npm:6.0.0-6-next.67"],\ ["@verdaccio/config", "npm:6.0.0-6-next.68"],\
["@verdaccio/core", "npm:6.0.0-6-next.67"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["express", "npm:4.18.2"],\ ["express", "npm:4.18.2"],\
["https-proxy-agent", "npm:5.0.1"],\ ["https-proxy-agent", "npm:5.0.1"],\
["node-fetch", "virtual:2c0413d013d95d792b4734fb5ba2b862c449db8f59693f269cdf9e3bf579fb5c5441b1fba98d8e06ba2937e2a5a71c997d9ebf245147018bc6b0d9897ab45083#npm:2.6.7"]\ ["node-fetch", "virtual:5b1ec82c597946a9cab5ff6462dd0319f4bddb816fb07702ea903ea5c4f6162c956ee44edcb7dd9eaa765aae33b49fd5eca0a4dfc2b9d28782e9e3491afbc9e7#npm:2.6.7"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\
}]\ }]\
@ -14091,15 +14099,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\ }]\
]],\ ]],\
["verdaccio-htpasswd", [\ ["verdaccio-htpasswd", [\
["npm:10.5.5", {\ ["npm:11.0.0-6-next.38", {\
"packageLocation": "./.yarn/cache/verdaccio-htpasswd-npm-10.5.5-51ff9070b2-1a5706af72.zip/node_modules/verdaccio-htpasswd/",\ "packageLocation": "./.yarn/cache/verdaccio-htpasswd-npm-11.0.0-6-next.38-5ceb09d742-eb633f15ad.zip/node_modules/verdaccio-htpasswd/",\
"packageDependencies": [\ "packageDependencies": [\
["verdaccio-htpasswd", "npm:10.5.5"],\ ["verdaccio-htpasswd", "npm:11.0.0-6-next.38"],\
["@verdaccio/file-locking", "npm:10.3.1"],\ ["@verdaccio/core", "npm:6.0.0-6-next.68"],\
["@verdaccio/file-locking", "npm:11.0.0-6-next.7"],\
["apache-md5", "npm:1.1.8"],\ ["apache-md5", "npm:1.1.8"],\
["bcryptjs", "npm:2.4.3"],\ ["bcryptjs", "npm:2.4.3"],\
["core-js", "npm:3.28.0"],\
["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\ ["debug", "virtual:29474417206615456729b7a578bf418b358d5457cdcef4bbfee11068b4718e28ceca45b525022e3820e15bd79419301ec7f358c2f28eae1e78ba4bae24d15383#npm:4.3.4"],\
["http-errors", "npm:2.0.0"],\ ["http-errors", "npm:1.8.1"],\
["unix-crypt-td-js", "npm:1.1.4"]\ ["unix-crypt-td-js", "npm:1.1.4"]\
],\ ],\
"linkType": "HARD"\ "linkType": "HARD"\

View file

@ -19,17 +19,17 @@
"url": "https://opencollective.com/verdaccio" "url": "https://opencollective.com/verdaccio"
}, },
"dependencies": { "dependencies": {
"@verdaccio/config": "6.0.0-6-next.67", "@verdaccio/config": "6.0.0-6-next.68",
"@verdaccio/core": "6.0.0-6-next.67", "@verdaccio/core": "6.0.0-6-next.68",
"@verdaccio/local-storage": "10.3.3", "@verdaccio/local-storage": "10.3.3",
"@verdaccio/logger-7": "6.0.0-6-next.12", "@verdaccio/logger-7": "6.0.0-6-next.13",
"@verdaccio/middleware": "6.0.0-6-next.46", "@verdaccio/middleware": "6.0.0-6-next.47",
"@verdaccio/signature": "6.0.0-6-next.2", "@verdaccio/signature": "6.0.0-6-next.2",
"@verdaccio/streams": "10.2.1", "@verdaccio/streams": "10.2.1",
"@verdaccio/tarball": "11.0.0-6-next.36", "@verdaccio/tarball": "11.0.0-6-next.37",
"@verdaccio/ui-theme": "6.0.0-6-next.67", "@verdaccio/ui-theme": "6.0.0-6-next.68",
"@verdaccio/url": "11.0.0-6-next.33", "@verdaccio/url": "11.0.0-6-next.34",
"@verdaccio/utils": "6.0.0-6-next.35", "@verdaccio/utils": "6.0.0-6-next.36",
"JSONStream": "1.3.5", "JSONStream": "1.3.5",
"async": "3.2.4", "async": "3.2.4",
"body-parser": "1.20.2", "body-parser": "1.20.2",
@ -56,8 +56,8 @@
"request": "2.88.2", "request": "2.88.2",
"semver": "7.5.0", "semver": "7.5.0",
"validator": "13.9.0", "validator": "13.9.0",
"verdaccio-audit": "11.0.0-6-next.30", "verdaccio-audit": "11.0.0-6-next.31",
"verdaccio-htpasswd": "10.5.5" "verdaccio-htpasswd": "11.0.0-6-next.38"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "7.21.0", "@babel/cli": "7.21.0",

View file

@ -30,4 +30,4 @@ middlewares:
audit: audit:
enabled: true enabled: true
logs: { type: stdout, format: json, level: warn } log: { type: stdout, format: json, level: warn }

View file

@ -55,9 +55,23 @@ class Auth {
logger: this.logger, logger: this.logger,
}; };
let authConf = { ...config.auth };
if (authConf?.htpasswd) {
// special case for htpasswd plugin, the v6 version uses bcrypt by default
// 5.x enforces crypt to avoid breaking changes, but is highly recommended using
// bcrypt instead.
if (!authConf.htpasswd.algorithm) {
authConf.htpasswd.algorithm = 'crypt';
this.logger.info(
// eslint-disable-next-line max-len
'the "crypt" algorithm is deprecated consider switch to "bcrypt" in the configuration file. Read the documentation for additional details'
);
}
}
return loadPlugin<pluginUtils.Auth<Config>>( return loadPlugin<pluginUtils.Auth<Config>>(
config, config,
config.auth, authConf,
pluginOptions, pluginOptions,
(plugin: pluginUtils.Auth<Config>): boolean => { (plugin: pluginUtils.Auth<Config>): boolean => {
const { authenticate, allow_access, allow_publish } = plugin; const { authenticate, allow_access, allow_publish } = plugin;

View file

@ -363,7 +363,7 @@ class ProxyStorage {
private _setHeaderAuthorization(headers: any, type: string, token: any): void { private _setHeaderAuthorization(headers: any, type: string, token: any): void {
const _type: string = type.toLowerCase(); const _type: string = type.toLowerCase();
if (_type !== TOKEN_BEARER.toLowerCase() && _type !== TOKEN_BASIC.toLowerCase()) { if ([TOKEN_BEARER.toLowerCase(), TOKEN_BASIC.toLowerCase()].includes(_type) === false) {
this._throwErrorAuth(`Auth type '${_type}' not allowed`); this._throwErrorAuth(`Auth type '${_type}' not allowed`);
} }

View file

@ -25,6 +25,7 @@ export async function initializeServer(
// to avoid conflics // to avoid conflics
// FUTURE: self_path is configPath in v6 // FUTURE: self_path is configPath in v6
config.self_path = config.storage; config.self_path = config.storage;
config.configPath = config.storage;
debug('storage: %s', config.storage); debug('storage: %s', config.storage);
const storage = new Storage(config); const storage = new Storage(config);
await storage.init(config, []); await storage.init(config, []);

View file

@ -1,3 +1,4 @@
import nock from 'nock';
import supertest from 'supertest'; import supertest from 'supertest';
import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '@verdaccio/core'; import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS, TOKEN_BEARER } from '@verdaccio/core';
@ -10,9 +11,14 @@ const FORBIDDEN_VUE = 'authorization required to access package vue';
jest.setTimeout(20000); jest.setTimeout(20000);
describe('token', () => { describe('token', () => {
beforeEach(() => {
nock.cleanAll();
});
describe('basics', () => { describe('basics', () => {
const FAKE_TOKEN: string = buildToken(TOKEN_BEARER, 'fake'); const FAKE_TOKEN: string = buildToken(TOKEN_BEARER, 'fake');
test.each([['user.yaml'], ['user.jwt.yaml']])('should test add a new user', async (conf) => { test.each([['user.yaml'], ['user.jwt.yaml']])('should test add a new user', async (conf) => {
nock('https://registry.verdaccio.org/').get(`/vue`).once().reply(200, { name: 'vue' });
const app = await initializeServer(conf); const app = await initializeServer(conf);
const credentials = { name: 'JotaJWT', password: 'secretPass' }; const credentials = { name: 'JotaJWT', password: 'secretPass' };
const response = await createUser(app, credentials.name, credentials.password); const response = await createUser(app, credentials.name, credentials.password);

View file

@ -1,9 +1,16 @@
import _ from 'lodash'; import _ from 'lodash';
import nock from 'nock';
import { Config, UpLinkConf } from '@verdaccio/types'; import { Config, UpLinkConf } from '@verdaccio/types';
import AppConfig from '../../../../src/lib/config'; import AppConfig from '../../../../src/lib/config';
import { API_ERROR, HTTP_STATUS } from '../../../../src/lib/constants'; import {
API_ERROR,
ERROR_CODE,
HTTP_STATUS,
TOKEN_BASIC,
TOKEN_BEARER,
} from '../../../../src/lib/constants';
import { setup } from '../../../../src/lib/logger'; import { setup } from '../../../../src/lib/logger';
import ProxyStorage from '../../../../src/lib/up-storage'; import ProxyStorage from '../../../../src/lib/up-storage';
import { DOMAIN_SERVERS } from '../../../functional/config.functional'; import { DOMAIN_SERVERS } from '../../../functional/config.functional';
@ -28,6 +35,10 @@ describe('UpStorage', () => {
mockRegistry = await mockServer(mockServerPort).init(); mockRegistry = await mockServer(mockServerPort).init();
}); });
beforeEach(() => {
nock.cleanAll();
});
afterAll(function (done) { afterAll(function (done) {
mockRegistry[0].stop(); mockRegistry[0].stop();
done(); done();
@ -39,7 +50,19 @@ describe('UpStorage', () => {
expect(proxy).toBeDefined(); expect(proxy).toBeDefined();
}); });
describe('UpStorage::getRemoteMetadata', () => { describe('getRemoteMetadata', () => {
beforeEach(() => {
// @ts-ignore
process.env.TOKEN_TEST_ENV = 'foo';
// @ts-ignore
process.env.NPM_TOKEN = 'foo';
});
afterEach(() => {
delete process.env.TOKEN_TEST_ENV;
delete process.env.NPM_TOKEN;
});
test('should be get remote metadata', (done) => { test('should be get remote metadata', (done) => {
const proxy = generateProxy(); const proxy = generateProxy();
@ -51,6 +74,28 @@ describe('UpStorage', () => {
}); });
}); });
test('should handle 404 on be get remote metadata', (done) => {
nock('http://localhost:55547').get(`/jquery`).once().reply(404, { name: 'jquery' });
const proxy = generateProxy();
proxy.getRemoteMetadata('jquery', {}, (err) => {
expect(err).not.toBeNull();
expect(err.message).toMatch(/package does not exist on uplink/);
done();
});
});
test('should handle 500 on be get remote metadata', (done) => {
nock('http://localhost:55547').get(`/jquery`).once().reply(500, { name: 'jquery' });
const proxy = generateProxy();
proxy.getRemoteMetadata('jquery', {}, (err) => {
expect(err).not.toBeNull();
expect(err.message).toMatch(/bad status code: 500/);
done();
});
});
test('should be get remote metadata with etag', (done) => { test('should be get remote metadata with etag', (done) => {
const proxy = generateProxy(); const proxy = generateProxy();
@ -74,6 +119,7 @@ describe('UpStorage', () => {
}); });
test('should be get remote metadata with json when uplink is npmmirror', (done) => { test('should be get remote metadata with json when uplink is npmmirror', (done) => {
nock('https://registry.npmmirror.com').get(`/jquery`).reply(200, { name: 'jquery' });
const proxy = generateProxy({ url: 'https://registry.npmmirror.com' }); const proxy = generateProxy({ url: 'https://registry.npmmirror.com' });
proxy.getRemoteMetadata('jquery', { json: true }, (err, data) => { proxy.getRemoteMetadata('jquery', { json: true }, (err, data) => {
@ -82,10 +128,161 @@ describe('UpStorage', () => {
done(); done();
}); });
}); });
test('should be get remote metadata with auth header bearer', (done) => {
nock('https://registry.npmmirror.com', {
reqheaders: {
authorization: 'Bearer foo',
},
})
.get(`/jquery`)
.reply(200, { name: 'jquery' });
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BEARER,
token: 'foo',
},
});
proxy.getRemoteMetadata('jquery', {}, (err, data, etag) => {
expect(err).toBeNull();
// expect(_.isString(etag)).toBeTruthy();
expect(data.name).toBe('jquery');
done();
});
});
test('should be get remote metadata with auth node env TOKEN_TEST_ENV header bearer', (done) => {
nock('https://registry.npmmirror.com', {
reqheaders: {
authorization: 'Bearer foo',
},
})
.get(`/jquery`)
.reply(200, { name: 'jquery' });
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BEARER,
token_env: 'TOKEN_TEST_ENV',
},
});
proxy.getRemoteMetadata('jquery', {}, (err, data, etag) => {
expect(err).toBeNull();
expect(data.name).toBe('jquery');
done();
});
});
test('should be get remote metadata with auth node env NPM_TOKEN header bearer', (done) => {
nock('https://registry.npmmirror.com', {
reqheaders: {
authorization: 'Bearer foo',
},
})
.get(`/jquery`)
.reply(200, { name: 'jquery' });
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BEARER,
token_env: true,
},
});
proxy.getRemoteMetadata('jquery', {}, (err, data, etag) => {
expect(err).toBeNull();
expect(data.name).toBe('jquery');
done();
});
});
test('should be get remote metadata with auth header basic', (done) => {
nock('https://registry.npmmirror.com', {
reqheaders: {
authorization: 'Basic foo',
},
})
.get(`/jquery`)
.reply(200, { name: 'jquery' });
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BASIC,
token: 'foo',
},
});
proxy.getRemoteMetadata('jquery', {}, (err, data, etag) => {
expect(err).toBeNull();
// expect(_.isString(etag)).toBeTruthy();
expect(data.name).toBe('jquery');
done();
});
});
}); });
describe('UpStorage::fetchTarball', () => { describe('error handling', () => {
test('should fetch a tarball from uplink', (done) => { test('should fails if auth type is missing', () => {
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BASIC,
token: undefined,
},
});
expect(function () {
proxy.getRemoteMetadata('jquery', {}, () => {});
}).toThrow(/token is required/);
});
test('should fails if token_env is undefined', () => {
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BASIC,
token_env: undefined,
},
});
expect(function () {
proxy.getRemoteMetadata('jquery', {}, () => {});
}).toThrow(ERROR_CODE.token_required);
});
test('should fails if token_env is false', () => {
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
type: TOKEN_BASIC,
token_env: false,
},
});
expect(function () {
proxy.getRemoteMetadata('jquery', {}, () => {});
}).toThrow(ERROR_CODE.token_required);
});
test.skip('should fails if invalid token type', () => {
const proxy = generateProxy({
url: 'https://registry.npmmirror.com',
auth: {
token: 'SomethingWrong',
},
});
expect(function () {
proxy.getRemoteMetadata('jquery', {}, () => {});
}).toThrow(ERROR_CODE.token_required);
});
});
describe('fetchTarball', () => {
test.skip('should fetch a tarball from uplink', (done) => {
const proxy = generateProxy(); const proxy = generateProxy();
const tarball = `http://${DOMAIN_SERVERS}:${mockServerPort}/jquery/-/jquery-1.5.1.tgz`; const tarball = `http://${DOMAIN_SERVERS}:${mockServerPort}/jquery/-/jquery-1.5.1.tgz`;
const stream = proxy.fetchTarball(tarball); const stream = proxy.fetchTarball(tarball);
@ -157,7 +354,7 @@ describe('UpStorage', () => {
}, 10000); }, 10000);
}); });
describe('UpStorage::isUplinkValid', () => { describe('isUplinkValid', () => {
describe('valid use cases', () => { describe('valid use cases', () => {
const validateUpLink = ( const validateUpLink = (
url: string, url: string,

BIN
yarn.lock

Binary file not shown.