Add unit tests for role middleware
Some checks are pending
Docker Test / test (push) Waiting to run

This commit is contained in:
BibaBot 2026-03-17 07:07:36 +00:00
parent 7a9bf3199a
commit c294e2e9ae
5702 changed files with 465039 additions and 34 deletions

22
node_modules/jest-resolve-dependencies/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
Copyright Contributors to the Jest project.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,43 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {IHasteFS} from 'jest-haste-map';
import default_2, {ResolveModuleConfig} from 'jest-resolve';
import {SnapshotResolver} from 'jest-snapshot';
/**
* DependencyResolver is used to resolve the direct dependencies of a module or
* to retrieve a list of all transitive inverse dependencies.
*/
export declare class DependencyResolver {
private readonly _hasteFS;
private readonly _resolver;
private readonly _snapshotResolver;
constructor(
resolver: default_2,
hasteFS: IHasteFS,
snapshotResolver: SnapshotResolver,
);
resolve(file: string, options?: ResolveModuleConfig): Array<string>;
resolveInverseModuleMap(
paths: Set<string>,
filter: (file: string) => boolean,
options?: ResolveModuleConfig,
): Array<ResolvedModule>;
resolveInverse(
paths: Set<string>,
filter: (file: string) => boolean,
options?: ResolveModuleConfig,
): Array<string>;
}
export declare type ResolvedModule = {
file: string;
dependencies: Array<string>;
};
export {};

159
node_modules/jest-resolve-dependencies/build/index.js generated vendored Normal file
View file

@ -0,0 +1,159 @@
/*!
* /**
* * Copyright (c) Meta Platforms, Inc. and affiliates.
* *
* * This source code is licensed under the MIT license found in the
* * LICENSE file in the root directory of this source tree.
* * /
*/
/******/ (() => { // webpackBootstrap
/******/ "use strict";
var __webpack_exports__ = {};
// This entry needs to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
(() => {
var exports = __webpack_exports__;
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.DependencyResolver = void 0;
function path() {
const data = _interopRequireWildcard(require("path"));
path = function () {
return data;
};
return data;
}
function _jestSnapshot() {
const data = require("jest-snapshot");
_jestSnapshot = function () {
return data;
};
return data;
}
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* DependencyResolver is used to resolve the direct dependencies of a module or
* to retrieve a list of all transitive inverse dependencies.
*/
class DependencyResolver {
_hasteFS;
_resolver;
_snapshotResolver;
constructor(resolver, hasteFS, snapshotResolver) {
this._resolver = resolver;
this._hasteFS = hasteFS;
this._snapshotResolver = snapshotResolver;
}
resolve(file, options) {
const dependencies = this._hasteFS.getDependencies(file);
const fallbackOptions = {
conditions: undefined
};
if (!dependencies) {
return [];
}
return dependencies.reduce((acc, dependency) => {
if (this._resolver.isCoreModule(dependency)) {
return acc;
}
let resolvedDependency;
let resolvedMockDependency;
try {
resolvedDependency = this._resolver.resolveModule(file, dependency, options ?? fallbackOptions);
} catch {
try {
resolvedDependency = this._resolver.getMockModule(file, dependency, options ?? fallbackOptions);
} catch {
// leave resolvedDependency as undefined if nothing can be found
}
}
if (resolvedDependency == null) {
return acc;
}
acc.push(resolvedDependency);
// If we resolve a dependency, then look for a mock dependency
// of the same name in that dependency's directory.
try {
resolvedMockDependency = this._resolver.getMockModule(resolvedDependency, path().basename(dependency), options ?? fallbackOptions);
} catch {
// leave resolvedMockDependency as undefined if nothing can be found
}
if (resolvedMockDependency != null) {
const dependencyMockDir = path().resolve(path().dirname(resolvedDependency), '__mocks__');
resolvedMockDependency = path().resolve(resolvedMockDependency);
// make sure mock is in the correct directory
if (dependencyMockDir === path().dirname(resolvedMockDependency)) {
acc.push(resolvedMockDependency);
}
}
return acc;
}, []);
}
resolveInverseModuleMap(paths, filter, options) {
if (paths.size === 0) {
return [];
}
const collectModules = (related, moduleMap, changed) => {
const visitedModules = new Set();
const result = [];
while (changed.size > 0) {
changed = new Set(moduleMap.reduce((acc, module) => {
if (visitedModules.has(module.file) || !module.dependencies.some(dep => changed.has(dep))) {
return acc;
}
const file = module.file;
if (filter(file)) {
result.push(module);
related.delete(file);
}
visitedModules.add(file);
acc.push(file);
return acc;
}, []));
}
return [...result, ...[...related].map(file => ({
dependencies: [],
file
}))];
};
const relatedPaths = new Set();
const changed = new Set();
for (const path of paths) {
if (this._hasteFS.exists(path)) {
const modulePath = (0, _jestSnapshot().isSnapshotPath)(path) ? this._snapshotResolver.resolveTestPath(path) : path;
changed.add(modulePath);
if (filter(modulePath)) {
relatedPaths.add(modulePath);
}
}
}
const modules = [];
for (const file of this._hasteFS.getAbsoluteFileIterator()) {
modules.push({
dependencies: this.resolve(file, options),
file
});
}
return collectModules(relatedPaths, modules, changed);
}
resolveInverse(paths, filter, options) {
return this.resolveInverseModuleMap(paths, filter, options).map(module => module.file);
}
}
exports.DependencyResolver = DependencyResolver;
})();
module.exports = __webpack_exports__;
/******/ })()
;

View file

@ -0,0 +1,3 @@
import cjsModule from './index.js';
export const DependencyResolver = cjsModule.DependencyResolver;

39
node_modules/jest-resolve-dependencies/package.json generated vendored Normal file
View file

@ -0,0 +1,39 @@
{
"name": "jest-resolve-dependencies",
"version": "30.3.0",
"repository": {
"type": "git",
"url": "https://github.com/jestjs/jest.git",
"directory": "packages/jest-resolve-dependencies"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"require": "./build/index.js",
"import": "./build/index.mjs",
"default": "./build/index.js"
},
"./package.json": "./package.json"
},
"dependencies": {
"jest-regex-util": "30.0.1",
"jest-snapshot": "30.3.0"
},
"devDependencies": {
"@jest/test-utils": "30.3.0",
"@jest/types": "30.3.0",
"jest-haste-map": "30.3.0",
"jest-resolve": "30.3.0",
"jest-runtime": "30.3.0"
},
"engines": {
"node": "^18.14.0 || ^20.0.0 || ^22.0.0 || >=24.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "efb59c2e81083f8dc941f20d6d20a3af2dc8d068"
}