Skip to content

Commit

Permalink
disable line
Browse files Browse the repository at this point in the history
  • Loading branch information
prayanshchh committed Nov 7, 2024
1 parent 4d298c1 commit f45df1c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 37 deletions.
39 changes: 20 additions & 19 deletions setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-restricted-imports */
import * as cryptolib from "crypto";
import dotenv from "dotenv";
import fs from "fs";
Expand All @@ -6,30 +7,30 @@ import path from "path";
import type { ExecException } from "child_process";
import { exec } from "child_process";
import { MongoClient } from "mongodb";
import { MAXIMUM_IMAGE_SIZE_LIMIT_KB } from "@constants";
import { MAXIMUM_IMAGE_SIZE_LIMIT_KB } from "./src/constants";
import {
askForMongoDBUrl,
checkConnection,
checkExistingMongoDB,
} from "@setup/MongoDB";
} from "./src/setup/MongoDB";
import crypto from "crypto";
import { askToKeepValues } from "@setup/askToKeepValues";
import { getNodeEnvironment } from "@setup/getNodeEnvironment";
import { isValidEmail } from "@setup/isValidEmail";
import { validateRecaptcha } from "@setup/reCaptcha";
import {
askForRedisUrl,
checkExistingRedis,
checkRedisConnection,
} from "@setup/redisConfiguration";
import {
setImageUploadSize,
validateImageFileSize,
} from "@setup/setImageUploadSize";
import { askForSuperAdminEmail } from "@setup/superAdmin";
import { updateEnvVariable } from "@setup/updateEnvVariable";
import { verifySmtpConnection } from "@setup/verifySmtpConnection";
import { loadDefaultOrganiation } from "@utilities/loadDefaultOrg";
import { askToKeepValues } from "./src/setup/askToKeepValues";
import { getNodeEnvironment } from "./src/setup/getNodeEnvironment";
import { isValidEmail } from "./src/setup/isValidEmail";
import { validateRecaptcha } from "./src/setup/reCaptcha";
import {
askForRedisUrl,
checkExistingRedis,
checkRedisConnection
} from "./src/setup/redisConfiguration";
import {
setImageUploadSize,
validateImageFileSize
} from "./src/setup/setImageUploadSize";
import { askForSuperAdminEmail } from "./src/setup/superAdmin";
import { updateEnvVariable } from "./src/setup/updateEnvVariable";
import { verifySmtpConnection } from "./src/setup/verifySmtpConnection";
import { loadDefaultOrganiation } from "./src/utilities/loadDefaultOrg";

dotenv.config();

Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/encryptionModule.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("encryptionModule", () => {
const originalKey = process.env.ENCRYPTION_KEY;
process.env.ENCRYPTION_KEY = "invalid_key";
expect(() => encryptEmail("[email protected]")).toThrow(
"Encryption key must be a 256-bit hexadecimal string (64 characters).",
"Encryption key must be a valid 256-bit hexadecimal string (64 characters).",
);
process.env.ENCRYPTION_KEY = originalKey;
});
Expand Down
29 changes: 19 additions & 10 deletions tests/utilities/hashingModule.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { describe, it, expect } from "vitest";
import { hashEmail } from "../../src/utilities/hashEmail";
import { setHashPepper } from "../../setup";

describe("hashingModule", () => {
describe("hashingEmail", () => {
Expand Down Expand Up @@ -29,21 +30,29 @@ describe("hashingModule", () => {
expect(() => hashEmail(undefined as unknown as string)).toThrow();
});

it("should produce different hashes with different HASH_PEPPER values", () => {
it("should produce different hashes with different HASH_PEPPER values", async () => {
const email = "[email protected]";
const originalPepper = process.env.HASH_PEPPER;
if (!originalPepper) {
throw new Error("HASH_PEPPER environment variable is required");
}
try {
process.env.HASH_PEPPER = "pepper1";
const hash1 = hashEmail(email);
process.env.HASH_PEPPER = "pepper2";
const hash2 = hashEmail(email);
expect(hash1).not.toEqual(hash2);
} finally {
process.env.HASH_PEPPER = originalPepper;
}
});
const pepper1 = await setHashPepper();
const pepper2 = await setHashPepper();
if(pepper1 != undefined && pepper2 != undefined)
{

process.env.HASH_PEPPER = pepper1;
const hash1 = hashEmail(email);
process.env.HASH_PEPPER = "pepper2";
const hash2 = hashEmail(email);
expect(hash1).not.toEqual(hash2);
}
}
finally {
process.env.HASH_PEPPER = originalPepper;
}
}
);
});
});
8 changes: 1 addition & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
"resolveJsonModule": true /* Allow to import JSON files */,
"baseUrl": ".",
"paths": {
"@constants": ["./src/constants"],
"@setup/*": ["./src/setup/*"],
"@utilities/*": ["./src/utilities/*"]
}
"resolveJsonModule": true /* Allow to import JSON files */
}
}

0 comments on commit f45df1c

Please sign in to comment.