Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 9 additions & 54 deletions backend/src/helpers/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,32 +164,6 @@ export const Constants = {
isTestConnection: true,
},

TEST_CONNECTION_TO_MSSQL: {
title: 'MSSQL',
masterEncryption: false,
type: ConnectionTypesEnum.mssql,
host: appConfig.testDb.mssql.host,
port: appConfig.testDb.mssql.port,
password: appConfig.testDb.mssql.password,
username: appConfig.testDb.mssql.username,
database: appConfig.testDb.mssql.database,
ssh: false,
ssl: false,
isTestConnection: true,
},

TEST_CONNECTION_TO_ORACLE: {
title: 'Oracle',
type: ConnectionTypesEnum.oracledb,
host: appConfig.testDb.oracle.host,
port: appConfig.testDb.oracle.port,
username: appConfig.testDb.oracle.username,
password: appConfig.testDb.oracle.password,
database: appConfig.testDb.oracle.database,
sid: appConfig.testDb.oracle.sid,
isTestConnection: true,
},

TEST_SSH_CONNECTION_TO_MYSQL: {
title: 'MySQL',
type: ConnectionTypesEnum.mysql,
Expand All @@ -206,30 +180,6 @@ export const Constants = {
privateSSHKey: appConfig.testDb.mysql.sshKey,
},

TEST_CONNECTION_TO_MONGO: {
title: 'MongoDB',
type: ConnectionTypesEnum.mongodb,
host: appConfig.testDb.mongo.host,
port: appConfig.testDb.mongo.port,
username: appConfig.testDb.mongo.username,
password: appConfig.testDb.mongo.password,
database: appConfig.testDb.mongo.database,
authSource: appConfig.testDb.mongo.authSource,
isTestConnection: true,
},

TEST_CONNECTION_TO_IBMBD2: {
title: 'IBM DB2',
type: ConnectionTypesEnum.ibmdb2,
host: appConfig.testDb.ibmdb2.host,
port: appConfig.testDb.ibmdb2.port,
username: appConfig.testDb.ibmdb2.username,
password: appConfig.testDb.ibmdb2.password,
database: appConfig.testDb.ibmdb2.database,
schema: appConfig.testDb.ibmdb2.schema,
isTestConnection: true,
},

REMOVED_PASSWORD_VALUE: '***',
REMOVED_SENSITIVE_FIELD_IF_CHANGED: '* * * sensitive data, no logs stored * * *',
REMOVED_SENSITIVE_FIELD_IF_NOT_CHANGED: '',
Expand All @@ -242,19 +192,24 @@ export const Constants = {
const testConnections: Array<CreateConnectionDto | null> = Constants.getTestConnectionsFromDSN() || [];
if (!testConnections.length) {
testConnections.push(
Constants.TEST_CONNECTION_TO_ORACLE as CreateConnectionDto,
Constants.TEST_CONNECTION_TO_POSTGRES as CreateConnectionDto,
Constants.TEST_SSH_CONNECTION_TO_MYSQL as unknown as CreateConnectionDto,
Constants.TEST_CONNECTION_TO_MSSQL as CreateConnectionDto,
Constants.TEST_CONNECTION_TO_MONGO as CreateConnectionDto,
Constants.TEST_CONNECTION_TO_IBMBD2 as CreateConnectionDto,
);
}

// Only MySQL and Postgres are provided as test connections for registered users.
const allowedTestConnectionTypes: Array<ConnectionTypesEnum> = [
ConnectionTypesEnum.mysql,
ConnectionTypesEnum.postgres,
];
Comment on lines +200 to +204

return testConnections.filter((dto): dto is CreateConnectionDto => {
if (!dto) {
return false;
}
if (!allowedTestConnectionTypes.includes(dto.type)) {
return false;
}
const values = Object.values(dto);
const nullElementIndex = values.indexOf(null);
return nullElementIndex < 0;
Expand Down
4 changes: 2 additions & 2 deletions backend/test/ava-tests/saas-tests/company-info-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ test.serial(

const result = foundUserTestConnectionsInfo.body.connections;

t.is(result.length, 5);
t.is(result.length, 3);

// toggle to off
const toggleTestConnectionsResponse = await request(app.getHttpServer())
Expand Down Expand Up @@ -1171,7 +1171,7 @@ test.serial(
const resultAfterToggleOnRO = JSON.parse(resultAfterToggleOn.text);

t.is(resultAfterToggleOn.status, 200);
t.is(resultAfterToggleOnRO.connections.length, 5);
t.is(resultAfterToggleOnRO.connections.length, 3);
},
);

Expand Down
9 changes: 4 additions & 5 deletions backend/test/ava-tests/saas-tests/connection-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test.serial(`${currentTest} should return all connections for this user`, async
.set('Accept', 'application/json');

t.is(findAllConnectionsResponse.status, 200);
t.is(findAllConnectionsResponse.body.connections.length, 4);
t.is(findAllConnectionsResponse.body.connections.length, 2);

let createConnectionResult = await request(app.getHttpServer())
.post('/connection')
Expand Down Expand Up @@ -117,13 +117,12 @@ test.serial(`${currentTest} should return all connections for this user`, async

const result = findAll.body.connections;

t.is(result.length, 6);
t.is(result.length, 4);
t.is(Object.hasOwn(result[0], 'connection'), true);
t.is(Object.hasOwn(result[1], 'accessLevel'), true);
t.is(result[2].accessLevel, AccessLevelEnum.edit);

t.is(Object.hasOwn(result[3], 'accessLevel'), true);
t.is(Object.hasOwn(result[4].connection, 'host'), true);
t.is(Object.hasOwn(result[3].connection, 'host'), true);
t.is(typeof result[0].connection.port, 'number');
t.is(Object.hasOwn(result[2].connection, 'username'), true);
Expand All @@ -132,9 +131,9 @@ test.serial(`${currentTest} should return all connections for this user`, async
t.is(Object.hasOwn(result[1].connection, 'updatedAt'), true);
t.is(Object.hasOwn(result[2].connection, 'password'), false);
t.is(Object.hasOwn(result[3].connection, 'groups'), false);
const oracleConnectionIndex = result.findIndex((e) => e.connection.type === ConnectionTypesEnum.oracledb);
const mysqlConnectionIndex = result.findIndex((e) => e.connection.type === ConnectionTypesEnum.mysql);
// eslint-disable-next-line security/detect-object-injection
t.is(Object.hasOwn(result[oracleConnectionIndex].connection, 'sid'), true);
t.is(Object.hasOwn(result[mysqlConnectionIndex].connection, 'host'), true);
Comment on lines +134 to +136
t.pass();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test.serial(`${currentTest} should return connections, where second user have ac
t.is(findAll.status, 200);

const result = findAll.body.connections;
t.is(result.length, 5);
t.is(result.length, 3);
t.is(Object.hasOwn(result[0], 'connection'), true);
t.is(Object.hasOwn(result[0], 'accessLevel'), true);
t.is(result[0].accessLevel, AccessLevelEnum.edit);
Expand All @@ -95,7 +95,7 @@ test.serial(`${currentTest} should return connections, where second user have ac
t.is(Object.hasOwn(result[0].connection, 'groups'), false);
t.is(Object.hasOwn(result[0].connection, 'author'), false);
const testConnectionsCount = result.filter((el: any) => el.connection.isTestConnection).length;
t.is(testConnectionsCount, 4);
t.is(testConnectionsCount, 2);
} catch (error) {
console.error(error);
throw error;
Expand Down
6 changes: 3 additions & 3 deletions backend/test/ava-tests/saas-tests/user-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ test.serial(`${currentTest} should toggle test connections display mode`, async
const getUserConnectionsRO = JSON.parse(getUserConnectionsResult.text);
t.is(getUserConnectionsResult.status, 200);
t.is(Object.hasOwn(getUserConnectionsRO, 'connections'), true);
t.is(getUserConnectionsRO.connections.length, 4);
t.is(getUserConnectionsRO.connections.length, 2);

const toggleTestConnectionsDisplayModeResult = await request(app.getHttpServer())
.put('/user/test/connections/display/?displayMode=off')
Expand Down Expand Up @@ -448,7 +448,7 @@ test.serial(`${currentTest} should register demo user`, async (t) => {
const getUserConnectionsRO = JSON.parse(getUserConnectionsResult.text);
t.is(getUserConnectionsResult.status, 200);
t.is(Object.hasOwn(getUserConnectionsRO, 'connections'), true);
t.is(getUserConnectionsRO.connections.length, 4);
t.is(getUserConnectionsRO.connections.length, 2);

//check user can add connection and use it

Expand Down Expand Up @@ -512,7 +512,7 @@ test.serial(`${currentTest} should register demo user`, async (t) => {
t.is(getUserCompanyRO.show_test_connections, true);
t.is(Object.hasOwn(getUserCompanyRO, 'connections'), true);
t.true(Array.isArray(getUserCompanyRO.connections));
t.is(getUserCompanyRO.connections.length, 5);
t.is(getUserCompanyRO.connections.length, 3);

for (const connection of getUserCompanyRO.connections) {
t.is(typeof connection.id, 'string');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ test.serial(`${currentTest} should return connections, where second user have ac
t.is(findAll.status, 200);

const result = findAll.body.connections;
t.is(result.length, 5);
t.is(result.length, 3);
t.is(Object.hasOwn(result[0], 'connection'), true);
t.is(Object.hasOwn(result[0], 'accessLevel'), true);

Expand All @@ -114,7 +114,7 @@ test.serial(`${currentTest} should return connections, where second user have ac
t.is(Object.hasOwn(result[0].connection, 'groups'), false);
t.is(Object.hasOwn(result[0].connection, 'author'), false);
const testConnectionsCount = result.filter((el: any) => el.connection.isTestConnection).length;
t.is(testConnectionsCount, 4);
t.is(testConnectionsCount, 2);
} catch (e) {
console.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ test.serial(`${currentTest} should return connections, where second user have ac

const result = findAll.body.connections;
const nonTestConnection = result.find(({ connection }) => connection.id === connections.firstId);
t.is(result.length, 5);
t.is(result.length, 3);
t.is(Object.hasOwn(nonTestConnection, 'connection'), true);
t.is(Object.hasOwn(nonTestConnection, 'accessLevel'), true);
t.is(nonTestConnection.accessLevel, AccessLevelEnum.readonly);
Expand All @@ -117,7 +117,7 @@ test.serial(`${currentTest} should return connections, where second user have ac
t.is(Object.hasOwn(result[0].connection, 'groups'), false);
t.is(Object.hasOwn(result[0].connection, 'author'), false);
const testConnectionsCount = result.filter((el: any) => el.connection.isTestConnection).length;
t.is(testConnectionsCount, 4);
t.is(testConnectionsCount, 2);
} catch (e) {
console.error(e);
throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ test.serial(`${currentTest} should return connections, where second user have ac
t.is(findAll.status, 200);

const result = findAll.body.connections;
t.is(result.length, 5);
t.is(result.length, 3);
const nonTestConnection = result.find(({ connection }) => connection.id === connections.firstId);
for (const key in nonTestConnection.connection) {
t.is(Constants.CONNECTION_KEYS_NONE_PERMISSION.includes(key), true);
Expand Down
Loading