Add Komoot API client, import logic, crypto helpers, integration routes, DB schema changes, and i18n strings for the Komoot import feature. Import processing runs as a durable pg-boss background job with retries instead of blocking the HTTP request. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { describe, it, expect, beforeAll } from "vitest";
|
|
import { encrypt, decrypt } from "./crypto.server";
|
|
|
|
beforeAll(() => {
|
|
process.env.INTEGRATION_SECRET = "test-secret-for-unit-tests";
|
|
});
|
|
|
|
describe("crypto", () => {
|
|
it("encrypts and decrypts a string", () => {
|
|
const plaintext = "my-secret-password-123";
|
|
const encrypted = encrypt(plaintext);
|
|
expect(encrypted).not.toBe(plaintext);
|
|
expect(decrypt(encrypted)).toBe(plaintext);
|
|
});
|
|
|
|
it("produces different ciphertext for the same input", () => {
|
|
const plaintext = "same-input";
|
|
const a = encrypt(plaintext);
|
|
const b = encrypt(plaintext);
|
|
expect(a).not.toBe(b);
|
|
expect(decrypt(a)).toBe(plaintext);
|
|
expect(decrypt(b)).toBe(plaintext);
|
|
});
|
|
|
|
it("handles empty string", () => {
|
|
const encrypted = encrypt("");
|
|
expect(decrypt(encrypted)).toBe("");
|
|
});
|
|
|
|
it("handles unicode", () => {
|
|
const plaintext = "Passwort mit Ümlauten: äöü 🏔️";
|
|
expect(decrypt(encrypt(plaintext))).toBe(plaintext);
|
|
});
|
|
|
|
it("throws on tampered ciphertext", () => {
|
|
const encrypted = encrypt("secret");
|
|
const tampered = encrypted.slice(0, -2) + "XX";
|
|
expect(() => decrypt(tampered)).toThrow();
|
|
});
|
|
});
|