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
8 changes: 4 additions & 4 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"test-all": "ava --timeout=5m --serial",
"test-saas": "ava test/ava-tests/saas-tests/* ",
"typeorm": "ts-node -r tsconfig-paths/register ../node_modules/.bin/typeorm",
"migration:generate": "yarn run typeorm migration:generate -d dist/shared/config/datasource.config.js",
"migration:create": "yarn run typeorm migration:create -d dist/shared/config/datasource.config.js",
"migration:run": "yarn run typeorm migration:run -d dist/shared/config/datasource.config.js",
"migration:revert": "npm run typeorm -- migration:revert -d dist/shared/config/datasource.config.js",
"migration:generate": "yarn run typeorm migration:generate -d dist/src/shared/config/datasource.config.js",
"migration:create": "yarn run typeorm migration:create -d dist/src/shared/config/datasource.config.js",
"migration:run": "yarn run typeorm migration:run -d dist/src/shared/config/datasource.config.js",
"migration:revert": "npm run typeorm -- migration:revert -d dist/src/shared/config/datasource.config.js",
"knip": "knip"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion backend/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class AppController {

@Get('/hello')
async getHello(): Promise<string> {

return this.getHelloUseCase.execute(undefined, InTransactionEnum.OFF);
}
}

1 change: 0 additions & 1 deletion backend/src/authorization/auth-with-api.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class AuthWithApiMiddleware implements NestMiddleware {
) {}

async use(req: Request, res: Response, next: (err?: any, res?: any) => void): Promise<void> {
console.info(`Auth with api middleware triggered ->: ${new Date().toISOString()}`);
try {
await this.authenticateRequest(req);
next();
Expand Down
1 change: 0 additions & 1 deletion backend/src/authorization/auth.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export class AuthMiddleware implements NestMiddleware {
private readonly logOutRepository: Repository<LogOutEntity>,
) {}
async use(req: Request, res: Response, next: (err?: any, res?: any) => void): Promise<void> {
console.log(`auth middleware triggered ->: ${new Date().toISOString()}`);
let token: string;
try {
token = req.cookies[Constants.JWT_COOKIE_KEY_NAME];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export const customAgentRepositoryExtension = {
return 'CASSANDRA-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_redis:
return 'REDIS-TEST-AGENT-TOKEN';
case ConnectionTypeTestEnum.agent_clickhouse:
return 'CLICKHOUSE-TEST-AGENT-TOKEN';
}
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function readSslCertificate(): Promise<string> {
const fileName = 'global-bundle.pem';
return new Promise((resolve, reject) => {
fs.readFile(
join(__dirname, '..', '..', '..', '..', 'files', 'certificates', fileName),
join(__dirname, '..', '..', '..', '..', '..', 'files', 'certificates', fileName),
'utf8',
function (err, data) {
if (err) {
Expand Down
9 changes: 5 additions & 4 deletions backend/src/entities/email/template-engine/nunjucks.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ import * as nunjucks from 'nunjucks';
import { BaseType } from '../../../common/data-injection.tokens.js';
import path from 'path';
import { fileURLToPath } from 'url';
import { isTest } from '../../../helpers/app/is-test.js';
import { existsSync } from 'node:fs';
import assert from 'assert';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const pathToTemplates = path.join(__dirname, '..', '..', '..', '..', '..', 'public', 'email-templates');
assert(existsSync(pathToTemplates), `Email templates directory does not exist: ${__dirname} ${pathToTemplates}`);

@Global()
@Module({
providers: [
{
provide: BaseType.NUNJUCKS,
useFactory: () => {
const pathToTemplates = isTest()
? process.cwd() + '/public/email-templates'
: path.join(__dirname, '..', '..', '..', '..', 'public', 'email-templates');
const env = new nunjucks.Environment(new nunjucks.FileSystemLoader(pathToTemplates));
return env;
},
Expand Down
4 changes: 4 additions & 0 deletions backend/src/entities/logging/winston-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class WinstonLogger implements LoggerService {
this.logger.info(message, ...optionalParams);
}

public info(message: any, ...optionalParams: any[]) {
this.logger.info(message, ...optionalParams);
}

public error(message: any, ...optionalParams: any[]) {
this.logger.error(message, ...optionalParams);
}
Expand Down
2 changes: 2 additions & 0 deletions backend/src/enums/connection-type.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export enum ConnectionTypeTestEnum {
elasticsearch = 'elasticsearch',
cassandra = 'cassandra',
redis = 'redis',
clickhouse = 'clickhouse',
agent_postgres = 'agent_postgres',
agent_mysql = 'agent_mysql',
agent_oracledb = 'agent_oracledb',
Expand All @@ -19,4 +20,5 @@ export enum ConnectionTypeTestEnum {
agent_elasticsearch = 'agent_elasticsearch',
agent_cassandra = 'agent_cassandra',
agent_redis = 'agent_redis',
agent_clickhouse = 'agent_clickhouse',
}
2 changes: 2 additions & 0 deletions backend/src/helpers/is-connection-entity-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function isConnectionEntityAgent(connection: ConnectionEntity | CreateCon
ConnectionTypesEnum.agent_mongodb,
ConnectionTypesEnum.agent_cassandra,
ConnectionTypesEnum.agent_redis,
ConnectionTypesEnum.agent_clickhouse,
];

return agentTypes.includes(connection.type as ConnectionTypesEnum);
Expand All @@ -28,6 +29,7 @@ export function isConnectionTypeAgent(type: ConnectionTypesEnum | string): boole
ConnectionTypeTestEnum.agent_mongodb,
ConnectionTypeTestEnum.agent_cassandra,
ConnectionTypesEnum.agent_redis,
ConnectionTypesEnum.agent_clickhouse,
];

return connectionTypes.includes(type as ConnectionTypeTestEnum);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export class AppLoggerMiddleware implements NestMiddleware {
use(request: Request, response: Response, next: NextFunction): void {
const { ip, method, path: url, baseUrl } = request;
const userAgent = request.get('user-agent') || '';
this.logger.log(`START ${method} ${url}${baseUrl} - ${userAgent} ${ip}`, { context: 'HTTP' });
this.logger.info(`START ${method} ${url}${baseUrl} - ${userAgent} ${ip}`, { context: 'HTTP' });
response.on('close', () => {
const { statusCode } = response;
const contentLength = response.get('content-length');
this.logger.log(
this.logger.info(
`method: ${method}, url: ${url}, statusCode: ${statusCode}, contentLength: ${contentLength}, userAgent: ${userAgent}, ip: ${ip}`,
{ context: 'HTTP' },
);
Expand Down
57 changes: 17 additions & 40 deletions backend/test/ava-tests/saas-tests/company-info-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import test from 'ava';
import { ValidationError } from 'class-validator';
import cookieParser from 'cookie-parser';
import fs from 'fs';
import os from 'os';
import { nanoid } from 'nanoid';
import path, { join } from 'path';
import request from 'supertest';
Expand Down Expand Up @@ -1194,13 +1195,8 @@ test.serial(`${currentTest} should create and return found company logo after cr

const foundCompanyInfoRO = JSON.parse(foundCompanyInfo.text);

const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}

const testLogoPatch = join(process.cwd(), 'test', 'ava-tests', 'test-files', 'test_logo.png');
const downloadedLogoPatch = join(__dirname, 'response-files', `${foundCompanyInfoRO.id}_test_logo.png`);
const downloadedLogoPatch = join(os.tmpdir(), `${foundCompanyInfoRO.id}_test_logo.png`);

const createLogoResponse = await request(app.getHttpServer())
.post(`/company/logo/${foundCompanyInfoRO.id}`)
Expand Down Expand Up @@ -1240,11 +1236,8 @@ test.serial(`${currentTest} should create and return found company logo after cr
t.is(foundCompanyLogoForSimpleUserRO.logo.mimeType, 'image/png');
t.is(foundCompanyLogoForSimpleUserRO.logo.image.length > 0, true);

const downloadedLogoPatchForSimpleUser = join(
__dirname,
'response-files',
`${foundCompanyInfoRO.id}_simple_user_logo.png`,
);
const downloadedLogoPatchForSimpleUser = join(os.tmpdir(), `${foundCompanyInfoRO.id}_simple_user_logo.png`);

fs.writeFileSync(downloadedLogoPatchForSimpleUser, foundCompanyLogoForSimpleUserRO.logo.image);
const isFileExistsForSimpleUser = fs.existsSync(downloadedLogoPatchForSimpleUser);
t.is(isFileExistsForSimpleUser, true);
Expand All @@ -1262,11 +1255,8 @@ test.serial(`${currentTest} should create and return found company logo after cr
t.is(foundCompanyInfoWithLogoRO.logo.mimeType, 'image/png');
t.is(foundCompanyInfoWithLogoRO.logo.image.length > 0, true);

const downloadedLogoPatchWithLogo = join(
__dirname,
'response-files',
`${foundCompanyInfoWithLogoRO.id}_admin_user_logo.png`,
);
const downloadedLogoPatchWithLogo = join(os.tmpdir(), `${foundCompanyInfoWithLogoRO.id}_admin_user_logo.png`);

fs.writeFileSync(downloadedLogoPatchWithLogo, foundCompanyInfoWithLogoRO.logo.image);
const isFileExistsWithLogo = fs.existsSync(downloadedLogoPatchWithLogo);
t.is(isFileExistsWithLogo, true);
Expand All @@ -1285,10 +1275,10 @@ test.serial(`${currentTest} should create and return found company logo after cr
t.is(foundCompanyInfoWithLogoForSimpleUserRO.logo.image.length > 0, true);

const downloadedLogoPatchForSimpleUserWithLogo = join(
__dirname,
'response-files',
os.tmpdir(),
`${foundCompanyInfoWithLogoForSimpleUserRO.id}_simple_user_logo.png`,
);

fs.writeFileSync(downloadedLogoPatchForSimpleUserWithLogo, foundCompanyInfoWithLogoForSimpleUserRO.logo.image);
const isFileExistsForSimpleUserWithLogo = fs.existsSync(downloadedLogoPatchForSimpleUserWithLogo);
t.is(isFileExistsForSimpleUserWithLogo, true);
Expand Down Expand Up @@ -1316,13 +1306,8 @@ test.serial(`${currentTest} should create and return found company favicon after

const foundCompanyInfoRO = JSON.parse(foundCompanyInfo.text);

const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}

const testFaviconPatch = join(process.cwd(), 'test', 'ava-tests', 'test-files', 'test_logo.png');
const downloadedFaviconPatch = join(__dirname, 'response-files', `${foundCompanyInfoRO.id}_test_favicon.png`);
const downloadedFaviconPatch = join(os.tmpdir(), `${foundCompanyInfoRO.id}_test_favicon.png`);

const createFaviconResponse = await request(app.getHttpServer())
.post(`/company/favicon/${foundCompanyInfoRO.id}`)
Expand Down Expand Up @@ -1362,11 +1347,8 @@ test.serial(`${currentTest} should create and return found company favicon after
t.is(foundCompanyFaviconForSimpleUserRO.favicon.mimeType, 'image/png');
t.is(foundCompanyFaviconForSimpleUserRO.favicon.image.length > 0, true);

const downloadedFaviconPatchForSimpleUser = join(
__dirname,
'response-files',
`${foundCompanyInfoRO.id}_simple_user_favicon.png`,
);
const downloadedFaviconPatchForSimpleUser = join(os.tmpdir(), `${foundCompanyInfoRO.id}_simple_user_favicon.png`);

fs.writeFileSync(downloadedFaviconPatchForSimpleUser, foundCompanyFaviconForSimpleUserRO.favicon.image);
const isFileExistsForSimpleUser = fs.existsSync(downloadedFaviconPatchForSimpleUser);
t.is(isFileExistsForSimpleUser, true);
Expand All @@ -1385,10 +1367,10 @@ test.serial(`${currentTest} should create and return found company favicon after
t.is(foundCompanyInfoWithFaviconRO.favicon.image.length > 0, true);

const downloadedFaviconPatchWithFavicon = join(
__dirname,
'response-files',
os.tmpdir(),
`${foundCompanyInfoWithFaviconRO.id}_admin_user_favicon.png`,
);

fs.writeFileSync(downloadedFaviconPatchWithFavicon, foundCompanyInfoWithFaviconRO.favicon.image);
const isFileExistsWithFavicon = fs.existsSync(downloadedFaviconPatchWithFavicon);
t.is(isFileExistsWithFavicon, true);
Expand All @@ -1407,10 +1389,10 @@ test.serial(`${currentTest} should create and return found company favicon after
t.is(foundCompanyInfoWithFaviconForSimpleUserRO.favicon.image.length > 0, true);

const downloadedFaviconPatchForSimpleUserWithFavicon = join(
__dirname,
'response-files',
os.tmpdir(),
`${foundCompanyInfoWithFaviconForSimpleUserRO.id}_simple_user_favicon.png`,
);

fs.writeFileSync(
downloadedFaviconPatchForSimpleUserWithFavicon,
foundCompanyInfoWithFaviconForSimpleUserRO.favicon.image,
Expand Down Expand Up @@ -1512,13 +1494,8 @@ test.serial(`${currentTest} should return found company white label properties f
const foundCompanyInfoRO = JSON.parse(foundCompanyInfo.text);

// crete company logo
const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}

const testLogoPatch = join(process.cwd(), 'test', 'ava-tests', 'test-files', 'test_logo.png');
const downloadedLogoPatch = join(__dirname, 'response-files', `${foundCompanyInfoRO.id}_test_logo.png`);
const downloadedLogoPatch = join(os.tmpdir(), `${foundCompanyInfoRO.id}_test_logo.png`);

const createLogoResponse = await request(app.getHttpServer())
.post(`/company/logo/${foundCompanyInfoRO.id}`)
Expand All @@ -1532,7 +1509,7 @@ test.serial(`${currentTest} should return found company white label properties f

// crete company favicon
const testFaviconPatch = join(process.cwd(), 'test', 'ava-tests', 'test-files', 'test_logo.png');
const downloadedFaviconPatch = join(__dirname, 'response-files', `${foundCompanyInfoRO.id}_test_favicon.png`);
const downloadedFaviconPatch = join(os.tmpdir(), `${foundCompanyInfoRO.id}_test_favicon.png`);

const createFaviconResponse = await request(app.getHttpServer())
.post(`/company/favicon/${foundCompanyInfoRO.id}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import test from 'ava';
import { ValidationError } from 'class-validator';
import cookieParser from 'cookie-parser';
import fs from 'fs';
import os from 'os';
import path, { join } from 'path';
import request from 'supertest';
import { fileURLToPath } from 'url';
Expand Down Expand Up @@ -3178,12 +3179,8 @@ test.serial(`${currentTest} should return csv file with table data`, async (t) =
}
t.is(getTableCsvResponse.status, 201);
const fileName = `${testTableName}.csv`;
const downloadedFilePatch = join(__dirname, 'response-files', fileName);
const downloadedFilePatch = join(os.tmpdir(), fileName);

const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body);

Expand Down Expand Up @@ -3293,12 +3290,8 @@ with search and pagination: page=1, perPage=2 and DESC sorting`,
}
t.is(getTableCsvResponse.status, 201);
const fileName = `${testTableName}.csv`;
const downloadedFilePatch = join(__dirname, 'response-files', fileName);
const downloadedFilePatch = join(os.tmpdir(), fileName);

const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body);

Expand Down Expand Up @@ -3358,12 +3351,8 @@ test.serial(`${currentTest} should import csv file with table data`, async (t) =
}
t.is(getTableCsvResponse.status, 201);
const fileName = `${testTableName}.csv`;
const downloadedFilePatch = join(__dirname, 'response-files', fileName);
const downloadedFilePatch = join(os.tmpdir(), fileName);

const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body);
// eslint-disable-next-line security/detect-non-literal-fs-filename
Expand Down Expand Up @@ -3463,12 +3452,8 @@ test.serial(`${currentTest} should throw exception whe csv import is disabled`,
}
t.is(getTableCsvResponse.status, 201);
const fileName = `${testTableName}.csv`;
const downloadedFilePatch = join(__dirname, 'response-files', fileName);
const downloadedFilePatch = join(os.tmpdir(), fileName);

const dir = join(__dirname, 'response-files');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.writeFileSync(downloadedFilePatch, getTableCsvResponse.body);
// eslint-disable-next-line security/detect-non-literal-fs-filename
Expand Down
Loading
Loading