Skip to content

Commit 6262442

Browse files
added user crypto tests
1 parent a9adee8 commit 6262442

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/integration/user/userTests.js

+39
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,45 @@ describe("User tests", () => {
251251
chai.assert.equal(verify, true);
252252
});
253253

254+
//encrypt tests
255+
const string = "hello there £ Я a a";
256+
let encryptedString;
257+
258+
it("should encrypt string data for another user", async function() {
259+
encryptedString = await user.encryptString(string, user_2.user_data.user_id);
260+
261+
//should not decrypt it again
262+
try {
263+
await user.decryptString(encryptedString);
264+
} catch (e) {
265+
const json = JSON.parse(e);
266+
267+
chai.assert.equal(json.status, "server_304");
268+
}
269+
});
270+
271+
it("should decrypt the string for the other user", async function() {
272+
const decrypted = await user_2.decryptString(encryptedString);
273+
274+
chai.assert.equal(decrypted, string);
275+
});
276+
277+
it("should encrypt string with sign", async function() {
278+
encryptedString = await user.encryptString(string, user_2.user_data.user_id, true);
279+
});
280+
281+
it("should decrypt the signed string without verify", async function() {
282+
const decrypted = await user_2.decryptString(encryptedString);
283+
284+
chai.assert.equal(decrypted, string);
285+
});
286+
287+
it("should decrypt the string with verify", async function() {
288+
const decrypted = await user_2.decryptString(encryptedString, true, user.user_data.user_id);
289+
290+
chai.assert.equal(decrypted, string);
291+
});
292+
254293
it("should delete the user", async function() {
255294
await user.deleteUser(pw);
256295
await user_2.deleteUser(pw);

0 commit comments

Comments
 (0)