refactor: Use string ids on Credentials, Workflows, Tags, and Executions DB entities (#5041)
This commit is contained in:
committed by
GitHub
parent
8bee04cd2a
commit
ee28213538
@@ -351,7 +351,7 @@ test('GET /credentials/:id should return 404 if cred not found', async () => {
|
||||
expect(response.statusCode).toBe(404);
|
||||
|
||||
const responseAbc = await authAgent(ownerShell).get('/credentials/abc');
|
||||
expect(responseAbc.statusCode).toBe(400);
|
||||
expect(responseAbc.statusCode).toBe(404);
|
||||
|
||||
// because EE router has precedence, check if forwards this route
|
||||
const responseNew = await authAgent(ownerShell).get('/credentials/new');
|
||||
|
||||
@@ -81,7 +81,7 @@ test('GET /credentials should return all creds for owner', async () => {
|
||||
response.body.data.forEach((credential: CredentialsEntity) => {
|
||||
validateMainCredentialData(credential);
|
||||
expect(credential.data).toBeUndefined();
|
||||
expect(savedCredentialsIds.includes(Number(credential.id))).toBe(true);
|
||||
expect(savedCredentialsIds).toContain(credential.id);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ test('GET /credentials should return only own creds for member', async () => {
|
||||
|
||||
validateMainCredentialData(member1Credential);
|
||||
expect(member1Credential.data).toBeUndefined();
|
||||
expect(member1Credential.id).toBe(savedCredential1.id.toString());
|
||||
expect(member1Credential.id).toBe(savedCredential1.id);
|
||||
});
|
||||
|
||||
test('POST /credentials should create cred', async () => {
|
||||
@@ -573,16 +573,11 @@ test('GET /credentials/:id should fail with missing encryption key', async () =>
|
||||
|
||||
test('GET /credentials/:id should return 404 if cred not found', async () => {
|
||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||
|
||||
const response = await authAgent(ownerShell).get('/credentials/789');
|
||||
expect(response.statusCode).toBe(404);
|
||||
});
|
||||
|
||||
test('GET /credentials/:id should return 400 if id is not a number', async () => {
|
||||
const ownerShell = await testDb.createUserShell(globalOwnerRole);
|
||||
|
||||
const responseAbc = await authAgent(ownerShell).get('/credentials/abc');
|
||||
expect(responseAbc.statusCode).toBe(400);
|
||||
expect(responseAbc.statusCode).toBe(404);
|
||||
});
|
||||
|
||||
function validateMainCredentialData(credential: CredentialsEntity) {
|
||||
|
||||
@@ -463,7 +463,7 @@ test('GET /executions should retrieve all executions of specific workflow', asyn
|
||||
await testDb.createManyExecutions(2, workflow2, testDb.createSuccessfulExecution);
|
||||
|
||||
const response = await authOwnerAgent.get(`/executions`).query({
|
||||
workflowId: workflow.id.toString(),
|
||||
workflowId: workflow.id,
|
||||
});
|
||||
|
||||
expect(response.statusCode).toBe(200);
|
||||
@@ -490,7 +490,7 @@ test('GET /executions should retrieve all executions of specific workflow', asyn
|
||||
expect(retryOf).toBeNull();
|
||||
expect(startedAt).not.toBeNull();
|
||||
expect(stoppedAt).not.toBeNull();
|
||||
expect(workflowId).toBe(workflow.id.toString());
|
||||
expect(workflowId).toBe(workflow.id);
|
||||
expect(waitTill).toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -195,7 +195,7 @@ test('GET /workflows should return all owned workflows with pagination', async (
|
||||
}
|
||||
|
||||
// check that we really received a different result
|
||||
expect(response.body.data[0].id).toBeLessThan(response2.body.data[0].id);
|
||||
expect(Number(response.body.data[0].id)).toBeLessThan(Number(response2.body.data[0].id));
|
||||
});
|
||||
|
||||
test('GET /workflows should return all owned workflows filtered by tag', async () => {
|
||||
@@ -690,7 +690,7 @@ test('POST /workflows/:id/activate should set workflow as active', async () => {
|
||||
expect(sharedWorkflow?.workflow.active).toBe(true);
|
||||
|
||||
// check whether the workflow is on the active workflow runner
|
||||
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(true);
|
||||
expect(await workflowRunner.isActive(workflow.id)).toBe(true);
|
||||
});
|
||||
|
||||
test('POST /workflows/:id/activate should set non-owned workflow as active when owner', async () => {
|
||||
@@ -744,7 +744,7 @@ test('POST /workflows/:id/activate should set non-owned workflow as active when
|
||||
expect(sharedWorkflow?.workflow.active).toBe(true);
|
||||
|
||||
// check whether the workflow is on the active workflow runner
|
||||
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(true);
|
||||
expect(await workflowRunner.isActive(workflow.id)).toBe(true);
|
||||
});
|
||||
|
||||
test('POST /workflows/:id/deactivate should fail due to missing API Key', async () => {
|
||||
@@ -835,7 +835,7 @@ test('POST /workflows/:id/deactivate should deactivate workflow', async () => {
|
||||
// check whether the workflow is deactivated in the database
|
||||
expect(sharedWorkflow?.workflow.active).toBe(false);
|
||||
|
||||
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(false);
|
||||
expect(await workflowRunner.isActive(workflow.id)).toBe(false);
|
||||
});
|
||||
|
||||
test('POST /workflows/:id/deactivate should deactivate non-owned workflow when owner', async () => {
|
||||
@@ -888,7 +888,7 @@ test('POST /workflows/:id/deactivate should deactivate non-owned workflow when o
|
||||
|
||||
expect(sharedWorkflow?.workflow.active).toBe(false);
|
||||
|
||||
expect(await workflowRunner.isActive(workflow.id.toString())).toBe(false);
|
||||
expect(await workflowRunner.isActive(workflow.id)).toBe(false);
|
||||
});
|
||||
|
||||
test('POST /workflows should fail due to missing API Key', async () => {
|
||||
|
||||
@@ -474,7 +474,7 @@ export async function createExecution(
|
||||
finished: finished ?? true,
|
||||
mode: mode ?? 'manual',
|
||||
startedAt: startedAt ?? new Date(),
|
||||
...(workflow !== undefined && { workflowData: workflow, workflowId: workflow.id.toString() }),
|
||||
...(workflow !== undefined && { workflowData: workflow, workflowId: workflow.id }),
|
||||
stoppedAt: stoppedAt ?? new Date(),
|
||||
waitTill: waitTill ?? null,
|
||||
});
|
||||
|
||||
@@ -180,7 +180,7 @@ describe('GET /workflows', () => {
|
||||
position: [0, 0],
|
||||
credentials: {
|
||||
actionNetworkApi: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -220,7 +220,7 @@ describe('GET /workflows', () => {
|
||||
const [usedCredential] = fetchedWorkflow.usedCredentials;
|
||||
|
||||
expect(usedCredential).toMatchObject({
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
type: savedCredential.type,
|
||||
currentUserHasAccess: true,
|
||||
@@ -313,7 +313,7 @@ describe('GET /workflows/:id', () => {
|
||||
|
||||
const workflowPayload = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
const workflow = await createWorkflow(workflowPayload, owner);
|
||||
|
||||
@@ -322,7 +322,7 @@ describe('GET /workflows/:id', () => {
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.body.data.usedCredentials).toMatchObject([
|
||||
{
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: true,
|
||||
},
|
||||
@@ -338,7 +338,7 @@ describe('GET /workflows/:id', () => {
|
||||
|
||||
const workflowPayload = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
const workflow = await createWorkflow(workflowPayload, owner);
|
||||
|
||||
@@ -347,7 +347,7 @@ describe('GET /workflows/:id', () => {
|
||||
expect(response.statusCode).toBe(200);
|
||||
expect(response.body.data.usedCredentials).toMatchObject([
|
||||
{
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: false, // although owner can see, he does not have access
|
||||
},
|
||||
@@ -363,7 +363,7 @@ describe('GET /workflows/:id', () => {
|
||||
|
||||
const workflowPayload = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
const workflow = await createWorkflow(workflowPayload, member1);
|
||||
await testDb.shareWorkflowWithUsers(workflow, [member2]);
|
||||
@@ -372,7 +372,7 @@ describe('GET /workflows/:id', () => {
|
||||
expect(responseMember1.statusCode).toBe(200);
|
||||
expect(responseMember1.body.data.usedCredentials).toMatchObject([
|
||||
{
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: true, // one user has access
|
||||
},
|
||||
@@ -383,7 +383,7 @@ describe('GET /workflows/:id', () => {
|
||||
expect(responseMember2.statusCode).toBe(200);
|
||||
expect(responseMember2.body.data.usedCredentials).toMatchObject([
|
||||
{
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: false, // the other one doesn't
|
||||
},
|
||||
@@ -400,7 +400,7 @@ describe('GET /workflows/:id', () => {
|
||||
|
||||
const workflowPayload = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
const workflow = await createWorkflow(workflowPayload, member1);
|
||||
await testDb.shareWorkflowWithUsers(workflow, [member2]);
|
||||
@@ -409,7 +409,7 @@ describe('GET /workflows/:id', () => {
|
||||
expect(responseMember1.statusCode).toBe(200);
|
||||
expect(responseMember1.body.data.usedCredentials).toMatchObject([
|
||||
{
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: true,
|
||||
},
|
||||
@@ -420,7 +420,7 @@ describe('GET /workflows/:id', () => {
|
||||
expect(responseMember2.statusCode).toBe(200);
|
||||
expect(responseMember2.body.data.usedCredentials).toMatchObject([
|
||||
{
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
currentUserHasAccess: true,
|
||||
},
|
||||
@@ -446,7 +446,7 @@ describe('POST /workflows', () => {
|
||||
const savedCredential = await saveCredential(randomCredentialPayload(), { user: owner });
|
||||
const workflow = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
|
||||
const response = await authAgent(owner).post('/workflows').send(workflow);
|
||||
@@ -462,7 +462,7 @@ describe('POST /workflows', () => {
|
||||
const savedCredential = await saveCredential(randomCredentialPayload(), { user: owner });
|
||||
const workflow = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
|
||||
const response = await authAgent(member).post('/workflows').send(workflow);
|
||||
@@ -481,7 +481,7 @@ describe('POST /workflows', () => {
|
||||
const savedCredential = await saveCredential(randomCredentialPayload(), { user: member });
|
||||
const workflow = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
|
||||
const response = await authAgent(owner).post('/workflows').send(workflow);
|
||||
@@ -498,7 +498,7 @@ describe('POST /workflows', () => {
|
||||
|
||||
const workflow = makeWorkflow({
|
||||
withPinData: false,
|
||||
withCredential: { id: savedCredential.id.toString(), name: savedCredential.name },
|
||||
withCredential: { id: savedCredential.id, name: savedCredential.name },
|
||||
});
|
||||
|
||||
const response = await authAgent(member2).post('/workflows').send(workflow);
|
||||
@@ -525,7 +525,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -563,7 +563,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -588,7 +588,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -619,7 +619,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -653,7 +653,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -682,7 +682,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
@@ -721,7 +721,7 @@ describe('PATCH /workflows/:id - validate credential permissions to user', () =>
|
||||
typeVersion: 1,
|
||||
credentials: {
|
||||
default: {
|
||||
id: savedCredential.id.toString(),
|
||||
id: savedCredential.id,
|
||||
name: savedCredential.name,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user