From ed330a6c9b24f9d1e1480172b7f0bac96051c034 Mon Sep 17 00:00:00 2001 From: Fritz Ray Date: Tue, 19 Sep 2023 16:08:39 -0700 Subject: [PATCH] Fixed unit test. 1.5.35 ## 1.5.35 * FIPS compatibility. * FIPS is enabled by default in all container builds, built with OpenSSL 3.0.8. * Switched Elastic to single-node to avoid some configuration annoyances on various platforms. * REJECT_SHA1 environment variable introduced (off by default), rejects requests made by cass-npm library < 1.5.35 * Turned logging headers off by default. * LOG_HEADERS environment variable introduced (off by default), enables logging headers. --- docker/standalone/Dockerfile | 4 ++-- src/main/server/skyRepo.js | 9 ++++--- src/main/server/skyRepo.test.js | 42 ++++++++++++++++----------------- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/docker/standalone/Dockerfile b/docker/standalone/Dockerfile index 9ca71fa8a..bd0337dea 100644 --- a/docker/standalone/Dockerfile +++ b/docker/standalone/Dockerfile @@ -23,15 +23,15 @@ RUN echo 'activate = 1' >> /usr/local/ssl/nodejs.cnf USER elasticsearch RUN mkdir CASS -COPY src CASS/src COPY package.json CASS/package.json +RUN cd CASS && npm install --omit=dev && npm upgrade --production --omit=dev --save && npm audit --production --audit-level=high fix +COPY src CASS/src COPY ca.crt CASS/ca.crt COPY cass.crt CASS/cass.crt COPY cass.key CASS/cass.key COPY pm2.standalone.config.js CASS/pm2.standalone.config.js COPY copyright.txt CASS/copyright.txt COPY LICENSE CASS/LICENSE -RUN cd CASS && npm install --omit=dev && npm upgrade --production --omit=dev --save && npm audit --production --audit-level=high fix USER root RUN echo '-Xms2g' >> config/jvm.options diff --git a/src/main/server/skyRepo.js b/src/main/server/skyRepo.js index 9f51e554e..d436092a7 100644 --- a/src/main/server/skyRepo.js +++ b/src/main/server/skyRepo.js @@ -9285,9 +9285,9 @@ let validateSignaturesBulk = async function(map, errorMessage) { const signatures = this.ctx.get('signatureSheet') || []; for (let oldGet of oldGets) { if (oldGet) { + const oldObj = new EcRemoteLinkedData(null, null); + oldObj.copyFrom(oldGet); try { - const oldObj = new EcRemoteLinkedData(null, null); - oldObj.copyFrom(oldGet); if (oldObj.owner !== undefined && oldObj.owner != null && oldObj.owner.length > 0) { let success = false; for (let i = 0; i < signatures.length; i++) { @@ -9310,7 +9310,10 @@ let validateSignaturesBulk = async function(map, errorMessage) { } } } catch (e) { - let id = oldGet['@id'].split('/').pop(); + let id = oldObj.getGuid(); + failed[id] = true; + delete map[id]; + id = EcCrypto.md5(oldObj.shortId()); failed[id] = true; delete map[id]; } diff --git a/src/main/server/skyRepo.test.js b/src/main/server/skyRepo.test.js index 5e415d44f..fdd3ba61f 100644 --- a/src/main/server/skyRepo.test.js +++ b/src/main/server/skyRepo.test.js @@ -165,34 +165,34 @@ describe('SkyRepo Adapter', function() { console.log(result2); assert.strictEqual(result2.length, 0); - // const getByShortId1d = await EcRepository.get(thing1.shortId()); - // assert.strictEqual(thing1bid, getByShortId1d.id); - // assert.strictEqual(getByShortId1d.name, 'Thing 1c'); + const getByShortId1d = await EcRepository.get(thing1.shortId()); + assert.strictEqual(thing1bid, getByShortId1d.id); + assert.strictEqual(getByShortId1d.name, 'Thing 1c'); - // const getByShortId2d = await EcRepository.get(thing2.shortId()); - // assert.strictEqual(thing2bid, getByShortId2d.id); - // assert.strictEqual(getByShortId2d.name, 'Thing 2c'); + const getByShortId2d = await EcRepository.get(thing2.shortId()); + assert.strictEqual(thing2bid, getByShortId2d.id); + assert.strictEqual(getByShortId2d.name, 'Thing 2c'); - // // Should fail when field types are mix of object and not object + // Should fail when field types are mix of object and not object - // const test1 = new EcCompetency(); - // test1.generateId(repo.selectedServer); - // test1.testDataField = 'string'; - // test1.name = 'Test 1'; + const test1 = new EcCompetency(); + test1.generateId(repo.selectedServer); + test1.testDataField = 'string'; + test1.name = 'Test 1'; - // result = await repo.multiput([test1]); - // assert.strictEqual(result.length, 1); + result = await repo.multiput([test1]); + assert.strictEqual(result.length, 1); - // const test2 = new EcCompetency(); - // test2.generateId(repo.selectedServer); - // test2.testDataField = {obj: 'thing'}; - // test2.name = 'Test 2'; + const test2 = new EcCompetency(); + test2.generateId(repo.selectedServer); + test2.testDataField = {obj: 'thing'}; + test2.name = 'Test 2'; - // let result3 = await repo.multiput([test1, test2]); - // assert.strictEqual(result3.length, 1); + let result3 = await repo.multiput([test1, test2]); + assert.strictEqual(result3.length, 1); - // const getTest2 = await EcRepository.get(test2.shortId()); - // assert.strictEqual(getTest2, null); + const getTest2 = await EcRepository.get(test2.shortId()); + assert.strictEqual(getTest2, null); }) });