Skip to content

Commit 6ac5311

Browse files
committed
feedback
1 parent fdc0ed9 commit 6ac5311

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ package.json.decrypt
4747
# they track the package.json version
4848
/modules/kms-keyring-browser/src/version.ts
4949
/modules/kms-keyring-node/src/version.ts
50-
/modules/branch-keystore-node/src/version.ts
50+
/modules/branch-keystore-node/src/version.ts
51+
/modules/integration-node/src/version.ts

modules/integration-node/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"name": "@aws-crypto/integration-node",
33
"version": "4.1.0",
44
"scripts": {
5+
"prepublishOnly": "npm run generate-version.ts; npm run build",
6+
"generate-version.ts": "npx genversion --es6 src/version.ts",
57
"build": "tsc -b tsconfig.json",
68
"lint": "run-s lint-*",
79
"lint-eslint": "eslint src/*.ts test/*.ts",
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
export const KEYS_MANIFEST_NAME_FILENAME = 'keys.json'
5+
export const MANIFEST_NAME_FILENAME = 'manifest.json'
6+
export const DECRYPT_MANIFEST_TYPE = 'awses-decrypt'
7+
export const DECRYPT_MANIFEST_CLIENT_NAME = 'aws/aws-encryption-sdk-javascript'
8+
export const MANIFEST_URI_PREFIX = 'file://'
9+
export const MANIFEST_PLAINTEXT_PATH = 'plaintexts/'
10+
export const MANIFEST_CIPHERTEXT_PATH = 'ciphertexts/'

modules/integration-node/src/get_encrypt_test_iterator.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import { URL } from 'url'
1515
import { readFileSync } from 'fs'
1616
import got from 'got'
1717
import { ZipFile } from 'yazl'
18+
import {
19+
KEYS_MANIFEST_NAME_FILENAME,
20+
MANIFEST_PLAINTEXT_PATH,
21+
} from './constants'
1822

1923
export async function getEncryptTestVectorIterator(
2024
manifestFile: string,
@@ -40,7 +44,7 @@ export function _getEncryptTestVectorIterator(
4044
// has all the keys required for decrypt.
4145
manifestZip.addBuffer(
4246
Buffer.from(JSON.stringify(keysManifest)),
43-
`keys.json`
47+
`${KEYS_MANIFEST_NAME_FILENAME}`
4448
)
4549
}
4650
const { keys } = keysManifest
@@ -50,7 +54,10 @@ export function _getEncryptTestVectorIterator(
5054
plaintextBytes[name] = randomBytes(plaintexts[name])
5155

5256
if (manifestZip) {
53-
manifestZip.addBuffer(plaintextBytes[name], `plaintexts/${name}`)
57+
manifestZip.addBuffer(
58+
plaintextBytes[name],
59+
`${MANIFEST_PLAINTEXT_PATH}${name}`
60+
)
5461
}
5562
})
5663

modules/integration-node/src/integration_tests.ts

+22-10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
needs,
2424
DecryptOutput,
2525
} from '@aws-crypto/client-node'
26+
import { version } from './version'
2627
import { URL } from 'url'
2728
import got from 'got'
2829
import streamToPromise from 'stream-to-promise'
@@ -34,6 +35,15 @@ import { createWriteStream } from 'fs'
3435
import { v4 } from 'uuid'
3536
import * as stream from 'stream'
3637
import * as util from 'util'
38+
import {
39+
DECRYPT_MANIFEST_CLIENT_NAME,
40+
DECRYPT_MANIFEST_TYPE,
41+
KEYS_MANIFEST_NAME_FILENAME,
42+
MANIFEST_CIPHERTEXT_PATH,
43+
MANIFEST_NAME_FILENAME,
44+
MANIFEST_PLAINTEXT_PATH,
45+
MANIFEST_URI_PREFIX,
46+
} from './constants'
3747
const pipeline = util.promisify(stream.pipeline)
3848

3949
const notSupportedEncryptMessages = [
@@ -231,15 +241,14 @@ function decryptionManifestEncryptResults(
231241
const manifestZip = new ZipFile()
232242
const manifest: DecryptManifestList = {
233243
manifest: {
234-
type: 'awses-decrypt',
235-
version: 1,
244+
type: `${DECRYPT_MANIFEST_TYPE}`,
245+
version: 2,
236246
},
237247
client: {
238-
name: 'aws/aws-encryption-sdk-javascript',
239-
//Get the right version
240-
version: '2.2.0',
248+
name: `${DECRYPT_MANIFEST_CLIENT_NAME}`,
249+
version,
241250
},
242-
keys: 'file://keys.json',
251+
keys: `${MANIFEST_URI_PREFIX}${KEYS_MANIFEST_NAME_FILENAME}`,
243252
tests: {},
244253
}
245254
manifestZip.outputStream.pipe(createWriteStream(manifestPath))
@@ -252,7 +261,7 @@ function decryptionManifestEncryptResults(
252261
// as close the zip file.
253262
manifestZip.addBuffer(
254263
Buffer.from(JSON.stringify(manifest)),
255-
`manifest.json`
264+
`${MANIFEST_NAME_FILENAME}`
256265
)
257266
manifestZip.end()
258267
},
@@ -265,15 +274,18 @@ function decryptionManifestEncryptResults(
265274
): Promise<boolean> {
266275
const testName = v4()
267276

268-
manifestZip.addBuffer(encryptResult, `ciphertexts/${testName}`)
277+
manifestZip.addBuffer(
278+
encryptResult,
279+
`${MANIFEST_CIPHERTEXT_PATH}${testName}`
280+
)
269281

270282
manifest.tests[testName] = {
271283
description: `Decrypt vector from ${info.name}`,
272-
ciphertext: `file://ciphertexts/${testName}`,
284+
ciphertext: `${MANIFEST_URI_PREFIX}${MANIFEST_CIPHERTEXT_PATH}${testName}`,
273285
'master-keys': info.keysInfo.map((info) => info[0]),
274286
result: {
275287
output: {
276-
plaintext: `file://plaintexts/${info.plaintextName}`,
288+
plaintext: `${MANIFEST_URI_PREFIX}${MANIFEST_PLAINTEXT_PATH}${info.plaintextName}`,
277289
},
278290
},
279291
}

0 commit comments

Comments
 (0)