n8n/packages/cli/test/integration/environments/VersionControl.test.ts
Michael Auerswald 71ed1f410c
feat(core): Add SSH key generation (#6006)
* basic prefs and ssh key generation

* review change

* cleanup save

* lint fix
2023-04-19 17:46:10 +02:00

39 lines
1.2 KiB
TypeScript

import { Container } from 'typedi';
import type { SuperAgentTest } from 'supertest';
import type { User } from '@db/entities/User';
import { License } from '@/License';
import * as testDb from '../shared/testDb';
import * as utils from '../shared/utils';
import { VersionControlService } from '../../../src/environments/versionControl/versionControl.service.ee';
let owner: User;
let authOwnerAgent: SuperAgentTest;
beforeAll(async () => {
Container.get(License).isVersionControlLicensed = () => true;
const app = await utils.initTestServer({ endpointGroups: ['versionControl'] });
owner = await testDb.createOwner();
authOwnerAgent = utils.createAuthAgent(app)(owner);
});
afterAll(async () => {
await testDb.terminate();
});
describe('GET /versionControl/preferences', () => {
test('should return Version Control preferences', async () => {
await Container.get(VersionControlService).generateAndSaveKeyPair();
await authOwnerAgent
.get('/versionControl/preferences')
.expect(200)
.expect((res) => {
return (
'privateKey' in res.body &&
'publicKey' in res.body &&
res.body.publicKey.includes('ssh-ed25519') &&
res.body.privateKey.includes('BEGIN OPENSSH PRIVATE KEY')
);
});
});
});