mirror of
https://github.com/n8n-io/n8n.git
synced 2024-09-11 13:15:28 +03:00
refactor(core): Update supertest, and fix some typing errors (no-changelog) (#9527)
This commit is contained in:
parent
47d774100b
commit
08902bf941
@ -59,7 +59,7 @@
|
||||
"rimraf": "^5.0.1",
|
||||
"run-script-os": "^1.0.7",
|
||||
"start-server-and-test": "^2.0.3",
|
||||
"supertest": "^6.3.4",
|
||||
"supertest": "^7.0.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
"tsc-alias": "^1.8.7",
|
||||
"tsc-watch": "^6.0.4",
|
||||
|
@ -76,7 +76,7 @@
|
||||
"@types/replacestream": "^4.0.1",
|
||||
"@types/shelljs": "^0.8.11",
|
||||
"@types/sshpk": "^1.17.1",
|
||||
"@types/superagent": "^8.1.4",
|
||||
"@types/superagent": "^8.1.7",
|
||||
"@types/swagger-ui-express": "^4.1.6",
|
||||
"@types/syslog-client": "^1.1.2",
|
||||
"@types/uuid": "^8.3.2",
|
||||
|
@ -1,15 +1,15 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Container } from 'typedi';
|
||||
import { Cipher } from 'n8n-core';
|
||||
import { jsonParse, type IDataObject } from 'n8n-workflow';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { License } from '@/License';
|
||||
import type { ExternalSecretsSettings, SecretsProviderState } from '@/Interfaces';
|
||||
import { Cipher } from 'n8n-core';
|
||||
import { SettingsRepository } from '@db/repositories/settings.repository';
|
||||
import { Container } from 'typedi';
|
||||
import { ExternalSecretsProviders } from '@/ExternalSecrets/ExternalSecretsProviders.ee';
|
||||
import config from '@/config';
|
||||
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
|
||||
import { CREDENTIAL_BLANKING_VALUE } from '@/constants';
|
||||
import { jsonParse, type IDataObject } from 'n8n-workflow';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { setupTestServer } from '../shared/utils';
|
||||
@ -20,6 +20,7 @@ import {
|
||||
MockProviders,
|
||||
TestFailProvider,
|
||||
} from '../../shared/ExternalSecrets/utils';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
let authMemberAgent: SuperAgentTest;
|
||||
|
@ -1,16 +1,18 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Container } from 'typedi';
|
||||
import validator from 'validator';
|
||||
|
||||
import config from '@/config';
|
||||
import { AUTH_COOKIE_NAME } from '@/constants';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { MfaService } from '@/Mfa/mfa.service';
|
||||
|
||||
import { LOGGED_OUT_RESPONSE_BODY } from './shared/constants';
|
||||
import { randomValidPassword } from './shared/random';
|
||||
import * as testDb from './shared/testDb';
|
||||
import * as utils from './shared/utils/';
|
||||
import { createUser, createUserShell } from './shared/db/users';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { MfaService } from '@/Mfa/mfa.service';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
let owner: User;
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
||||
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import * as utils from './shared/utils/';
|
||||
import { createUser } from './shared/db/users';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
describe('Auth Middleware', () => {
|
||||
mockInstance(ActiveWorkflowManager);
|
||||
@ -13,23 +13,23 @@ describe('Auth Middleware', () => {
|
||||
});
|
||||
|
||||
/** Routes requiring a valid `n8n-auth` cookie for a user, either owner or member. */
|
||||
const ROUTES_REQUIRING_AUTHENTICATION: Readonly<Array<[string, string]>> = [
|
||||
['PATCH', '/me'],
|
||||
['PATCH', '/me/password'],
|
||||
['POST', '/me/survey'],
|
||||
];
|
||||
const ROUTES_REQUIRING_AUTHENTICATION = [
|
||||
['patch', '/me'],
|
||||
['patch', '/me/password'],
|
||||
['post', '/me/survey'],
|
||||
] as const;
|
||||
|
||||
/** Routes requiring a valid `n8n-auth` cookie for an owner. */
|
||||
const ROUTES_REQUIRING_AUTHORIZATION: Readonly<Array<[string, string]>> = [
|
||||
['POST', '/invitations'],
|
||||
['DELETE', '/users/123'],
|
||||
];
|
||||
const ROUTES_REQUIRING_AUTHORIZATION = [
|
||||
['post', '/invitations'],
|
||||
['delete', '/users/123'],
|
||||
] as const;
|
||||
|
||||
describe('Routes requiring Authentication', () => {
|
||||
ROUTES_REQUIRING_AUTHENTICATION.concat(ROUTES_REQUIRING_AUTHORIZATION).forEach(
|
||||
[...ROUTES_REQUIRING_AUTHENTICATION, ...ROUTES_REQUIRING_AUTHORIZATION].forEach(
|
||||
([method, endpoint]) => {
|
||||
test(`${method} ${endpoint} should return 401 Unauthorized if no cookie`, async () => {
|
||||
const { statusCode } = await testServer.authlessAgent[method.toLowerCase()](endpoint);
|
||||
const { statusCode } = await testServer.authlessAgent[method](endpoint);
|
||||
expect(statusCode).toBe(401);
|
||||
});
|
||||
},
|
||||
@ -45,7 +45,7 @@ describe('Auth Middleware', () => {
|
||||
|
||||
ROUTES_REQUIRING_AUTHORIZATION.forEach(async ([method, endpoint]) => {
|
||||
test(`${method} ${endpoint} should return 403 Forbidden for member`, async () => {
|
||||
const { statusCode } = await authMemberAgent[method.toLowerCase()](endpoint);
|
||||
const { statusCode } = await authMemberAgent[method](endpoint);
|
||||
expect(statusCode).toBe(403);
|
||||
});
|
||||
});
|
||||
|
@ -1,11 +1,11 @@
|
||||
import fsp from 'node:fs/promises';
|
||||
import { Readable } from 'node:stream';
|
||||
import { BinaryDataService, FileNotFoundError } from 'n8n-core';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { setupTestServer } from './shared/utils';
|
||||
import { createOwner } from './shared/db/users';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
jest.mock('fs/promises');
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import path from 'path';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
|
||||
import type { InstalledPackages } from '@db/entities/InstalledPackages';
|
||||
import type { InstalledNodes } from '@db/entities/InstalledNodes';
|
||||
@ -10,6 +9,7 @@ import { mockInstance } from '../shared/mocking';
|
||||
import { COMMUNITY_PACKAGE_VERSION } from './shared/constants';
|
||||
import { setupTestServer, mockPackage, mockNode, mockPackageName } from './shared/utils';
|
||||
import { createOwner } from './shared/db/users';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
const communityPackagesService = mockInstance(CommunityPackagesService, {
|
||||
hasMissingPackages: false,
|
||||
|
@ -1,18 +1,20 @@
|
||||
import type { SuperTest, Test } from 'supertest';
|
||||
import { createOwner } from '../shared/db/users';
|
||||
import { setupTestServer } from '../shared/utils';
|
||||
import * as AdditionalData from '@/WorkflowExecuteAdditionalData';
|
||||
import type {
|
||||
INodeListSearchResult,
|
||||
IWorkflowExecuteAdditionalData,
|
||||
ResourceMapperFields,
|
||||
} from 'n8n-workflow';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import { DynamicNodeParametersService } from '@/services/dynamicNodeParameters.service';
|
||||
import * as AdditionalData from '@/WorkflowExecuteAdditionalData';
|
||||
|
||||
import { createOwner } from '../shared/db/users';
|
||||
import { setupTestServer } from '../shared/utils';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
describe('DynamicNodeParametersController', () => {
|
||||
const testServer = setupTestServer({ endpointGroups: ['dynamic-node-parameters'] });
|
||||
let ownerAgent: SuperTest<Test>;
|
||||
let ownerAgent: SuperAgentTest;
|
||||
|
||||
beforeAll(async () => {
|
||||
const owner = await createOwner();
|
||||
|
@ -1,10 +1,14 @@
|
||||
import { Container } from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { In } from '@n8n/typeorm';
|
||||
|
||||
import config from '@/config';
|
||||
import type { ListQuery } from '@/requests';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
import type { Project } from '@db/entities/Project';
|
||||
import { ProjectService } from '@/services/project.service';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
|
||||
import { randomCredentialPayload } from '../shared/random';
|
||||
import * as testDb from '../shared/testDb';
|
||||
@ -16,13 +20,8 @@ import {
|
||||
shareCredentialWithUsers,
|
||||
} from '../shared/db/credentials';
|
||||
import { createManyUsers, createUser, createUserShell } from '../shared/db/users';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import config from '@/config';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import type { Project } from '@/databases/entities/Project';
|
||||
import { ProjectService } from '@/services/project.service';
|
||||
|
||||
const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['credentials'],
|
||||
|
@ -1,6 +1,16 @@
|
||||
import { Container } from 'typedi';
|
||||
import type { Scope } from '@sentry/node';
|
||||
import { Credentials } from 'n8n-core';
|
||||
|
||||
import type { ListQuery } from '@/requests';
|
||||
import type { User } from '@db/entities/User';
|
||||
import config from '@/config';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
import type { Project } from '@db/entities/Project';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { ProjectService } from '@/services/project.service';
|
||||
|
||||
import * as testDb from '../shared/testDb';
|
||||
import { setupTestServer } from '../shared/utils';
|
||||
import {
|
||||
@ -15,16 +25,8 @@ import {
|
||||
shareCredentialWithUsers,
|
||||
} from '../shared/db/credentials';
|
||||
import { createManyUsers, createMember, createOwner } from '../shared/db/users';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import Container from 'typedi';
|
||||
import type { Project } from '@/databases/entities/Project';
|
||||
import { createTeamProject, linkUserToProject } from '../shared/db/projects';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Credentials } from 'n8n-core';
|
||||
import type { Scope } from '@sentry/node';
|
||||
import { CredentialsRepository } from '@/databases/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@/databases/repositories/sharedCredentials.repository';
|
||||
import { ProjectService } from '@/services/project.service';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
const { any } = expect;
|
||||
|
||||
|
@ -1,15 +1,16 @@
|
||||
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
|
||||
import { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { randomName } from './shared/random';
|
||||
import { generateNanoId } from '@/databases/utils/generators';
|
||||
import type { WorkflowEntity } from '@/databases/entities/WorkflowEntity';
|
||||
import { setupTestServer } from './shared/utils';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { createOwner } from './shared/db/users';
|
||||
import { OrchestrationService } from '@/services/orchestration.service';
|
||||
import { MultiMainSetup } from '@/services/orchestration/main/MultiMainSetup.ee';
|
||||
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { randomName } from './shared/random';
|
||||
import { setupTestServer } from './shared/utils';
|
||||
import { createOwner } from './shared/db/users';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
describe('DebugController', () => {
|
||||
const workflowRepository = mockInstance(WorkflowRepository);
|
||||
const activeWorkflowManager = mockInstance(ActiveWorkflowManager);
|
||||
|
@ -1,16 +1,16 @@
|
||||
import { Container } from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
import config from '@/config';
|
||||
import { SourceControlPreferencesService } from '@/environments/sourceControl/sourceControlPreferences.service.ee';
|
||||
import { SourceControlService } from '@/environments/sourceControl/sourceControl.service.ee';
|
||||
import type { SourceControlledFile } from '@/environments/sourceControl/types/sourceControlledFile';
|
||||
import { WaitTracker } from '@/WaitTracker';
|
||||
|
||||
import * as utils from '../shared/utils/';
|
||||
import { createUser } from '../shared/db/users';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import { WaitTracker } from '@/WaitTracker';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
let owner: User;
|
||||
|
@ -3,7 +3,6 @@ import config from '@/config';
|
||||
import axios from 'axios';
|
||||
import syslog from 'syslog-client';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type {
|
||||
MessageEventBusDestinationSentryOptions,
|
||||
MessageEventBusDestinationSyslogOptions,
|
||||
@ -28,6 +27,7 @@ import { ExecutionDataRecoveryService } from '@/eventbus/executionDataRecovery.s
|
||||
import * as utils from './shared/utils';
|
||||
import { createUser } from './shared/db/users';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
jest.unmock('@/eventbus/MessageEventBus/MessageEventBus');
|
||||
jest.mock('axios');
|
||||
|
@ -1,5 +1,3 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
import { MessageEventBus } from '@/eventbus/MessageEventBus/MessageEventBus';
|
||||
import { ExecutionDataRecoveryService } from '@/eventbus/executionDataRecovery.service';
|
||||
@ -7,6 +5,7 @@ import { ExecutionDataRecoveryService } from '@/eventbus/executionDataRecovery.s
|
||||
import * as utils from './shared/utils/';
|
||||
import { createUser } from './shared/db/users';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
/**
|
||||
* NOTE: due to issues with mocking the MessageEventBus in multiple tests running in parallel,
|
||||
|
@ -1,11 +1,12 @@
|
||||
import Container from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Container } from 'typedi';
|
||||
import type { Entry as LdapUser } from 'ldapts';
|
||||
import { Not } from '@n8n/typeorm';
|
||||
import { Cipher } from 'n8n-core';
|
||||
|
||||
import config from '@/config';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { AuthProviderSyncHistoryRepository } from '@db/repositories/authProviderSyncHistory.repository';
|
||||
import { LDAP_DEFAULT_CONFIGURATION } from '@/Ldap/constants';
|
||||
import { LdapService } from '@/Ldap/ldap.service';
|
||||
import { saveLdapSynchronization } from '@/Ldap/helpers';
|
||||
@ -14,12 +15,10 @@ import { getCurrentAuthenticationMethod, setCurrentAuthenticationMethod } from '
|
||||
import { randomEmail, randomName, uniqueId } from './../shared/random';
|
||||
import * as testDb from './../shared/testDb';
|
||||
import * as utils from '../shared/utils/';
|
||||
|
||||
import { createLdapUser, createUser, getAllUsers, getLdapIdentities } from '../shared/db/users';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { AuthProviderSyncHistoryRepository } from '@db/repositories/authProviderSyncHistory.repository';
|
||||
import { getPersonalProject } from '../shared/db/projects';
|
||||
import { createLdapConfig, defaultLdapConfig } from '../shared/ldap';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
jest.mock('@/telemetry');
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import config from '@/config';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { ILicensePostResponse, ILicenseReadResponse } from '@/Interfaces';
|
||||
import { License } from '@/License';
|
||||
|
||||
import * as testDb from './shared/testDb';
|
||||
import * as utils from './shared/utils/';
|
||||
import { createUserShell } from './shared/db/users';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
const MOCK_SERVER_URL = 'https://server.com/v1';
|
||||
const MOCK_RENEW_OFFSET = 259200;
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Container } from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { IsNull } from '@n8n/typeorm';
|
||||
import validator from 'validator';
|
||||
|
||||
import config from '@/config';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
@ -18,7 +18,7 @@ import {
|
||||
import * as testDb from './shared/testDb';
|
||||
import * as utils from './shared/utils/';
|
||||
import { addApiKey, createOwner, createUser, createUserShell } from './shared/db/users';
|
||||
import config from '@/config';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
const testServer = utils.setupTestServer({ endpointGroups: ['me'] });
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
|
||||
import { randomApiKey, randomName, randomString } from '../shared/random';
|
||||
import * as utils from '../shared/utils/';
|
||||
@ -7,9 +10,7 @@ import type { CredentialPayload, SaveCredentialFunction } from '../shared/types'
|
||||
import * as testDb from '../shared/testDb';
|
||||
import { affixRoleToSaveCredential } from '../shared/db/credentials';
|
||||
import { addApiKey, createUser, createUserShell } from '../shared/db/users';
|
||||
import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||
import Container from 'typedi';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let owner: User;
|
||||
let member: User;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
||||
|
||||
@ -17,6 +16,7 @@ import {
|
||||
createSuccessfulExecution,
|
||||
createWaitingExecution,
|
||||
} from '../shared/db/executions';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let owner: User;
|
||||
let user1: User;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import Container from 'typedi';
|
||||
import { Container } from 'typedi';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { TagRepository } from '@db/repositories/tag.repository';
|
||||
|
||||
@ -8,6 +7,7 @@ import * as utils from '../shared/utils/';
|
||||
import * as testDb from '../shared/testDb';
|
||||
import { createUser } from '../shared/db/users';
|
||||
import { createTag } from '../shared/db/tags';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let owner: User;
|
||||
let member: User;
|
||||
|
@ -1,4 +1,3 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import validator from 'validator';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
@ -9,6 +8,7 @@ import { randomApiKey } from '../shared/random';
|
||||
import * as utils from '../shared/utils/';
|
||||
import * as testDb from '../shared/testDb';
|
||||
import { createUser, createUserShell } from '../shared/db/users';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
mockInstance(License, {
|
||||
getUsersLimit: jest.fn().mockReturnValue(-1),
|
||||
|
@ -1,10 +1,12 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import config from '@/config';
|
||||
import Container from 'typedi';
|
||||
import { Container } from 'typedi';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
|
||||
import config from '@/config';
|
||||
import { STARTING_NODES } from '@/constants';
|
||||
import type { TagEntity } from '@db/entities/TagEntity';
|
||||
import type { User } from '@db/entities/User';
|
||||
import type { Project } from '@db/entities/Project';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
|
||||
import { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
||||
@ -17,8 +19,7 @@ import { createUser } from '../shared/db/users';
|
||||
import { createWorkflow, createWorkflowWithTrigger } from '../shared/db/workflows';
|
||||
import { createTag } from '../shared/db/tags';
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import type { Project } from '@/databases/entities/Project';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let owner: User;
|
||||
let ownerPersonalProject: Project;
|
||||
|
@ -1,13 +1,15 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Container } from 'typedi';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
|
||||
import type { GlobalRole } from '@db/entities/User';
|
||||
import type { ProjectRole } from '@db/entities/ProjectRelation';
|
||||
import type { CredentialSharingRole } from '@db/entities/SharedCredentials';
|
||||
import type { WorkflowSharingRole } from '@db/entities/SharedWorkflow';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
|
||||
import * as utils from './shared/utils/';
|
||||
import { createMember } from './shared/db/users';
|
||||
import type { GlobalRole } from '@/databases/entities/User';
|
||||
import type { ProjectRole } from '@/databases/entities/ProjectRelation';
|
||||
import type { CredentialSharingRole } from '@/databases/entities/SharedCredentials';
|
||||
import type { WorkflowSharingRole } from '@/databases/entities/SharedWorkflow';
|
||||
import { RoleService } from '@/services/role.service';
|
||||
import Container from 'typedi';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
const testServer = utils.setupTestServer({
|
||||
endpointGroups: ['role'],
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Container } from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type { AuthenticationMethod } from 'n8n-workflow';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
import { setSamlLoginEnabled } from '@/sso/saml/samlHelpers';
|
||||
import { getCurrentAuthenticationMethod, setCurrentAuthenticationMethod } from '@/sso/ssoHelpers';
|
||||
@ -12,6 +12,7 @@ import { randomEmail, randomName, randomValidPassword } from '../shared/random';
|
||||
import * as utils from '../shared/utils/';
|
||||
import { sampleConfig } from './sampleMetadata';
|
||||
import { createOwner, createUser } from '../shared/db/users';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let someUser: User;
|
||||
let owner: User;
|
||||
|
@ -1,10 +0,0 @@
|
||||
import superagent = require('superagent');
|
||||
|
||||
/**
|
||||
* Make `SuperTest<T>` string-indexable.
|
||||
*/
|
||||
declare module 'supertest' {
|
||||
interface SuperTest<T extends superagent.SuperAgentRequest>
|
||||
extends superagent.SuperAgent<T>,
|
||||
Record<string, any> {}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import type { Application } from 'express';
|
||||
import type { ICredentialDataDecryptedObject } from 'n8n-workflow';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type TestAgent from 'supertest/lib/agent';
|
||||
import type { Server } from 'http';
|
||||
|
||||
import type { CredentialsEntity } from '@db/entities/CredentialsEntity';
|
||||
@ -44,12 +44,14 @@ export interface SetupProps {
|
||||
quotas?: Partial<{ [K in NumericLicenseFeature]: number }>;
|
||||
}
|
||||
|
||||
export type SuperAgentTest = TestAgent;
|
||||
|
||||
export interface TestServer {
|
||||
app: Application;
|
||||
httpServer: Server;
|
||||
authAgentFor: (user: User) => SuperAgentTest;
|
||||
publicApiAgentFor: (user: User) => SuperAgentTest;
|
||||
authlessAgent: SuperAgentTest;
|
||||
authAgentFor: (user: User) => TestAgent;
|
||||
publicApiAgentFor: (user: User) => TestAgent;
|
||||
authlessAgent: TestAgent;
|
||||
license: LicenseMocker;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
import { Container } from 'typedi';
|
||||
|
||||
import { TagRepository } from '@db/repositories/tag.repository';
|
||||
|
||||
import * as utils from './shared/utils/';
|
||||
import * as testDb from './shared/testDb';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { TagRepository } from '@db/repositories/tag.repository';
|
||||
import Container from 'typedi';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
import { createUserShell } from './shared/db/users';
|
||||
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
|
@ -1,11 +1,15 @@
|
||||
import Container from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import { UsersController } from '@/controllers/users.controller';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
import { ProjectRelationRepository } from '@db/repositories/projectRelation.repository';
|
||||
import { UserRepository } from '@db/repositories/user.repository';
|
||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
import { CacheService } from '@/services/cache/cache.service';
|
||||
import { ExecutionService } from '@/executions/execution.service';
|
||||
|
||||
import {
|
||||
@ -21,12 +25,8 @@ import { randomCredentialPayload } from './shared/random';
|
||||
import * as utils from './shared/utils/';
|
||||
import * as testDb from './shared/testDb';
|
||||
import { mockInstance } from '../shared/mocking';
|
||||
import { RESPONSE_ERROR_MESSAGES } from '@/constants';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
import { createTeamProject, getPersonalProject, linkUserToProject } from './shared/db/projects';
|
||||
import { ProjectRelationRepository } from '@/databases/repositories/projectRelation.repository';
|
||||
import { CacheService } from '@/services/cache/cache.service';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
mockInstance(ExecutionService);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Container from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { Container } from 'typedi';
|
||||
|
||||
import type { Variables } from '@db/entities/Variables';
|
||||
import { VariablesRepository } from '@db/repositories/variables.repository';
|
||||
import { generateNanoId } from '@db/utils/generators';
|
||||
@ -8,6 +8,7 @@ import { VariablesService } from '@/environments/variables/variables.service.ee'
|
||||
import * as testDb from './shared/testDb';
|
||||
import * as utils from './shared/utils/';
|
||||
import { createOwner, createUser } from './shared/db/users';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
let authMemberAgent: SuperAgentTest;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { agent as testAgent } from 'supertest';
|
||||
import type { INodeType, INodeTypeDescription, IWebhookFunctions } from 'n8n-workflow';
|
||||
|
||||
@ -15,6 +14,7 @@ import { initActiveWorkflowManager } from './shared/utils';
|
||||
import * as testDb from './shared/testDb';
|
||||
import { createUser } from './shared/db/users';
|
||||
import { createWorkflow } from './shared/db/workflows';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
describe('Webhook API', () => {
|
||||
mockInstance(ExternalHooks);
|
||||
|
@ -1,4 +1,3 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type { User } from '@db/entities/User';
|
||||
|
||||
import * as testDb from './shared/testDb';
|
||||
@ -6,6 +5,7 @@ import * as utils from './shared/utils/';
|
||||
import { createOwner, createUser } from './shared/db/users';
|
||||
import { createWorkflow } from './shared/db/workflows';
|
||||
import { createWorkflowHistoryItem } from './shared/db/workflowHistory';
|
||||
import type { SuperAgentTest } from './shared/types';
|
||||
|
||||
let owner: User;
|
||||
let authOwnerAgent: SuperAgentTest;
|
||||
|
@ -1,11 +1,16 @@
|
||||
import Container from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import type { INode } from 'n8n-workflow';
|
||||
|
||||
import config from '@/config';
|
||||
import type { Project } from '@db/entities/Project';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
import type { User } from '@db/entities/User';
|
||||
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
|
||||
import { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
||||
import { License } from '@/License';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/workflows/workflows.types';
|
||||
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import * as utils from '../shared/utils/';
|
||||
@ -16,13 +21,8 @@ import { randomCredentialPayload } from '../shared/random';
|
||||
import { affixRoleToSaveCredential, shareCredentialWithUsers } from '../shared/db/credentials';
|
||||
import { createUser, createUserShell } from '../shared/db/users';
|
||||
import { createWorkflow, getWorkflowSharing, shareWorkflowWithUsers } from '../shared/db/workflows';
|
||||
import { License } from '@/License';
|
||||
import { UserManagementMailer } from '@/UserManagement/email';
|
||||
import config from '@/config';
|
||||
import type { WorkflowWithSharingsMetaDataAndCredentials } from '@/workflows/workflows.types';
|
||||
import type { Project } from '@/databases/entities/Project';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { createTag } from '../shared/db/tags';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let owner: User;
|
||||
let ownerPersonalProject: Project;
|
||||
|
@ -1,15 +1,19 @@
|
||||
import Container from 'typedi';
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
import type { INode, IPinData } from 'n8n-workflow';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
|
||||
import type { User } from '@db/entities/User';
|
||||
import { WorkflowRepository } from '@db/repositories/workflow.repository';
|
||||
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
|
||||
import type { ListQuery } from '@/requests';
|
||||
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
|
||||
import { SharedWorkflowRepository } from '@db/repositories/sharedWorkflow.repository';
|
||||
import { ProjectRepository } from '@db/repositories/project.repository';
|
||||
import { ProjectService } from '@/services/project.service';
|
||||
import { ActiveWorkflowManager } from '@/ActiveWorkflowManager';
|
||||
import { EnterpriseWorkflowService } from '@/workflows/workflow.service.ee';
|
||||
import { License } from '@/License';
|
||||
|
||||
import { mockInstance } from '../../shared/mocking';
|
||||
import * as utils from '../shared/utils/';
|
||||
@ -20,12 +24,8 @@ import { saveCredential } from '../shared/db/credentials';
|
||||
import { createManyUsers, createMember, createOwner } from '../shared/db/users';
|
||||
import { createWorkflow, shareWorkflowWithProjects } from '../shared/db/workflows';
|
||||
import { createTag } from '../shared/db/tags';
|
||||
import { License } from '@/License';
|
||||
import { SharedWorkflowRepository } from '@/databases/repositories/sharedWorkflow.repository';
|
||||
import { ProjectRepository } from '@/databases/repositories/project.repository';
|
||||
import { ProjectService } from '@/services/project.service';
|
||||
import { createTeamProject, linkUserToProject } from '../shared/db/projects';
|
||||
import type { Scope } from '@n8n/permissions';
|
||||
import type { SuperAgentTest } from '../shared/types';
|
||||
|
||||
let owner: User;
|
||||
let member: User;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type { SuperAgentTest } from 'supertest';
|
||||
import type SuperAgentTest from 'supertest/lib/agent';
|
||||
import { agent as testAgent } from 'supertest';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
|
@ -111,8 +111,8 @@ importers:
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
supertest:
|
||||
specifier: ^6.3.4
|
||||
version: 6.3.4
|
||||
specifier: ^7.0.0
|
||||
version: 7.0.0
|
||||
ts-jest:
|
||||
specifier: ^29.1.1
|
||||
version: 29.1.1(@babel/core@7.24.0)(jest@29.6.2)(typescript@5.4.2)
|
||||
@ -838,8 +838,8 @@ importers:
|
||||
specifier: ^1.17.1
|
||||
version: 1.17.1
|
||||
'@types/superagent':
|
||||
specifier: ^8.1.4
|
||||
version: 8.1.4
|
||||
specifier: ^8.1.7
|
||||
version: 8.1.7
|
||||
'@types/swagger-ui-express':
|
||||
specifier: ^4.1.6
|
||||
version: 4.1.6
|
||||
@ -10986,8 +10986,8 @@ packages:
|
||||
resolution: {integrity: sha512-n4sx2bqL0mW1tvDf/loQ+aMX7GQD3lc3fkCMC55VFNDu/vBOabO+LTIeXKM14xK0ppk5TUGcWRjiSpIlUpghKw==}
|
||||
dev: true
|
||||
|
||||
/@types/superagent@8.1.4:
|
||||
resolution: {integrity: sha512-uzSBYwrpal8y2X2Pul5ZSWpzRiDha2FLcquaN95qUPnOjYgm/zQ5LIdqeJpQJTRWNTN+Rhm0aC8H06Ds2rqCYw==}
|
||||
/@types/superagent@8.1.7:
|
||||
resolution: {integrity: sha512-NmIsd0Yj4DDhftfWvvAku482PZum4DBW7U51OvS8gvOkDDY0WT1jsVyDV3hK+vplrsYw8oDwi9QxOM7U68iwww==}
|
||||
dependencies:
|
||||
'@types/cookiejar': 2.1.5
|
||||
'@types/methods': 1.1.4
|
||||
@ -10998,7 +10998,7 @@ packages:
|
||||
resolution: {integrity: sha512-137ypx2lk/wTQbW6An6safu9hXmajAifU/s7szAHLN/FeIm5w7yR0Wkl9fdJMRSHwOn4HLAI0DaB2TOORuhPDg==}
|
||||
dependencies:
|
||||
'@types/methods': 1.1.4
|
||||
'@types/superagent': 8.1.4
|
||||
'@types/superagent': 8.1.7
|
||||
dev: true
|
||||
|
||||
/@types/swagger-ui-express@4.1.6:
|
||||
@ -23795,9 +23795,9 @@ packages:
|
||||
ts-interface-checker: 0.1.13
|
||||
dev: true
|
||||
|
||||
/superagent@8.1.2:
|
||||
resolution: {integrity: sha512-6WTxW1EB6yCxV5VFOIPQruWGHqc3yI7hEmZK6h+pyk69Lk/Ut7rLUY6W/ONF2MjBuGjvmMiIpsrVJ2vjrHlslA==}
|
||||
engines: {node: '>=6.4.0 <13 || >=14'}
|
||||
/superagent@9.0.2:
|
||||
resolution: {integrity: sha512-xuW7dzkUpcJq7QnhOsnNUgtYp3xRwpt2F7abdRYIpCsAt0hhUqia0EdxyXZQQpNmGtsCzYHryaKSV3q3GJnq7w==}
|
||||
engines: {node: '>=14.18.0'}
|
||||
dependencies:
|
||||
component-emitter: 1.3.0
|
||||
cookiejar: 2.1.4
|
||||
@ -23808,17 +23808,16 @@ packages:
|
||||
methods: 1.1.2
|
||||
mime: 2.6.0
|
||||
qs: 6.11.0
|
||||
semver: 7.6.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/supertest@6.3.4:
|
||||
resolution: {integrity: sha512-erY3HFDG0dPnhw4U+udPfrzXa4xhSG+n4rxfRuZWCUvjFWwKl+OxWf/7zk50s84/fAAs7vf5QAb9uRa0cCykxw==}
|
||||
engines: {node: '>=6.4.0'}
|
||||
/supertest@7.0.0:
|
||||
resolution: {integrity: sha512-qlsr7fIC0lSddmA3tzojvzubYxvlGtzumcdHgPwbFWMISQwL22MhM2Y3LNt+6w9Yyx7559VW5ab70dgphm8qQA==}
|
||||
engines: {node: '>=14.18.0'}
|
||||
dependencies:
|
||||
methods: 1.1.2
|
||||
superagent: 8.1.2
|
||||
superagent: 9.0.2
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
Loading…
Reference in New Issue
Block a user