From 619544b29400c5e259a2357c8f1c5f460efd4043 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 30 May 2024 12:19:13 +0800 Subject: [PATCH 1/4] fix: force detect unpkg-white-list --- app/core/service/PackageVersionFileService.ts | 11 ++- .../PackageVersionFileController.ts | 1 + .../PackageVersionFileController/raw.test.ts | 78 +++++++++++++++++++ 3 files changed, 88 insertions(+), 2 deletions(-) diff --git a/app/core/service/PackageVersionFileService.ts b/app/core/service/PackageVersionFileService.ts index 5ea40ff7..84e8dd87 100644 --- a/app/core/service/PackageVersionFileService.ts +++ b/app/core/service/PackageVersionFileService.ts @@ -28,6 +28,7 @@ import { PackageManagerService } from './PackageManagerService'; import { CacheAdapter } from '../../common/adapter/CacheAdapter'; const unpkgWhiteListUrl = 'https://github.com/cnpm/unpkg-white-list'; +const CHECK_TIMEOUT = process.env.NODE_ENV === 'test' ? 1 : 60000; @SingletonProto({ accessLevel: AccessLevel.PUBLIC, @@ -46,6 +47,7 @@ export class PackageVersionFileService extends AbstractService { @Inject() private readonly cacheAdapter: CacheAdapter; + #unpkgWhiteListCheckTime: number = 0; #unpkgWhiteListCurrentVersion: string = ''; #unpkgWhiteListAllowPackages: Record assert.equal(res.headers.vary, 'Origin, Accept, Accept-Encoding'); }); + it('should block raw file when package not in white list', async () => { + mock(app.config.cnpmcore, 'allowPublishNonScopePackage', true); + let pkg = await TestUtil.getFullPackage({ + name: 'foo', + version: '1.0.0', + versionObject: { + description: 'work with utf8mb4 ๐Ÿ’ฉ, ๐Œ† utf8_unicode_ci, foo๐Œ†bar ๐Ÿป', + }, + }); + await app.httpRequest() + .put(`/${pkg.name}`) + .set('authorization', publisher.authorization) + .set('user-agent', publisher.ua) + .send(pkg) + .expect(201); + let res = await app.httpRequest() + .get('/foo/1.0.0/files/package.json') + .expect(200) + .expect('content-type', 'application/json; charset=utf-8'); + // console.log(res.body); + assert.equal(res.headers['cache-control'], 'public, max-age=31536000'); + assert.equal(res.headers.vary, 'Origin, Accept, Accept-Encoding'); + assert.deepEqual(res.body, { + name: 'mk2testmodule', + version: '0.0.1', + description: '', + main: 'index.js', + scripts: { test: 'echo "Error: no test specified" && exit 1' }, + author: '', + license: 'ISC', + }); + + mock(app.config.cnpmcore, 'enableSyncUnpkgFilesWhiteList', true); + // should block + res = await app.httpRequest() + .get('/foo/1.0.0/files/package.json') + .expect(403) + .expect('content-type', 'application/json; charset=utf-8'); + assert.equal(res.body.error, + '[FORBIDDEN] "foo" is not allow to unpkg files, see https://github.com/cnpm/unpkg-white-list'); + + // add white list + pkg = await TestUtil.getFullPackage({ + name: 'unpkg-white-list', + version: '2.0.1111', + versionObject: { + description: 'work with utf8mb4 ๐Ÿ’ฉ, ๐Œ† utf8_unicode_ci, foo๐Œ†bar ๐Ÿป', + allowPackages: { + foo: { + version: '*', + }, + }, + }, + }); + await app.httpRequest() + .put(`/${pkg.name}`) + .set('authorization', publisher.authorization) + .set('user-agent', publisher.ua) + .send(pkg) + .expect(201); + res = await app.httpRequest() + .get('/foo/1.0.0/files/package.json') + // .expect(200) + .expect('content-type', 'application/json; charset=utf-8'); + console.log(res.body); + // assert.equal(res.headers['cache-control'], 'public, max-age=31536000'); + // assert.equal(res.headers.vary, 'Origin, Accept, Accept-Encoding'); + assert.deepEqual(res.body, { + name: 'mk2testmodule', + version: '0.0.1', + description: '', + main: 'index.js', + scripts: { test: 'echo "Error: no test specified" && exit 1' }, + author: '', + license: 'ISC', + }); + }); + it('should show one package version file meta', async () => { mock(app.config.cnpmcore, 'allowPublishNonScopePackage', true); const pkg = await TestUtil.getFullPackage({ From bebc32041912f34749473ce43dabfdac40a88fbe Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 30 May 2024 12:38:50 +0800 Subject: [PATCH 2/4] f --- app/repository/TaskRepository.ts | 2 +- app/repository/util/EntityProperty.ts | 2 +- config/config.default.ts | 6 ++--- test/cli/npm/access.test.ts | 3 +-- test/cli/npm/install.test.ts | 4 ++-- test/common/PackageUtil.test.ts | 2 +- test/common/UserUtil.test.ts | 2 +- test/common/adapter/BugVersionStore.test.ts | 2 +- test/common/adapter/CacheAdapter.test.ts | 4 ++-- test/common/adapter/NpmRegistry.test.ts | 2 +- test/common/adapter/binary/ApiBinary.test.ts | 2 +- .../adapter/binary/BucketBinary.test.ts | 2 +- .../binary/ChromeForTestingBinary.test.ts | 2 +- .../adapter/binary/EdgedriverBinary.test.ts | 2 +- .../adapter/binary/ElectronBinary.test.ts | 2 +- .../adapter/binary/GithubBinary.test.ts | 2 +- .../adapter/binary/ImageminBinary.test.ts | 2 +- test/common/adapter/binary/NodeBinary.test.ts | 2 +- .../adapter/binary/NodePreGypBinary.test.ts | 2 +- test/common/adapter/binary/NwjsBinary.test.ts | 2 +- .../adapter/binary/PlaywrightBinary.test.ts | 2 +- .../adapter/binary/PuppeteerBinary.test.ts | 2 +- .../adapter/binary/SqlcipherBinary.test.ts | 2 +- .../CnpmcoreChangesStream.test.ts | 2 +- .../CnpmjsorgChangesStream.test.ts | 2 +- .../changesStream/NpmChangesStream.test.ts | 2 +- test/core/entity/BugVersion.test.ts | 2 +- test/core/entity/PaddingSemver.test.ts | 2 +- test/core/entity/SqlRange.test.ts | 2 +- test/core/event/BugVersionFixHandler.test.ts | 2 +- test/core/event/StoreManifest.test.ts | 2 +- .../BinarySyncerService/createTask.test.ts | 2 +- .../BinarySyncerService/executeTask.test.ts | 2 +- .../cleanBugVersionPackageCache.test.ts | 2 +- .../fixPackageBugVersion.test.ts | 2 +- .../fixPackageBugVersions.test.ts | 2 +- .../core/service/ChangesStreamService.test.ts | 2 +- .../service/CreateHookTriggerService.test.ts | 2 +- .../HookManageService/createHook.test.ts | 2 +- .../HookManageService/deleteHook.test.ts | 2 +- .../getHookByOwnerId.test.ts | 2 +- .../HookManageService/updateHook.test.ts | 2 +- test/core/service/HookTriggerService.test.ts | 2 +- .../PackageManagerService/block.test.ts | 2 +- .../PackageManagerService/publish.test.ts | 2 +- .../PackageSyncerService/createTask.test.ts | 2 +- .../PackageSyncerService/executeTask.test.ts | 2 +- .../findExecuteTask.test.ts | 2 +- .../getTaskRegistry.test.ts | 2 +- .../service/PackageVersionService.test.ts | 2 +- .../RegistryManagerService/index.test.ts | 2 +- .../service/ScopeManagerService/index.test.ts | 2 +- .../TaskService/findExecuteTask.test.ts | 2 +- test/core/util/EntityUtil.test.ts | 2 +- test/infra/QueueAdapter.test.ts | 2 +- .../listCollaborators.test.ts | 2 +- .../listPackagesByUser.test.ts | 2 +- .../BinarySyncController/showBinary.test.ts | 2 +- .../listChanges.test.ts | 2 +- .../showPackageDownloads.test.ts | 2 +- .../controller/HomeController/cors.test.ts | 2 +- .../controller/HomeController/ping.test.ts | 2 +- .../HomeController/showTotal.test.ts | 2 +- .../blockPackage.test.ts | 2 +- .../unblockPackage.test.ts | 2 +- .../createSyncTask.test.ts | 2 +- .../showSyncTask.test.ts | 2 +- .../showSyncTaskLog.test.ts | 2 +- .../PackageTagController/removeTag.test.ts | 2 +- .../PackageTagController/saveTag.test.ts | 2 +- .../PackageTagController/showTags.test.ts | 2 +- .../PackageVersionFileController/raw.test.ts | 23 +++++++++++-------- .../RegistryController/index.test.ts | 2 +- .../controller/ScopeController/index.test.ts | 4 ++-- .../TokenController/createToken.test.ts | 6 ++--- .../TokenController/listTokens.test.ts | 6 ++--- .../TokenController/removeToken.test.ts | 4 ++-- .../UserController/loginOrCreateUser.test.ts | 2 +- .../controller/UserController/logout.test.ts | 2 +- .../UserController/saveProfile.test.ts | 2 +- .../UserController/showProfile.test.ts | 2 +- .../UserController/showUser.test.ts | 2 +- .../UserController/starredByUser.test.ts | 2 +- .../controller/UserController/whoami.test.ts | 4 ++-- .../controller/hook/HookController.test.ts | 2 +- ...ownloadPackageVersionTarController.test.ts | 2 +- .../RemovePackageVersionController.test.ts | 2 +- .../SavePackageVersionController.test.ts | 6 ++--- .../package/SearchPackageController.test.ts | 3 +-- .../package/ShowPackageController.test.ts | 2 +- .../package/UpdatePackageController.test.ts | 4 ++-- test/port/middleware/AlwaysAuth.test.ts | 2 +- test/port/middleware/Tracing.test.ts | 2 +- test/repository/ChangeRepository.test.ts | 2 +- test/repository/PackageRepository.test.ts | 2 +- test/repository/RegistryRepository.test.ts | 2 +- test/repository/ScopeRepository.test.ts | 2 +- test/repository/SearchRepository.test.ts | 2 +- test/repository/TaskRepository.test.ts | 6 ++--- test/schedule/ChangesStreamWorker.test.ts | 2 +- .../CheckRecentlyUpdatedPackages.test.ts | 2 +- test/schedule/SyncPackageWorker.test.ts | 2 +- 102 files changed, 130 insertions(+), 129 deletions(-) diff --git a/app/repository/TaskRepository.ts b/app/repository/TaskRepository.ts index b5db3129..a844ef14 100644 --- a/app/repository/TaskRepository.ts +++ b/app/repository/TaskRepository.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { AccessLevel, SingletonProto, Inject } from '@eggjs/tegg'; import { ModelConvertor } from './util/ModelConvertor'; import type { Task as TaskModel } from './model/Task'; diff --git a/app/repository/util/EntityProperty.ts b/app/repository/util/EntityProperty.ts index 2e208845..ac2f7f76 100644 --- a/app/repository/util/EntityProperty.ts +++ b/app/repository/util/EntityProperty.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { EggProtoImplClass } from '@eggjs/tegg'; import { ModelConvertorUtil } from './ModelConvertorUtil'; diff --git a/config/config.default.ts b/config/config.default.ts index 6ef39cd3..efe42803 100644 --- a/config/config.default.ts +++ b/config/config.default.ts @@ -1,6 +1,6 @@ -import assert from 'assert'; -import { randomUUID } from 'crypto'; -import { join } from 'path'; +import { strict as assert } from 'node:assert'; +import { randomUUID } from 'node:crypto'; +import { join } from 'node:path'; import { EggAppConfig, PowerPartial } from 'egg'; import OSSClient from 'oss-cnpm'; import { patchAjv } from '../app/port/typebox'; diff --git a/test/cli/npm/access.test.ts b/test/cli/npm/access.test.ts index 5c8dcaf4..016601cb 100644 --- a/test/cli/npm/access.test.ts +++ b/test/cli/npm/access.test.ts @@ -1,5 +1,4 @@ -// import assert from 'assert'; -import path from 'path'; +import path from 'node:path'; import { app } from 'egg-mock/bootstrap'; import coffee from 'coffee'; import semver from 'semver'; diff --git a/test/cli/npm/install.test.ts b/test/cli/npm/install.test.ts index 2915139e..45857f72 100644 --- a/test/cli/npm/install.test.ts +++ b/test/cli/npm/install.test.ts @@ -1,5 +1,5 @@ -import assert from 'assert'; -import path from 'path'; +import { strict as assert } from 'node:assert'; +import path from 'node:path'; import { app } from 'egg-mock/bootstrap'; import coffee from 'coffee'; import { TestUtil } from '../../../test/TestUtil'; diff --git a/test/common/PackageUtil.test.ts b/test/common/PackageUtil.test.ts index 32b6e262..6d9b00ab 100644 --- a/test/common/PackageUtil.test.ts +++ b/test/common/PackageUtil.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { formatAuthor, formatTarball, hasShrinkWrapInTgz } from '../../app/common/PackageUtil'; import { TestUtil } from '../TestUtil'; diff --git a/test/common/UserUtil.test.ts b/test/common/UserUtil.test.ts index fa686461..d7f69932 100644 --- a/test/common/UserUtil.test.ts +++ b/test/common/UserUtil.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { randomToken, checkToken } from '../../app/common/UserUtil'; describe('test/common/UserUtil.test.ts', () => { diff --git a/test/common/adapter/BugVersionStore.test.ts b/test/common/adapter/BugVersionStore.test.ts index 8e16f581..09cde263 100644 --- a/test/common/adapter/BugVersionStore.test.ts +++ b/test/common/adapter/BugVersionStore.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { BugVersionStore } from '../../../app/common/adapter/BugVersionStore'; import { BugVersion } from '../../../app/core/entity/BugVersion'; diff --git a/test/common/adapter/CacheAdapter.test.ts b/test/common/adapter/CacheAdapter.test.ts index 5e5798ad..4bbabb48 100644 --- a/test/common/adapter/CacheAdapter.test.ts +++ b/test/common/adapter/CacheAdapter.test.ts @@ -1,5 +1,5 @@ -import assert from 'assert'; -import { setTimeout } from 'timers/promises'; +import { strict as assert } from 'node:assert'; +import { setTimeout } from 'node:timers/promises'; import { app, mock } from 'egg-mock/bootstrap'; import { CacheAdapter } from '../../../app/common/adapter/CacheAdapter'; diff --git a/test/common/adapter/NpmRegistry.test.ts b/test/common/adapter/NpmRegistry.test.ts index 25f8a66e..2477ad1b 100644 --- a/test/common/adapter/NpmRegistry.test.ts +++ b/test/common/adapter/NpmRegistry.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { NPMRegistry } from '../../../app/common/adapter/NPMRegistry'; diff --git a/test/common/adapter/binary/ApiBinary.test.ts b/test/common/adapter/binary/ApiBinary.test.ts index 71f9ce0d..87e32165 100644 --- a/test/common/adapter/binary/ApiBinary.test.ts +++ b/test/common/adapter/binary/ApiBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { ApiBinary } from '../../../../app/common/adapter/binary/ApiBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/BucketBinary.test.ts b/test/common/adapter/binary/BucketBinary.test.ts index 59798dd1..a24de4fe 100644 --- a/test/common/adapter/binary/BucketBinary.test.ts +++ b/test/common/adapter/binary/BucketBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { BucketBinary } from '../../../../app/common/adapter/binary/BucketBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/ChromeForTestingBinary.test.ts b/test/common/adapter/binary/ChromeForTestingBinary.test.ts index acbf619a..94db8d61 100644 --- a/test/common/adapter/binary/ChromeForTestingBinary.test.ts +++ b/test/common/adapter/binary/ChromeForTestingBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ChromeForTestingBinary } from '../../../../app/common/adapter/binary/ChromeForTestingBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/EdgedriverBinary.test.ts b/test/common/adapter/binary/EdgedriverBinary.test.ts index 2a5a11db..33f03bff 100644 --- a/test/common/adapter/binary/EdgedriverBinary.test.ts +++ b/test/common/adapter/binary/EdgedriverBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { EdgedriverBinary } from '../../../../app/common/adapter/binary/EdgedriverBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/ElectronBinary.test.ts b/test/common/adapter/binary/ElectronBinary.test.ts index ef246e7e..036d3f7f 100644 --- a/test/common/adapter/binary/ElectronBinary.test.ts +++ b/test/common/adapter/binary/ElectronBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ElectronBinary } from '../../../../app/common/adapter/binary/ElectronBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/GithubBinary.test.ts b/test/common/adapter/binary/GithubBinary.test.ts index 04238e73..e53c3d5c 100644 --- a/test/common/adapter/binary/GithubBinary.test.ts +++ b/test/common/adapter/binary/GithubBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { GithubBinary } from '../../../../app/common/adapter/binary/GithubBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/ImageminBinary.test.ts b/test/common/adapter/binary/ImageminBinary.test.ts index 67f9043f..389239c4 100644 --- a/test/common/adapter/binary/ImageminBinary.test.ts +++ b/test/common/adapter/binary/ImageminBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ImageminBinary } from '../../../../app/common/adapter/binary/ImageminBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/NodeBinary.test.ts b/test/common/adapter/binary/NodeBinary.test.ts index 4654701b..8b8f0088 100644 --- a/test/common/adapter/binary/NodeBinary.test.ts +++ b/test/common/adapter/binary/NodeBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { NodeBinary } from '../../../../app/common/adapter/binary/NodeBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/NodePreGypBinary.test.ts b/test/common/adapter/binary/NodePreGypBinary.test.ts index 9fad0aa0..861f1a7d 100644 --- a/test/common/adapter/binary/NodePreGypBinary.test.ts +++ b/test/common/adapter/binary/NodePreGypBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { NodePreGypBinary } from '../../../../app/common/adapter/binary/NodePreGypBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/NwjsBinary.test.ts b/test/common/adapter/binary/NwjsBinary.test.ts index c0fabd09..b9b3d0cc 100644 --- a/test/common/adapter/binary/NwjsBinary.test.ts +++ b/test/common/adapter/binary/NwjsBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { NwjsBinary } from '../../../../app/common/adapter/binary/NwjsBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/PlaywrightBinary.test.ts b/test/common/adapter/binary/PlaywrightBinary.test.ts index a7d5c0d8..5d809b3a 100644 --- a/test/common/adapter/binary/PlaywrightBinary.test.ts +++ b/test/common/adapter/binary/PlaywrightBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { PlaywrightBinary } from '../../../../app/common/adapter/binary/PlaywrightBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/PuppeteerBinary.test.ts b/test/common/adapter/binary/PuppeteerBinary.test.ts index 3b1753fd..19a766f6 100644 --- a/test/common/adapter/binary/PuppeteerBinary.test.ts +++ b/test/common/adapter/binary/PuppeteerBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { PuppeteerBinary } from '../../../../app/common/adapter/binary/PuppeteerBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/binary/SqlcipherBinary.test.ts b/test/common/adapter/binary/SqlcipherBinary.test.ts index 1e198a70..e96ca677 100644 --- a/test/common/adapter/binary/SqlcipherBinary.test.ts +++ b/test/common/adapter/binary/SqlcipherBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { SqlcipherBinary } from '../../../../app/common/adapter/binary/SqlcipherBinary'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts b/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts index 0279bf4d..8c70f9f4 100644 --- a/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts +++ b/test/common/adapter/changesStream/CnpmcoreChangesStream.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ChangesStreamChange } from '../../../../app/common/adapter/changesStream/AbstractChangesStream'; import { CnpmcoreChangesStream } from '../../../../app/common/adapter/changesStream/CnpmcoreChangesStream'; diff --git a/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts b/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts index b776f39a..58d6ecaf 100644 --- a/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts +++ b/test/common/adapter/changesStream/CnpmjsorgChangesStream.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ChangesStreamChange } from '../../../../app/common/adapter/changesStream/AbstractChangesStream'; import { CnpmjsorgChangesStream } from '../../../../app/common/adapter/changesStream/CnpmjsorgChangesStream'; diff --git a/test/common/adapter/changesStream/NpmChangesStream.test.ts b/test/common/adapter/changesStream/NpmChangesStream.test.ts index 51536a77..b436ab94 100644 --- a/test/common/adapter/changesStream/NpmChangesStream.test.ts +++ b/test/common/adapter/changesStream/NpmChangesStream.test.ts @@ -1,5 +1,5 @@ import { Readable, Duplex } from 'node:stream'; -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { ChangesStreamChange } from '../../../../app/common/adapter/changesStream/AbstractChangesStream'; import { NpmChangesStream } from '../../../../app/common/adapter/changesStream/NpmChangesStream'; diff --git a/test/core/entity/BugVersion.test.ts b/test/core/entity/BugVersion.test.ts index d16b6c8f..e7904adc 100644 --- a/test/core/entity/BugVersion.test.ts +++ b/test/core/entity/BugVersion.test.ts @@ -1,5 +1,5 @@ +import { strict as assert } from 'node:assert'; import { BugVersion } from '../../../app/core/entity/BugVersion'; -import assert from 'assert'; describe('test/core/entity/BugVersion.test.ts', () => { const bugVersion = new BugVersion({ diff --git a/test/core/entity/PaddingSemver.test.ts b/test/core/entity/PaddingSemver.test.ts index a4d956aa..ecac4f83 100644 --- a/test/core/entity/PaddingSemver.test.ts +++ b/test/core/entity/PaddingSemver.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { PaddingSemVer } from '../../../app/core/entity/PaddingSemVer'; describe('test/npm/core/entity/PaddingSemver.test.ts', () => { diff --git a/test/core/entity/SqlRange.test.ts b/test/core/entity/SqlRange.test.ts index e8837efb..901e21af 100644 --- a/test/core/entity/SqlRange.test.ts +++ b/test/core/entity/SqlRange.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { SqlRange } from '../../../app/core/entity/SqlRange'; describe('test/npm/core/entity/SqlRange.test.ts', () => { diff --git a/test/core/event/BugVersionFixHandler.test.ts b/test/core/event/BugVersionFixHandler.test.ts index 86bfb498..d2c0088a 100644 --- a/test/core/event/BugVersionFixHandler.test.ts +++ b/test/core/event/BugVersionFixHandler.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { BUG_VERSIONS } from '../../../app/common/constants'; import { CacheService } from '../../../app/core/service/CacheService'; diff --git a/test/core/event/StoreManifest.test.ts b/test/core/event/StoreManifest.test.ts index b0fc1b7d..81dfdf9b 100644 --- a/test/core/event/StoreManifest.test.ts +++ b/test/core/event/StoreManifest.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; import { getScopeAndName } from '../../../app/common/PackageUtil'; diff --git a/test/core/service/BinarySyncerService/createTask.test.ts b/test/core/service/BinarySyncerService/createTask.test.ts index 3f076c18..5742ed1c 100644 --- a/test/core/service/BinarySyncerService/createTask.test.ts +++ b/test/core/service/BinarySyncerService/createTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { BinarySyncerService } from '../../../../app/core/service/BinarySyncerService'; import { BinaryName } from '../../../../config/binaries'; diff --git a/test/core/service/BinarySyncerService/executeTask.test.ts b/test/core/service/BinarySyncerService/executeTask.test.ts index 8896a06a..70e67ece 100644 --- a/test/core/service/BinarySyncerService/executeTask.test.ts +++ b/test/core/service/BinarySyncerService/executeTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BinarySyncerService } from '../../../../app/core/service/BinarySyncerService'; diff --git a/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts b/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts index cdce208a..7260a30a 100644 --- a/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts +++ b/test/core/service/BugVersionService/cleanBugVersionPackageCache.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; diff --git a/test/core/service/BugVersionService/fixPackageBugVersion.test.ts b/test/core/service/BugVersionService/fixPackageBugVersion.test.ts index bb7f9cd3..a87f38cb 100644 --- a/test/core/service/BugVersionService/fixPackageBugVersion.test.ts +++ b/test/core/service/BugVersionService/fixPackageBugVersion.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; diff --git a/test/core/service/BugVersionService/fixPackageBugVersions.test.ts b/test/core/service/BugVersionService/fixPackageBugVersions.test.ts index a0f2e06b..9a12da92 100644 --- a/test/core/service/BugVersionService/fixPackageBugVersions.test.ts +++ b/test/core/service/BugVersionService/fixPackageBugVersions.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { BugVersionService } from '../../../../app/core/service/BugVersionService'; diff --git a/test/core/service/ChangesStreamService.test.ts b/test/core/service/ChangesStreamService.test.ts index 71088d49..0f819b11 100644 --- a/test/core/service/ChangesStreamService.test.ts +++ b/test/core/service/ChangesStreamService.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { Readable } from 'node:stream'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; diff --git a/test/core/service/CreateHookTriggerService.test.ts b/test/core/service/CreateHookTriggerService.test.ts index 864b88a3..0c2beb95 100644 --- a/test/core/service/CreateHookTriggerService.test.ts +++ b/test/core/service/CreateHookTriggerService.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; import { HookManageService } from '../../../app/core/service/HookManageService'; diff --git a/test/core/service/HookManageService/createHook.test.ts b/test/core/service/HookManageService/createHook.test.ts index 13dfcfaf..32772d71 100644 --- a/test/core/service/HookManageService/createHook.test.ts +++ b/test/core/service/HookManageService/createHook.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; diff --git a/test/core/service/HookManageService/deleteHook.test.ts b/test/core/service/HookManageService/deleteHook.test.ts index f99e1a6d..f1d394e1 100644 --- a/test/core/service/HookManageService/deleteHook.test.ts +++ b/test/core/service/HookManageService/deleteHook.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; diff --git a/test/core/service/HookManageService/getHookByOwnerId.test.ts b/test/core/service/HookManageService/getHookByOwnerId.test.ts index 7e4caa29..fe06c4dc 100644 --- a/test/core/service/HookManageService/getHookByOwnerId.test.ts +++ b/test/core/service/HookManageService/getHookByOwnerId.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; diff --git a/test/core/service/HookManageService/updateHook.test.ts b/test/core/service/HookManageService/updateHook.test.ts index 03766330..49a52f7e 100644 --- a/test/core/service/HookManageService/updateHook.test.ts +++ b/test/core/service/HookManageService/updateHook.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; diff --git a/test/core/service/HookTriggerService.test.ts b/test/core/service/HookTriggerService.test.ts index 19b1f650..2ba57f8d 100644 --- a/test/core/service/HookTriggerService.test.ts +++ b/test/core/service/HookTriggerService.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { HttpClientRequestOptions } from 'egg'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../test/TestUtil'; diff --git a/test/core/service/PackageManagerService/block.test.ts b/test/core/service/PackageManagerService/block.test.ts index 24a9ff70..8efb2072 100644 --- a/test/core/service/PackageManagerService/block.test.ts +++ b/test/core/service/PackageManagerService/block.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageManagerService } from '../../../../app/core/service/PackageManagerService'; diff --git a/test/core/service/PackageManagerService/publish.test.ts b/test/core/service/PackageManagerService/publish.test.ts index 9ae041f4..0c85824e 100644 --- a/test/core/service/PackageManagerService/publish.test.ts +++ b/test/core/service/PackageManagerService/publish.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageManagerService } from '../../../../app/core/service/PackageManagerService'; diff --git a/test/core/service/PackageSyncerService/createTask.test.ts b/test/core/service/PackageSyncerService/createTask.test.ts index ea05d4a9..9985da57 100644 --- a/test/core/service/PackageSyncerService/createTask.test.ts +++ b/test/core/service/PackageSyncerService/createTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { setTimeout } from 'timers/promises'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/core/service/PackageSyncerService/executeTask.test.ts b/test/core/service/PackageSyncerService/executeTask.test.ts index fe10a33f..48031d72 100644 --- a/test/core/service/PackageSyncerService/executeTask.test.ts +++ b/test/core/service/PackageSyncerService/executeTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; diff --git a/test/core/service/PackageSyncerService/findExecuteTask.test.ts b/test/core/service/PackageSyncerService/findExecuteTask.test.ts index 7dd500db..e35c1ac8 100644 --- a/test/core/service/PackageSyncerService/findExecuteTask.test.ts +++ b/test/core/service/PackageSyncerService/findExecuteTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { Task as TaskModel } from '../../../../app/repository/model/Task'; diff --git a/test/core/service/PackageSyncerService/getTaskRegistry.test.ts b/test/core/service/PackageSyncerService/getTaskRegistry.test.ts index fa9cbe5a..8d6ff6df 100644 --- a/test/core/service/PackageSyncerService/getTaskRegistry.test.ts +++ b/test/core/service/PackageSyncerService/getTaskRegistry.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; diff --git a/test/core/service/PackageVersionService.test.ts b/test/core/service/PackageVersionService.test.ts index 7119d2e1..99867b44 100644 --- a/test/core/service/PackageVersionService.test.ts +++ b/test/core/service/PackageVersionService.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import npa from 'npm-package-arg'; diff --git a/test/core/service/RegistryManagerService/index.test.ts b/test/core/service/RegistryManagerService/index.test.ts index bd3703a4..7f65fbca 100644 --- a/test/core/service/RegistryManagerService/index.test.ts +++ b/test/core/service/RegistryManagerService/index.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; import { RegistryType } from '../../../../app/common/enum/Registry'; diff --git a/test/core/service/ScopeManagerService/index.test.ts b/test/core/service/ScopeManagerService/index.test.ts index 4cec3cb5..53d05c4b 100644 --- a/test/core/service/ScopeManagerService/index.test.ts +++ b/test/core/service/ScopeManagerService/index.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ScopeManagerService } from '../../../../app/core/service/ScopeManagerService'; diff --git a/test/core/service/TaskService/findExecuteTask.test.ts b/test/core/service/TaskService/findExecuteTask.test.ts index 0a49c236..d3d85f18 100644 --- a/test/core/service/TaskService/findExecuteTask.test.ts +++ b/test/core/service/TaskService/findExecuteTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mm } from 'egg-mock/bootstrap'; import { TaskService } from '../../../../app/core/service/TaskService'; import { PackageSyncerService } from '../../../../app/core/service/PackageSyncerService'; diff --git a/test/core/util/EntityUtil.test.ts b/test/core/util/EntityUtil.test.ts index 2c0577da..30aaab8f 100644 --- a/test/core/util/EntityUtil.test.ts +++ b/test/core/util/EntityUtil.test.ts @@ -1,5 +1,5 @@ +import { strict as assert } from 'node:assert'; import { EntityUtil } from '../../../app/core/util/EntityUtil'; -import assert from 'assert'; describe('test/core/util/EntityUtil.test.ts', () => { describe('convertPageOptionsToLimitOption', () => { diff --git a/test/infra/QueueAdapter.test.ts b/test/infra/QueueAdapter.test.ts index 633b79d4..295c8a2f 100644 --- a/test/infra/QueueAdapter.test.ts +++ b/test/infra/QueueAdapter.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { RedisQueueAdapter } from '../../app/infra/QueueAdapter'; diff --git a/test/port/controller/AccessController/listCollaborators.test.ts b/test/port/controller/AccessController/listCollaborators.test.ts index ee3e7516..1bfda709 100644 --- a/test/port/controller/AccessController/listCollaborators.test.ts +++ b/test/port/controller/AccessController/listCollaborators.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/AccessController/listPackagesByUser.test.ts b/test/port/controller/AccessController/listPackagesByUser.test.ts index 6065a6a1..0cf0dd04 100644 --- a/test/port/controller/AccessController/listPackagesByUser.test.ts +++ b/test/port/controller/AccessController/listPackagesByUser.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/BinarySyncController/showBinary.test.ts b/test/port/controller/BinarySyncController/showBinary.test.ts index 1a41d1cb..3fd9c85f 100644 --- a/test/port/controller/BinarySyncController/showBinary.test.ts +++ b/test/port/controller/BinarySyncController/showBinary.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { BinarySyncerService } from '../../../../app/core/service/BinarySyncerService'; import { NodeBinary } from '../../../../app/common/adapter/binary/NodeBinary'; diff --git a/test/port/controller/ChangesStreamController/listChanges.test.ts b/test/port/controller/ChangesStreamController/listChanges.test.ts index 980283d4..96e85ff3 100644 --- a/test/port/controller/ChangesStreamController/listChanges.test.ts +++ b/test/port/controller/ChangesStreamController/listChanges.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/DownloadController/showPackageDownloads.test.ts b/test/port/controller/DownloadController/showPackageDownloads.test.ts index d91fc2c2..163e8e5c 100644 --- a/test/port/controller/DownloadController/showPackageDownloads.test.ts +++ b/test/port/controller/DownloadController/showPackageDownloads.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import dayjs from '../../../../app/common/dayjs'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/HomeController/cors.test.ts b/test/port/controller/HomeController/cors.test.ts index d79c4ce2..37bdeb1d 100644 --- a/test/port/controller/HomeController/cors.test.ts +++ b/test/port/controller/HomeController/cors.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; describe('test/port/controller/HomeController/cors.test.ts', () => { diff --git a/test/port/controller/HomeController/ping.test.ts b/test/port/controller/HomeController/ping.test.ts index 825eeab6..21a4ab4c 100644 --- a/test/port/controller/HomeController/ping.test.ts +++ b/test/port/controller/HomeController/ping.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; describe('test/port/controller/HomeController/ping.test.ts', () => { diff --git a/test/port/controller/HomeController/showTotal.test.ts b/test/port/controller/HomeController/showTotal.test.ts index 33807e78..6916074e 100644 --- a/test/port/controller/HomeController/showTotal.test.ts +++ b/test/port/controller/HomeController/showTotal.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageVersionDownload } from '../../../../app/repository/model/PackageVersionDownload'; diff --git a/test/port/controller/PackageBlockController/blockPackage.test.ts b/test/port/controller/PackageBlockController/blockPackage.test.ts index eb0d8506..0f377878 100644 --- a/test/port/controller/PackageBlockController/blockPackage.test.ts +++ b/test/port/controller/PackageBlockController/blockPackage.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/PackageBlockController/unblockPackage.test.ts b/test/port/controller/PackageBlockController/unblockPackage.test.ts index 9aff9ce8..4eeca613 100644 --- a/test/port/controller/PackageBlockController/unblockPackage.test.ts +++ b/test/port/controller/PackageBlockController/unblockPackage.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/PackageSyncController/createSyncTask.test.ts b/test/port/controller/PackageSyncController/createSyncTask.test.ts index af4cd08d..d76f0827 100644 --- a/test/port/controller/PackageSyncController/createSyncTask.test.ts +++ b/test/port/controller/PackageSyncController/createSyncTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { setTimeout } from 'timers/promises'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/PackageSyncController/showSyncTask.test.ts b/test/port/controller/PackageSyncController/showSyncTask.test.ts index a011daf5..5fec3f87 100644 --- a/test/port/controller/PackageSyncController/showSyncTask.test.ts +++ b/test/port/controller/PackageSyncController/showSyncTask.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { TaskRepository } from '../../../../app/repository/TaskRepository'; diff --git a/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts b/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts index b63f57a5..28799681 100644 --- a/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts +++ b/test/port/controller/PackageSyncController/showSyncTaskLog.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { TaskRepository } from '../../../../app/repository/TaskRepository'; diff --git a/test/port/controller/PackageTagController/removeTag.test.ts b/test/port/controller/PackageTagController/removeTag.test.ts index b4196dee..3878aeb1 100644 --- a/test/port/controller/PackageTagController/removeTag.test.ts +++ b/test/port/controller/PackageTagController/removeTag.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/PackageTagController/saveTag.test.ts b/test/port/controller/PackageTagController/saveTag.test.ts index 0e028cdf..4ec3d15b 100644 --- a/test/port/controller/PackageTagController/saveTag.test.ts +++ b/test/port/controller/PackageTagController/saveTag.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/PackageTagController/showTags.test.ts b/test/port/controller/PackageTagController/showTags.test.ts index dfab979b..fb9f7b3c 100644 --- a/test/port/controller/PackageTagController/showTags.test.ts +++ b/test/port/controller/PackageTagController/showTags.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/PackageVersionFileController/raw.test.ts b/test/port/controller/PackageVersionFileController/raw.test.ts index 0581b855..d202109d 100644 --- a/test/port/controller/PackageVersionFileController/raw.test.ts +++ b/test/port/controller/PackageVersionFileController/raw.test.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'node:assert'; +import { setTimeout } from 'node:timers/promises'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { calculateIntegrity } from '../../../../app/common/PackageUtil'; @@ -90,7 +91,7 @@ describe('test/port/controller/PackageVersionFileController/raw.test.ts', () => it('should block raw file when package not in white list', async () => { mock(app.config.cnpmcore, 'allowPublishNonScopePackage', true); let pkg = await TestUtil.getFullPackage({ - name: 'foo', + name: 'foo-block-again', version: '1.0.0', versionObject: { description: 'work with utf8mb4 ๐Ÿ’ฉ, ๐Œ† utf8_unicode_ci, foo๐Œ†bar ๐Ÿป', @@ -103,7 +104,7 @@ describe('test/port/controller/PackageVersionFileController/raw.test.ts', () => .send(pkg) .expect(201); let res = await app.httpRequest() - .get('/foo/1.0.0/files/package.json') + .get('/foo-block-again/1.0.0/files/package.json') .expect(200) .expect('content-type', 'application/json; charset=utf-8'); // console.log(res.body); @@ -119,14 +120,15 @@ describe('test/port/controller/PackageVersionFileController/raw.test.ts', () => license: 'ISC', }); + await setTimeout(1); mock(app.config.cnpmcore, 'enableSyncUnpkgFilesWhiteList', true); // should block res = await app.httpRequest() - .get('/foo/1.0.0/files/package.json') + .get('/foo-block-again/1.0.0/files/package.json') .expect(403) .expect('content-type', 'application/json; charset=utf-8'); assert.equal(res.body.error, - '[FORBIDDEN] "foo" is not allow to unpkg files, see https://github.com/cnpm/unpkg-white-list'); + '[FORBIDDEN] "foo-block-again" is not allow to unpkg files, see https://github.com/cnpm/unpkg-white-list'); // add white list pkg = await TestUtil.getFullPackage({ @@ -135,7 +137,7 @@ describe('test/port/controller/PackageVersionFileController/raw.test.ts', () => versionObject: { description: 'work with utf8mb4 ๐Ÿ’ฉ, ๐Œ† utf8_unicode_ci, foo๐Œ†bar ๐Ÿป', allowPackages: { - foo: { + 'foo-block-again': { version: '*', }, }, @@ -147,13 +149,14 @@ describe('test/port/controller/PackageVersionFileController/raw.test.ts', () => .set('user-agent', publisher.ua) .send(pkg) .expect(201); + await setTimeout(1); res = await app.httpRequest() - .get('/foo/1.0.0/files/package.json') - // .expect(200) + .get('/foo-block-again/1.0.0/files/package.json') + .expect(200) .expect('content-type', 'application/json; charset=utf-8'); - console.log(res.body); - // assert.equal(res.headers['cache-control'], 'public, max-age=31536000'); - // assert.equal(res.headers.vary, 'Origin, Accept, Accept-Encoding'); + // console.log(res.body); + assert.equal(res.headers['cache-control'], 'public, max-age=31536000'); + assert.equal(res.headers.vary, 'Origin, Accept, Accept-Encoding'); assert.deepEqual(res.body, { name: 'mk2testmodule', version: '0.0.1', diff --git a/test/port/controller/RegistryController/index.test.ts b/test/port/controller/RegistryController/index.test.ts index e96c4512..4f5ee6fd 100644 --- a/test/port/controller/RegistryController/index.test.ts +++ b/test/port/controller/RegistryController/index.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TaskType } from '../../../../app/common/enum/Task'; import { Registry } from '../../../../app/core/entity/Registry'; diff --git a/test/port/controller/ScopeController/index.test.ts b/test/port/controller/ScopeController/index.test.ts index 73ec4b70..bc43b7ee 100644 --- a/test/port/controller/ScopeController/index.test.ts +++ b/test/port/controller/ScopeController/index.test.ts @@ -1,7 +1,7 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; +import { app } from 'egg-mock/bootstrap'; import { RegistryType } from '../../../../app/common/enum/Registry'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; -import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../TestUtil'; import { Scope } from '../../../../app/core/entity/Scope'; diff --git a/test/port/controller/TokenController/createToken.test.ts b/test/port/controller/TokenController/createToken.test.ts index f05bcafa..0285458a 100644 --- a/test/port/controller/TokenController/createToken.test.ts +++ b/test/port/controller/TokenController/createToken.test.ts @@ -1,9 +1,9 @@ +import { strict as assert } from 'node:assert'; +import dayjs from 'dayjs'; +import { app, mock } from 'egg-mock/bootstrap'; import { Token, TokenType } from '../../../../app/core/entity/Token'; import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; import { UserRepository } from '../../../../app/repository/UserRepository'; -import assert from 'assert'; -import dayjs from 'dayjs'; -import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/TokenController/createToken.test.ts', () => { diff --git a/test/port/controller/TokenController/listTokens.test.ts b/test/port/controller/TokenController/listTokens.test.ts index 662143af..ea42ba24 100644 --- a/test/port/controller/TokenController/listTokens.test.ts +++ b/test/port/controller/TokenController/listTokens.test.ts @@ -1,10 +1,10 @@ +import { strict as assert } from 'node:assert'; +import { app, mock } from 'egg-mock/bootstrap'; +import dayjs from 'dayjs'; import { TokenType } from '../../../../app/core/entity/Token'; import { UserService } from '../../../../app/core/service/UserService'; import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; -import assert from 'assert'; -import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; -import dayjs from 'dayjs'; describe('test/port/controller/TokenController/listTokens.test.ts', () => { describe('[GET /-/npm/v1/tokens] listTokens()', () => { diff --git a/test/port/controller/TokenController/removeToken.test.ts b/test/port/controller/TokenController/removeToken.test.ts index 9c9a6bcc..74488120 100644 --- a/test/port/controller/TokenController/removeToken.test.ts +++ b/test/port/controller/TokenController/removeToken.test.ts @@ -1,9 +1,9 @@ +import { strict as assert } from 'node:assert'; +import { app, mock } from 'egg-mock/bootstrap'; import { Token, TokenType } from '../../../../app/core/entity/Token'; import { UserService } from '../../../../app/core/service/UserService'; import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; import { TokenPackage } from '../../../../app/repository/model/TokenPackage'; -import assert from 'assert'; -import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/TokenController/removeToken.test.ts', () => { diff --git a/test/port/controller/UserController/loginOrCreateUser.test.ts b/test/port/controller/UserController/loginOrCreateUser.test.ts index 2c976314..f37706ed 100644 --- a/test/port/controller/UserController/loginOrCreateUser.test.ts +++ b/test/port/controller/UserController/loginOrCreateUser.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; describe('test/port/controller/UserController/loginOrCreateUser.test.ts', () => { diff --git a/test/port/controller/UserController/logout.test.ts b/test/port/controller/UserController/logout.test.ts index dd874b04..8b0188aa 100644 --- a/test/port/controller/UserController/logout.test.ts +++ b/test/port/controller/UserController/logout.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/UserController/saveProfile.test.ts b/test/port/controller/UserController/saveProfile.test.ts index d2f86490..1afa0284 100644 --- a/test/port/controller/UserController/saveProfile.test.ts +++ b/test/port/controller/UserController/saveProfile.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/UserController/showProfile.test.ts b/test/port/controller/UserController/showProfile.test.ts index d802041b..d94c8ce3 100644 --- a/test/port/controller/UserController/showProfile.test.ts +++ b/test/port/controller/UserController/showProfile.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/UserController/showUser.test.ts b/test/port/controller/UserController/showUser.test.ts index 24a33aa1..51ab4e9f 100644 --- a/test/port/controller/UserController/showUser.test.ts +++ b/test/port/controller/UserController/showUser.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/UserController/starredByUser.test.ts b/test/port/controller/UserController/starredByUser.test.ts index f07d1236..8cda93b7 100644 --- a/test/port/controller/UserController/starredByUser.test.ts +++ b/test/port/controller/UserController/starredByUser.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; diff --git a/test/port/controller/UserController/whoami.test.ts b/test/port/controller/UserController/whoami.test.ts index 294c9781..971e184b 100644 --- a/test/port/controller/UserController/whoami.test.ts +++ b/test/port/controller/UserController/whoami.test.ts @@ -1,7 +1,7 @@ -import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import dayjs from 'dayjs'; import { app, mock } from 'egg-mock/bootstrap'; +import { AuthAdapter } from '../../../../app/infra/AuthAdapter'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/UserController/whoami.test.ts', () => { diff --git a/test/port/controller/hook/HookController.test.ts b/test/port/controller/hook/HookController.test.ts index d698ac39..a3b71d0a 100644 --- a/test/port/controller/hook/HookController.test.ts +++ b/test/port/controller/hook/HookController.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { HookManageService } from '../../../../app/core/service/HookManageService'; diff --git a/test/port/controller/package/DownloadPackageVersionTarController.test.ts b/test/port/controller/package/DownloadPackageVersionTarController.test.ts index bd1a9702..d3b10171 100644 --- a/test/port/controller/package/DownloadPackageVersionTarController.test.ts +++ b/test/port/controller/package/DownloadPackageVersionTarController.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { NFSClientAdapter } from '../../../../app/infra/NFSClientAdapter'; diff --git a/test/port/controller/package/RemovePackageVersionController.test.ts b/test/port/controller/package/RemovePackageVersionController.test.ts index 1c31d88a..c91a5203 100644 --- a/test/port/controller/package/RemovePackageVersionController.test.ts +++ b/test/port/controller/package/RemovePackageVersionController.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageRepository } from '../../../../app/repository/PackageRepository'; diff --git a/test/port/controller/package/SavePackageVersionController.test.ts b/test/port/controller/package/SavePackageVersionController.test.ts index 72f5146d..97d9ddd3 100644 --- a/test/port/controller/package/SavePackageVersionController.test.ts +++ b/test/port/controller/package/SavePackageVersionController.test.ts @@ -1,6 +1,8 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { setTimeout } from 'node:timers/promises'; import { app, mock } from 'egg-mock/bootstrap'; +import { ForbiddenError } from 'egg-errors'; +import dayjs from 'dayjs'; import { TestUtil } from '../../../../test/TestUtil'; import { UserRepository } from '../../../../app/repository/UserRepository'; import { calculateIntegrity } from '../../../../app/common/PackageUtil'; @@ -10,9 +12,7 @@ import { UserService } from '../../../../app/core/service/UserService'; import { Token, TokenType } from '../../../../app/core/entity/Token'; import { Token as TokenModel } from '../../../../app/repository/model/Token'; import { User } from '../../../../app/core/entity/User'; -import dayjs from 'dayjs'; import { PackageManagerService } from '../../../../app/core/service/PackageManagerService'; -import { ForbiddenError } from 'egg-errors'; describe('test/port/controller/package/SavePackageVersionController.test.ts', () => { let userRepository: UserRepository; diff --git a/test/port/controller/package/SearchPackageController.test.ts b/test/port/controller/package/SearchPackageController.test.ts index 12aac38c..63e0967b 100644 --- a/test/port/controller/package/SearchPackageController.test.ts +++ b/test/port/controller/package/SearchPackageController.test.ts @@ -1,7 +1,6 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { errors } from '@elastic/elasticsearch'; - import { mockES } from '../../../../config/config.unittest'; import { TestUtil } from '../../../TestUtil'; diff --git a/test/port/controller/package/ShowPackageController.test.ts b/test/port/controller/package/ShowPackageController.test.ts index 745c62be..0745462a 100644 --- a/test/port/controller/package/ShowPackageController.test.ts +++ b/test/port/controller/package/ShowPackageController.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; import { PackageManifestType, PackageRepository } from '../../../../app/repository/PackageRepository'; diff --git a/test/port/controller/package/UpdatePackageController.test.ts b/test/port/controller/package/UpdatePackageController.test.ts index b5921bd4..b7e142f8 100644 --- a/test/port/controller/package/UpdatePackageController.test.ts +++ b/test/port/controller/package/UpdatePackageController.test.ts @@ -1,7 +1,7 @@ +import { strict as assert } from 'node:assert'; +import { app, mock } from 'egg-mock/bootstrap'; import { RegistryType } from '../../../../app/common/enum/Registry'; import { RegistryManagerService } from '../../../../app/core/service/RegistryManagerService'; -import assert from 'assert'; -import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../../../test/TestUtil'; describe('test/port/controller/package/UpdatePackageController.test.ts', () => { diff --git a/test/port/middleware/AlwaysAuth.test.ts b/test/port/middleware/AlwaysAuth.test.ts index 9c896b7f..8fc5fdb0 100644 --- a/test/port/middleware/AlwaysAuth.test.ts +++ b/test/port/middleware/AlwaysAuth.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { TestUtil } from '../../TestUtil'; diff --git a/test/port/middleware/Tracing.test.ts b/test/port/middleware/Tracing.test.ts index 0d009454..e649e9ef 100644 --- a/test/port/middleware/Tracing.test.ts +++ b/test/port/middleware/Tracing.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; describe('test/port/middleware/Tracing.test.ts', () => { diff --git a/test/repository/ChangeRepository.test.ts b/test/repository/ChangeRepository.test.ts index 370b6001..e6dda944 100644 --- a/test/repository/ChangeRepository.test.ts +++ b/test/repository/ChangeRepository.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ChangeRepository } from '../../app/repository/ChangeRepository'; import { Change as ChangeModel } from '../../app/repository/model/Change'; diff --git a/test/repository/PackageRepository.test.ts b/test/repository/PackageRepository.test.ts index 7e3fe933..2f195f2b 100644 --- a/test/repository/PackageRepository.test.ts +++ b/test/repository/PackageRepository.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { PackageRepository } from '../../app/repository/PackageRepository'; import { PackageManagerService } from '../../app/core/service/PackageManagerService'; diff --git a/test/repository/RegistryRepository.test.ts b/test/repository/RegistryRepository.test.ts index b0b6f1b9..ac29aea5 100644 --- a/test/repository/RegistryRepository.test.ts +++ b/test/repository/RegistryRepository.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { RegistryRepository } from '../../app/repository/RegistryRepository'; import { Registry } from '../../app/core/entity/Registry'; diff --git a/test/repository/ScopeRepository.test.ts b/test/repository/ScopeRepository.test.ts index 3ca6b30a..532dc619 100644 --- a/test/repository/ScopeRepository.test.ts +++ b/test/repository/ScopeRepository.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app } from 'egg-mock/bootstrap'; import { ScopeRepository } from '../../app/repository/ScopeRepository'; import { Scope } from '../../app/core/entity/Scope'; diff --git a/test/repository/SearchRepository.test.ts b/test/repository/SearchRepository.test.ts index 1492f26c..1275fc1f 100644 --- a/test/repository/SearchRepository.test.ts +++ b/test/repository/SearchRepository.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { SearchManifestType, SearchRepository } from '../../app/repository/SearchRepository'; import { mockES } from '../../config/config.unittest'; diff --git a/test/repository/TaskRepository.test.ts b/test/repository/TaskRepository.test.ts index 59c7caea..87d05c98 100644 --- a/test/repository/TaskRepository.test.ts +++ b/test/repository/TaskRepository.test.ts @@ -1,11 +1,11 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; +import { setTimeout } from 'node:timers/promises'; +import os from 'node:os'; import { app } from 'egg-mock/bootstrap'; -import { setTimeout } from 'timers/promises'; import { TaskRepository } from '../../app/repository/TaskRepository'; import { Task as TaskModel } from '../../app/repository/model/Task'; import { ChangesStreamTaskData, Task, TaskData } from '../../app/core/entity/Task'; import { TaskState, TaskType } from '../../app/common/enum/Task'; -import os from 'os'; import { EasyData, EntityUtil } from '../../app/core/util/EntityUtil'; describe('test/repository/TaskRepository.test.ts', () => { diff --git a/test/schedule/ChangesStreamWorker.test.ts b/test/schedule/ChangesStreamWorker.test.ts index 37678361..bac786a3 100644 --- a/test/schedule/ChangesStreamWorker.test.ts +++ b/test/schedule/ChangesStreamWorker.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { ChangesStreamService } from '../../app/core/service/ChangesStreamService'; import { TaskService } from '../../app/core/service/TaskService'; diff --git a/test/schedule/CheckRecentlyUpdatedPackages.test.ts b/test/schedule/CheckRecentlyUpdatedPackages.test.ts index fa00db6e..f94988a8 100644 --- a/test/schedule/CheckRecentlyUpdatedPackages.test.ts +++ b/test/schedule/CheckRecentlyUpdatedPackages.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { PackageSyncerService } from '../../app/core/service/PackageSyncerService'; import { TestUtil } from '../../test/TestUtil'; diff --git a/test/schedule/SyncPackageWorker.test.ts b/test/schedule/SyncPackageWorker.test.ts index 417579c3..c800fc4f 100644 --- a/test/schedule/SyncPackageWorker.test.ts +++ b/test/schedule/SyncPackageWorker.test.ts @@ -1,4 +1,4 @@ -import assert from 'assert'; +import { strict as assert } from 'node:assert'; import { app, mock } from 'egg-mock/bootstrap'; import { PackageSyncerService } from '../../app/core/service/PackageSyncerService'; import { TestUtil } from '../../test/TestUtil'; From eb8a756fadf2b9f2413c1cb9afedf69db0821cc1 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 30 May 2024 14:07:25 +0800 Subject: [PATCH 3/4] f --- test/repository/ScopeRepository.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/repository/ScopeRepository.test.ts b/test/repository/ScopeRepository.test.ts index 532dc619..9750552f 100644 --- a/test/repository/ScopeRepository.test.ts +++ b/test/repository/ScopeRepository.test.ts @@ -32,7 +32,8 @@ describe('test/repository/ScopeRepository.test.ts', () => { registryId: '1', })) as Scope; const scopeRes = await scopeRepository.listScopes({}); - assert.deepEqual([ cnpmjsScope.name, cnpmScope.name ], scopeRes.data.map(scope => scope.name)); + assert.deepEqual([ cnpmjsScope.name, cnpmScope.name ], + Array.from(scopeRes.data.map(scope => scope.name))); }); it('update work', async () => { @@ -56,10 +57,11 @@ describe('test/repository/ScopeRepository.test.ts', () => { })) as Scope; await scopeRepository.removeScope(cnpmjsScope.scopeId); const scopesAfterRemove = await scopeRepository.listScopes({}); - assert.deepEqual(scopesAfterRemove.data.map(scope => scope.name), [ cnpmScope.name ]); + assert.deepEqual(Array.from(scopesAfterRemove.data.map(scope => scope.name)), + [ cnpmScope.name ]); await scopeRepository.removeScopeByRegistryId(cnpmjsScope.registryId); const emptyRes = await scopeRepository.listScopes({}); - assert.deepEqual(emptyRes.data, []); + assert.deepEqual(Array.from(emptyRes.data), []); }); }); }); From b3e57d19e9b0fab17623bf3c76f2c43d3c5e981b Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Thu, 30 May 2024 14:12:35 +0800 Subject: [PATCH 4/4] f --- test/repository/RegistryRepository.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/repository/RegistryRepository.test.ts b/test/repository/RegistryRepository.test.ts index ac29aea5..d8ee7b37 100644 --- a/test/repository/RegistryRepository.test.ts +++ b/test/repository/RegistryRepository.test.ts @@ -64,7 +64,7 @@ describe('test/repository/RegistryRepository.test.ts', () => { it('remove work', async () => { await registryRepository.removeRegistry(registryModel.registryId); const emptyRes = await registryRepository.listRegistries({}); - assert.deepEqual(emptyRes.data, []); + assert.deepEqual(Array.from(emptyRes.data), []); }); }); });