Skip to content

Commit

Permalink
remove non-iv cipher tests
Browse files Browse the repository at this point in the history
  • Loading branch information
icebob committed Dec 4, 2024
1 parent 176a623 commit de52131
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions test/unit/middlewares/transmit/encryption.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ describe("Test EncryptionMiddleware", () => {
});

it("should encrypt the data", () => {
const mw = Middleware(password);

const meta = {};
const next = jest.fn();
const send = mw.transporterSend.call(broker, next);
const encrypter = crypto.createCipher("aes-256-cbc", password);

send("topic", Buffer.from("plaintext data"), meta);

expect(next).toHaveBeenCalledTimes(1);
expect(next).toHaveBeenCalledWith("topic", expect.any(Buffer), meta);
expect(next.mock.calls[0][1]).toEqual(
Buffer.concat([encrypter.update("plaintext data"), encrypter.final()])
);
});

it("should encrypt the data with IV", () => {
const pass = crypto.randomBytes(32);
const iv = crypto.randomBytes(16);
const mw = Middleware(pass, "aes-256-ctr", iv);
Expand All @@ -48,23 +31,6 @@ describe("Test EncryptionMiddleware", () => {
);
});

it("should decrypt data with IV", () => {
const mw = Middleware(password);

const meta = {};
const next = jest.fn();
const receive = mw.transporterReceive.call(broker, next);
const encrypter = crypto.createCipher("aes-256-cbc", password);
const encryptedData = Buffer.concat([
encrypter.update("plaintext data"),
encrypter.final()
]);

receive("topic", encryptedData, meta);
expect(next).toHaveBeenCalledTimes(1);
expect(next).toHaveBeenCalledWith("topic", Buffer.from("plaintext data"), meta);
});

it("should decrypt data", () => {
const pass = crypto.randomBytes(32);
const iv = crypto.randomBytes(16);
Expand Down

0 comments on commit de52131

Please sign in to comment.