Skip to content

Commit 3770156

Browse files
committed
added to tests
1 parent 1d64526 commit 3770156

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

spec/crypto-v3.spec.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import {
44
ciphertext,
55
formPublicKey,
66
formSecretKey,
7-
submissionSecretKey
7+
submissionSecretKey,
8+
plainVerifiedText
89
} from './resources/crypto-v3-data-20231207'
910
import CryptoV3 from '../src/crypto-v3'
11+
import Crypto from '../src/crypto'
1012

1113
const INTERNAL_TEST_VERSION = 3
1214

@@ -18,6 +20,7 @@ describe('CryptoV3', function () {
1820
afterEach(() => mockAxios.reset())
1921

2022
const crypto = new CryptoV3()
23+
const cryptoV1 = new Crypto()
2124

2225
it('should generate a keypair', () => {
2326
const keypair = crypto.generate()
@@ -126,4 +129,22 @@ describe('CryptoV3', function () {
126129

127130
expect(decrypted).toBeNull()
128131
})
132+
133+
it('should be able to encrypt and decrypt submissions with verifiedContent from 2023-12-07 end-to-end successfully from the form private key', () => {
134+
// Arrange
135+
const { publicKey, secretKey } = crypto.generate()
136+
137+
// Act
138+
const ciphertext = crypto.encrypt(plaintext, publicKey)
139+
const verifiedText = cryptoV1.encrypt(plainVerifiedText, publicKey)
140+
const decrypted = crypto.decrypt(secretKey, {
141+
...ciphertext,
142+
verifiedContent: verifiedText,
143+
version: INTERNAL_TEST_VERSION,
144+
})
145+
// Assert
146+
expect(decrypted).toHaveProperty('responses', plaintext)
147+
expect(decrypted).toHaveProperty('verified', plainVerifiedText)
148+
149+
})
129150
})

spec/resources/crypto-v3-data-20231207.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,29 @@ const plaintext = {
3030
}
3131
}
3232

33+
const plainVerifiedText = { 'uinFin (Step 1)': 'S9912370B' }
34+
3335
const ciphertext = {
3436
encryptedContent:
3537
'yUW5li4+IA9q2/n3ZS+5+wrXQ8mKGrFJ1KW9Kf/eRzc=;PgZE8+y8rBvssnqLnqjnnqHDW6PngYKK:eIEuOUQjf1YkQIulZ7bCKXIl6wByg644Ulk/LjhefmLzhkVmXbTxBJVKVG6YgV0ZMcG4JPUuQ+WOW+N1/AOyL/8DJqclX74kG6s0DNXIJixkqNZCnfZapulerR9XXKSfwBjpo1nK25KCg32F/ey2HypPcluGV19hWwgj80mlms7Ya7x1X5wcdttlGrzGEnNH2VEPXjzJZHqiV1TWoQGwxSZ753fpkHUkBeKFA1UkMHS5XYnWyYD48JpfpOAz0L2ti6RHQnQLSKUHscYVfAZt5OyUGqPFmhm2ulWdycNVp8HayQrpqeY8cdu8QsmZRdNCMfMFLahZCm6xKS+8GUrJWgJr64yaZpkxQS45uPb9zxC+G/u4FZhS/YsrjDTuIIwMGS0+qsNr4075yemFFAQHIpbhWZ9QlYrNq2TAolrVezeAw3AQ/nr4sz60dvqRahcse9x8oMxB7jA55OuxH5uk6PcCIAmEi+njr6Lgbcn2mtPMyk7kGcwjNzCL57b51RxJVi0ZqNXrS0FFepvzCK3IOEqKqrKGGK0qGqF4MFsH2wdq4RFkXjLMZk4u9ZWjIRjc',
3638
encryptedSubmissionSecretKey:
3739
'ywWDxb29guAgVK4yhLmLK19UKzLrfLAl65JzPDCVNz8=;/Q3WNg7Dk/tWBmpdUcST39zG16/Nyn8V:p1YqpiwEtOssq3yZUhZC1SgIYJcfJDmVFmgNwKf8D+YEqDzLaq5GShR7hTtTixtp',
3840
}
3941

42+
const cipherTextWithVerified = ciphertext && {
43+
verifiedContent: 'Pb3Vsnlq4dxGOd6it4b2b3J2JPM5NDtmmxl3iCpy0Bc=;gURQt+HU9XpeCcS4tzlDjJGAgQOyzOpg:Ip4UavPqxT94DkUbTB6RdbXqZ2JlHQVn+e6SkH5Ec7lcTKAQ8I695F6eG6Zx8GY='
44+
}
45+
4046
const formPublicKey = 'ySgusViv6xdSIXELuGOq2L3Obp8xorT0Qilv+G4nHnM='
4147
const formSecretKey = 'Ngx1Kwpe8JXZUof/DCkkVduVmPSN4paqaKj5971Gq5c='
4248
const submissionPublicKey = '8JCuSlyJZ5N684o9TNdZLijtuORTlD/pbXiFwNf7Fhc='
4349
const submissionSecretKey = 'bIyKphcx5hiuBaJ4q5cwnXaFNY9Ofe5NQBqTEzf3zYA='
4450

4551
export {
4652
plaintext,
53+
plainVerifiedText,
4754
ciphertext,
55+
cipherTextWithVerified,
4856
formPublicKey,
4957
formSecretKey,
5058
submissionPublicKey,

0 commit comments

Comments
 (0)