cassproject 1.5.13 → 1.5.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,6 +49,15 @@ Development unit tests presume you have a CaSS Repository running on `localhost:
49
49
 
50
50
  # Changelog
51
51
 
52
+ ## 1.5.15
53
+ * Fixed issue combining use of client side certificates with HTTP/2
54
+ * Support import of ceasn:ProgressionModel
55
+ * Ignore sample data for CEASN import.
56
+ * Skip empty lines on CSV taxonomy import.
57
+ * Introduced way to debounce EcRepository.get to prevent multiple HTTP requests for the same piece of data in a race condition environment.
58
+ * EcPerson.getByPk now fetches people by their PK more reliably.
59
+ *
60
+
52
61
  ## 1.5.13
53
62
  * Audit logging.
54
63
  * Classification and Markings remain unencrypted on objects.
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "cassproject",
3
- "version": "1.5.13",
3
+ "version": "1.5.16",
4
4
  "description": "Competency and Skills Service",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "npm run test15Https11 && npm run test15Https && npm run test15 && npm run test14 && npm run test13 && npm run test12",
7
+ "test": "npm run test15Https11 && npm run test15Https && npm run test15",
8
+ "testCustom": "npm run test14 && npm run test13 && npm run test12",
8
9
  "multitest": "concurrently --kill-others --kill-others-on-fail \"npm run test15\" \"npm run test14\" \"npm run test13\" \"npm run test12\"",
9
10
  "testCassTest": "npm run testkill && docker run -d --name cass-test -p80:80 -e CASS_LOOPBACK cass-test && wait-on http://localhost/api/ping && npm run testNode18 && npm run testNode18Fips && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testCypressEdge && npm run testCypress && npm run testkill",
10
11
  "testDevHttps": "npm run testkill && docker run -d --name cass-test -p443:80 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:dev && wait-on https://localhost/api/ping && npm run testNode18HttpsFips && npm run testNode18Https && npm run testNode16Https && npm run testNode15Https && npm run testNode14Https && npm run testNode13Https && npm run testNode12Https && npm run testCypressEdgeHttps && npm run testCypressHttps",
11
- "test15Https": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.11 && wait-on https://localhost/api/ping && npm run testNode18HttpsFips && npm run testNode18Https && npm run testNode16Https && npm run testCypressEdgeHttps && npm run testCypressHttps && npm run testkill",
12
- "test15Https11": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.11 && wait-on https://localhost/api/ping && npm run testNode18HttpsFips && npm run testNode18Https && npm run testNode16Https && npm run testCypressEdgeHttps && npm run testCypressHttps && npm run testkill",
13
- "test15": "export CASS_LOOPBACK=http://localhost/api/|| set CASS_LOOPBACK=http://localhost/api/&& npm run testkill15 && docker run -d -e CASS_LOOPBACK --name cass-test15 -p80:80 cassproject/cass:1.5.11 && wait-on http://localhost/api/ping && npm run testNode18 && npm run testNode18Fips && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testCypressEdge && npm run testCypress && npm run testkill15",
14
- "test14": "npm run testkill14 && docker run -d -e CASS_LOOPBACK --name cass-test14 -p80:80 cassproject/cass:1.4.4 && wait-on http://localhost/api/ping && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testCypressEdge && npm run testCypress && npm run testkill14",
15
- "test13": "npm run testkill13 && docker run -d -e CASS_LOOPBACK --name cass-test13 -p80:80 cassproject/cass:1.3.18 && wait-on http://localhost/api/ping && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testCypressEdge && npm run testCypress && npm run testkill13",
16
- "test12": "npm run testkill12 && docker run -d -e CASS_LOOPBACK --name cass-test12 -p80:80 cassproject/cass:1.2.44 && wait-on http://localhost/api/ping && npm run testNode16 && npm run testNode15 && npm run testNode14 && npm run testNode13 && npm run testNode12 && npm run testCypressEdge && npm run testCypress && npm run testkill12",
12
+ "test15Https": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.15 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode18HttpsFips\" \"npm run testNode18Https\" \"npm run testNode16Https\" && npm run testkill",
13
+ "test15Https11": "npm run testkill && docker run -d --name cass-test -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.15 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode18HttpsFips\" \"npm run testNode18Https\" \"npm run testNode16Https\" && npm run testkill",
14
+ "test15": "export CASS_LOOPBACK=http://localhost/api/|| set CASS_LOOPBACK=http://localhost/api/&& npm run testkill15 && docker run -d -e CASS_LOOPBACK --name cass-test15 -p80:80 cassproject/cass:1.5.15 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode18\" \"npm run testNode18Fips\" \"npm run testNode16\" && npm run testkill15",
15
+ "test14": "npm run testkill14 && docker run -d -e CASS_LOOPBACK --name cass-test14 -p80:80 cassproject/cass:1.4.4 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode16\" && npm run testkill14",
16
+ "test13": "npm run testkill13 && docker run -d -e CASS_LOOPBACK --name cass-test13 -p80:80 cassproject/cass:1.3.18 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode16\" && npm run testkill13",
17
+ "test12": "npm run testkill12 && docker run -d -e CASS_LOOPBACK --name cass-test12 -p80:80 cassproject/cass:1.2.44 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode16\" && npm run testkill12",
17
18
  "testkill15": "docker kill cass-test15 | exit 0 && docker rm cass-test15 | exit 0",
18
19
  "testkill14": "docker kill cass-test14 | exit 0 && docker rm cass-test14 | exit 0",
19
20
  "testkill13": "docker kill cass-test13 | exit 0 && docker rm cass-test13 | exit 0",
@@ -33,35 +34,38 @@
33
34
  "testNode13Https": "docker build --progress plain -f docker/node13https -t npm-cass13https . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-cass13https",
34
35
  "testNode12": "docker build --progress plain -f docker/node12 -t npm-cass12 . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-cass12",
35
36
  "testNode12Https": "docker build --progress plain -f docker/node12https -t npm-cass12https . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-cass12https",
36
- "testCypress": "docker build --progress plain -f docker/cypress -t npm-casscypress . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-casscypress",
37
- "testCypressEdge": "docker build --progress plain -f docker/cypressEdge -t npm-casscypressedge . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-casscypressedge",
38
- "testCypressHttps": "docker build --progress plain -f docker/cypressHttps -t npm-casscypresshttps . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-casscypresshttps",
39
- "testCypressEdgeHttps": "docker build --progress plain -f docker/cypressEdgeHttps -t npm-casscypressedgehttps . & docker run -e CASS_LOOPBACK --rm --network=\"host\" npm-casscypressedgehttps",
37
+ "testCypress": "docker build --progress plain -f docker/cypress -t npm-casscypress . & docker run -e CASS_LOOPBACK --rm npm-casscypress",
38
+ "testCypressHttps": "docker build --progress plain -f docker/cypressHttps -t npm-casscypresshttps . & docker run -e CASS_LOOPBACK --rm npm-casscypresshttps",
40
39
  "autotest": "nodemon test.js",
41
40
  "autoindex": "nodemon index.js",
42
- "mocha": "nyc --reporter=lcov --reporter=text mocha -b src/**/*.test.js",
43
- "mocha:httpsNoHttp2": "export HTTP2=false|| set HTTP2=false&& mocha -b src/**/*.test.js",
44
- "mocha:https": "mocha -b src/**/*.test.js",
45
- "mocha:clientSideCertificates": "export CASS_LOOPBACK=https://localhost/api/|| set CASS_LOOPBACK=https://localhost/api/&& mocha -b src/**/*.test.js",
46
- "mochaGraph": "mocha -b src/com/eduworks/ec/graph/**/*.test.js",
47
- "automocha": "nodemon --exec \"npm run mocha\"",
41
+ "mocha": "nyc --reporter=lcov --reporter=text mocha --timeout 15000 -b src/**/*.test.js",
42
+ "mocha:httpsNoHttp2": "export HTTP2=false|| set HTTP2=false&& mocha --timeout 15000 -b src/**/*.test.js",
43
+ "mocha:https": "mocha --timeout 15000 -b src/**/*.test.js",
44
+ "mocha:clientSideCertificates": "export CASS_LOOPBACK=https://localhost/api/|| set CASS_LOOPBACK=https://localhost/api/&& mocha --timeout 15000 -b src/**/*.test.js",
45
+ "mocha:custom": "export CASS_LOOPBACK=https://tides.eduworks.us/api/|| set CASS_LOOPBACK=https://tides.eduworks.us/api/&& export HTTP2=false|| set HTTP2=false&& mocha --timeout 300000 -b src/**/*.test.js",
46
+ "mocha:dev": "export CASS_LOOPBACK=https://dev.cassproject.org/api/|| set CASS_LOOPBACK=https://dev.cassproject.org/api/&& export HTTP2=false|| set HTTP2=false&& mocha --timeout 300000 -b src/**/*.test.js",
47
+ "mocha:demo": "export CASS_LOOPBACK=https://demo.cassproject.org/api/|| set CASS_LOOPBACK=https://demo.cassproject.org/api/&& export HTTP2=false|| set HTTP2=false&& mocha --timeout 300000 -b src/**/*.test.js",
48
+ "mochaGraph": "mocha --timeout 15000 -b src/com/eduworks/ec/graph/**/*.test.js",
49
+ "automocha": "nodemon --exec \"npm run mocha:clientSideCertificates\"",
48
50
  "automochaGraph": "nodemon --exec \"npm run mochaGraph\"",
49
51
  "automocha:clientSideCertificates": "nodemon --exec \"npm run mocha:clientSideCertificates\"",
50
52
  "lint": "eslint src -c .eslintrc.js --ext .js --fix",
51
53
  "docs": "npm install yuidocjs yuidoc-ember-cli-theme && yuidoc -c yuidoc.json -o docs -e .js src && npm remove yuidocjs yuidoc-ember-cli-theme",
52
54
  "doclint": "npm install yuidocjs yuidoc-ember-cli-theme && yuidoc --lint -c yuidoc.json -o docs -e .js src",
53
- "browserify:cypress:open": "cypress open --config-file cypressBrowserify.json",
54
- "browserify:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.json",
55
- "webpack:cypress:open": "cypress open --config-file cypressWebpack.json",
56
- "webpack:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.json",
57
- "browserify:cypress": "cypress run --config-file cypressBrowserify.json --headless --browser chrome",
58
- "browserify:cypressHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.json --headless --browser chrome",
59
- "browserify:cypressEdge": "cypress run --config-file cypressBrowserify.json --headless --browser edge",
60
- "browserify:cypressEdgeHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.json --headless --browser edge",
61
- "webpack:cypress": "cypress run --config-file cypressWebpack.json --headless --browser chrome",
62
- "webpack:cypressHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.json --headless --browser chrome",
63
- "webpack:cypressEdge": "cypress run --config-file cypressWebpack.json --headless --browser edge",
64
- "webpack:cypressEdgeHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.json --headless --browser edge"
55
+ "browserify:cypress:open": "cypress open --config-file cypressBrowserify.config.js",
56
+ "browserify:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.config.js",
57
+ "vite:cypress:open": "cypress open --config-file cypressVite.config.js",
58
+ "vite:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressVite.config.js",
59
+ "webpack:cypress:open": "cypress open --config-file cypressWebpack.config.js",
60
+ "webpack:cypress:open:https": "cypress open -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.config.js",
61
+ "browserify:cypress": "cypress run --config-file cypressBrowserify.config.js --headless --browser chrome",
62
+ "browserify:cypressHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.config.js --headless --browser chrome",
63
+ "browserify:cypressEdge": "cypress run --config-file cypressBrowserify.config.js --headless --browser edge",
64
+ "browserify:cypressEdgeHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressBrowserify.config.js --headless --browser edge",
65
+ "webpack:cypress": "cypress run --config-file cypressWebpack.config.js --headless --browser chrome",
66
+ "webpack:cypressHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.config.js --headless --browser chrome",
67
+ "webpack:cypressEdge": "cypress run --config-file cypressWebpack.config.js --headless --browser edge",
68
+ "webpack:cypressEdgeHttps": "cypress run -e CASS_LOOPBACK=https://localhost/api/ --config-file cypressWebpack.config.js --headless --browser edge"
65
69
  },
66
70
  "contributors": [
67
71
  {
@@ -86,17 +90,17 @@
86
90
  }
87
91
  ],
88
92
  "dependencies": {
89
- "axios": "^0.27.2",
93
+ "axios": "^1.1.3",
90
94
  "base64-arraybuffer": "^1.0.2",
91
95
  "forge": "^2.3.0",
92
96
  "form-data": "^4.0.0",
93
97
  "http2-wrapper": "^2.1.11",
94
- "jsonld": "^5.2.0",
98
+ "jsonld": "^8.1.0",
95
99
  "node-forge": "^1.3.1",
96
100
  "papaparse": "^5.3.2",
97
101
  "pem-jwk": "^2.0.0",
98
102
  "promise-worker": "^2.0.1",
99
- "rdf-canonize": "^3.0.0",
103
+ "rdf-canonize": "^3.3.0",
100
104
  "web-worker": "^1.2.0"
101
105
  },
102
106
  "files": [
@@ -121,25 +125,25 @@
121
125
  },
122
126
  "homepage": "https://github.com/cassproject/cass-npm#readme",
123
127
  "devDependencies": {
124
- "@babel/core": "^7.18.6",
125
- "@babel/preset-env": "^7.18.6",
128
+ "@babel/core": "^7.19.3",
129
+ "@babel/preset-env": "^7.19.4",
126
130
  "@cypress/browserify-preprocessor": "^3.0.2",
127
- "@cypress/vite-dev-server": "^2.2.3",
128
- "@cypress/webpack-preprocessor": "^5.12.0",
131
+ "@cypress/vite-dev-server": "^3.3.1",
132
+ "@cypress/webpack-preprocessor": "^5.14.0",
129
133
  "babel-eslint": "^10.1.0",
130
134
  "babel-loader": "^8.2.5",
131
135
  "babel-plugin-transform-remove-strict-mode": "^0.0.2",
132
136
  "chai": "^4.3.6",
133
- "concurrently": "^7.2.2",
137
+ "concurrently": "^7.4.0",
134
138
  "convert-hrtime": "^5.0.0",
135
- "cypress": "^9.7.0",
136
- "eslint": "^8.17.0",
137
- "mocha": "^10.0.0",
138
- "node-polyfill-webpack-plugin": "^1.1.4",
139
- "nodemon": "^2.0.18",
139
+ "cypress": "^10.10.0",
140
+ "eslint": "^8.25.0",
141
+ "mocha": "^10.1.0",
142
+ "node-polyfill-webpack-plugin": "^2.0.1",
143
+ "nodemon": "^2.0.20",
140
144
  "nyc": "^15.1.0",
141
145
  "wait-on": "^6.0.1",
142
- "webpack": "^5.73.0",
146
+ "webpack": "^5.74.0",
143
147
  "webpack-cli": "^4.10.0"
144
148
  }
145
149
  }
@@ -1,3 +1,9 @@
1
+ const envHttp2 = process.env.HTTP2 != null ? process.env.HTTP2.trim() == 'true' : true;
2
+ if (!envHttp2)
3
+ {
4
+ global.axios = require("axios"); //Pre-empt http2 use.
5
+ }
6
+ const EcRemote = require("../remote/EcRemote.js");
1
7
  let EcFrameworkGraph = require("./EcFrameworkGraph.js");
2
8
  const EcFramework = require("../../../../org/cass/competency/EcFramework.js");
3
9
  let chai = require("chai");
@@ -12,9 +18,6 @@ const EcRsaOaepAsyncWorker = require("../crypto/EcRsaOaepAsyncWorker.js");
12
18
  const EcIdentityManager = require("../../../../org/cassproject/ebac/identity/EcIdentityManager");
13
19
  const EcAes = require("../crypto/EcAes.js");
14
20
  const fs = require('fs');
15
- const https = require('https');
16
- const EcCrypto = require("../../../../com/eduworks/ec/crypto/EcCrypto.js");
17
- const EcEncryptedValue = require("../../../../org/cassproject/ebac/repository/EcEncryptedValue.js");
18
21
 
19
22
  let hrtime = function() {
20
23
  try {
@@ -50,9 +53,10 @@ var failure = function (p1) {
50
53
  };
51
54
 
52
55
  if (fs.readFileSync != null) {
53
- https.globalAgent.options.key = fs.readFileSync('client.key');
54
- https.globalAgent.options.cert = fs.readFileSync('client.crt');
55
- https.globalAgent.options.ca = fs.readFileSync('ca.crt');
56
+ // https.globalAgent.options.key = fs.readFileSync('client.key');
57
+ // https.globalAgent.options.cert = fs.readFileSync('client.crt');
58
+ // https.globalAgent.options.ca = fs.readFileSync('ca.crt');
59
+ process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
56
60
  }
57
61
 
58
62
  let repo = new EcRepository();
@@ -152,7 +156,7 @@ describe("EcFrameworkGraph", () => {
152
156
  var encrypted = await EcRsaOaepAsyncWorker.encrypt(pk, randomString);
153
157
  var decrypted = await EcRsaOaepAsyncWorker.decrypt(ppk, encrypted);
154
158
  assert.isTrue(randomString == decrypted);
155
- }).timeout(10000);
159
+ })
156
160
  it('basic true test', async () => {
157
161
  let f = await newFramework("basic true framework");
158
162
  let c = await newCompetency("Add");
@@ -189,7 +193,7 @@ describe("EcFrameworkGraph", () => {
189
193
  await deleteById(a.shortId());
190
194
  });
191
195
  assert.deepEqual(result, [1]);
192
- }).timeout(15000);
196
+ })
193
197
  it('basic false test', async () => {
194
198
  var f = await newFramework("basic false framework");
195
199
  var c = await newCompetency("Add");
@@ -229,7 +233,7 @@ describe("EcFrameworkGraph", () => {
229
233
  await deleteById(a.shortId());
230
234
  });
231
235
  assert.deepEqual(result, [1]);
232
- }).timeout(10000);
236
+ })
233
237
  it('basic indeterminant test', async () => {
234
238
  var f = await newFramework("basic indeterminant framework");
235
239
  var c = await newCompetency("Add");
@@ -271,7 +275,7 @@ describe("EcFrameworkGraph", () => {
271
275
  await deleteById(a2.shortId());
272
276
  });
273
277
  assert.deepEqual(result, [1, 1]);
274
- }).timeout(10000);
278
+ })
275
279
  it('basic unknown test', async () => {
276
280
  var f = await newFramework("basic unknown framework");
277
281
  var c = await newCompetency("Add");
@@ -305,7 +309,7 @@ describe("EcFrameworkGraph", () => {
305
309
  await deleteById(c.shortId());
306
310
  });
307
311
  assert.deepEqual(result, [undefined, undefined]);
308
- }).timeout(10000);
312
+ })
309
313
  it('basic equivalence test', async () => {
310
314
  var f = await newFramework("basic equivalence framework");
311
315
  var c = await newCompetency("Add");
@@ -350,7 +354,7 @@ describe("EcFrameworkGraph", () => {
350
354
  await deleteById(r.shortId());
351
355
  });
352
356
  assert.deepEqual(result, [1, 1]);
353
- }).timeout(10000);
357
+ })
354
358
  it('basic equivalence false test', async () => {
355
359
  var f = await newFramework("basic equivalence false framework");
356
360
  var c = await newCompetency("Add");
@@ -395,7 +399,7 @@ describe("EcFrameworkGraph", () => {
395
399
  await deleteById(r.shortId());
396
400
  });
397
401
  assert.deepEqual(result, [1, 1]);
398
- }).timeout(10000);
402
+ })
399
403
  it('basic equivalence indeterminant test', async () => {
400
404
  var f = await newFramework("basic equivalence indeterminant framework");
401
405
  var c = await newCompetency("Add");
@@ -447,7 +451,7 @@ describe("EcFrameworkGraph", () => {
447
451
  await deleteById(r.shortId());
448
452
  });
449
453
  assert.deepEqual(result, [1, 1, 1, 1]);
450
- }).timeout(10000);
454
+ })
451
455
  it('basic equivalence unknown test', async () => {
452
456
  var f = await newFramework("basic equivalence unknown framework");
453
457
  var c = await newCompetency("Add");
@@ -489,7 +493,7 @@ describe("EcFrameworkGraph", () => {
489
493
  await deleteById(r.shortId());
490
494
  });
491
495
  assert.deepEqual(result, [undefined, undefined, undefined, undefined]);
492
- }).timeout(10000);
496
+ })
493
497
  it('basic equivalence equivalence test', async () => {
494
498
  var f = await newFramework("basic equivalence equivalence framework");
495
499
  var c = await newCompetency("Add");
@@ -542,7 +546,7 @@ describe("EcFrameworkGraph", () => {
542
546
  await deleteById(r2.shortId());
543
547
  });
544
548
  assert.deepEqual(result, [1, 1, 1]);
545
- }).timeout(10000);
549
+ })
546
550
  it('basic equivalence unequivalent test', async () => {
547
551
  var f = await newFramework("basic equivalence unequivalent framework");
548
552
  var c = await newCompetency("Add");
@@ -590,7 +594,7 @@ describe("EcFrameworkGraph", () => {
590
594
  await deleteById(r.shortId());
591
595
  });
592
596
  assert.deepEqual(result, [undefined, undefined, 1]);
593
- }).timeout(10000);
597
+ })
594
598
  it('basic requires satisfied test', async () => {
595
599
  var f = await newFramework("basic requires satisfied framework");
596
600
  var c = await newCompetency("Add");
@@ -635,7 +639,7 @@ describe("EcFrameworkGraph", () => {
635
639
  await deleteById(r.shortId());
636
640
  });
637
641
  assert.deepEqual(result, [1, 1]);
638
- }).timeout(10000);
642
+ })
639
643
  it('basic requires false test', async () => {
640
644
  var f = await newFramework("basic requires false framework");
641
645
  var c = await newCompetency("Add");
@@ -680,7 +684,7 @@ describe("EcFrameworkGraph", () => {
680
684
  await deleteById(r.shortId());
681
685
  });
682
686
  assert.deepEqual(result, [1, 1]);
683
- }).timeout(10000);
687
+ })
684
688
  it('basic narrows true test', async () => {
685
689
  var f = await newFramework("basic narrows true framework");
686
690
  var c = await newCompetency("Add");
@@ -725,7 +729,7 @@ describe("EcFrameworkGraph", () => {
725
729
  await deleteById(r.shortId());
726
730
  });
727
731
  assert.deepEqual(result, [1, 1]);
728
- }).timeout(10000);
732
+ })
729
733
  it('basic narrows false test', async () => {
730
734
  var f = await newFramework("basic narrows false framework");
731
735
  var c = await newCompetency("Add");
@@ -770,7 +774,7 @@ describe("EcFrameworkGraph", () => {
770
774
  await deleteById(r.shortId());
771
775
  });
772
776
  assert.deepEqual(result, [1, 1]);
773
- }).timeout(10000);
777
+ })
774
778
  it('basic narrows narrows test', async () => {
775
779
  var f = await newFramework("basic narrows narrows framework");
776
780
  var c = await newCompetency("Add");
@@ -823,7 +827,7 @@ describe("EcFrameworkGraph", () => {
823
827
  await deleteById(r2.shortId());
824
828
  });
825
829
  assert.deepEqual(result, [1, 1, 1]);
826
- }).timeout(10000);
830
+ })
827
831
  it('basic narrows narrows false test', async () => {
828
832
  var f = await newFramework("basic narrows narrows false framework");
829
833
  var c = await newCompetency("Add");
@@ -876,7 +880,7 @@ describe("EcFrameworkGraph", () => {
876
880
  await deleteById(r2.shortId());
877
881
  });
878
882
  assert.deepEqual(result, [1, 1, 1]);
879
- }).timeout(10000);
883
+ })
880
884
  it('callbacks removed test', async () => {
881
885
  var f = await newFramework("callbacks removed framework");
882
886
  var c = await newCompetency("Add");
@@ -912,5 +916,5 @@ describe("EcFrameworkGraph", () => {
912
916
  await deleteById(a.shortId());
913
917
  });
914
918
  assert.deepEqual(result, [1]);
915
- }).timeout(10000);
919
+ })
916
920
  });
@@ -26,9 +26,10 @@ if (isNode)
26
26
 
27
27
  global.httpOptions = [];
28
28
  global.http2Enabled = {};
29
+ let axios = null;
29
30
  if (global.axios == null)
30
31
  {
31
- global.axios = require("axios");
32
+ global.axios = axios = require("axios");
32
33
  if (isNode)
33
34
  {
34
35
  let http2;
@@ -61,8 +62,9 @@ if (global.axios == null)
61
62
  while (global.httpOptions.length > 0)
62
63
  {
63
64
  let options = global.httpOptions.pop();
65
+ options.ca = global.ca;
64
66
  options.ALPNProtocols = ['h2', 'http/1.1'];
65
- if (options.port == null)
67
+ if (options.port == null || options.port == '')
66
68
  options.port = 443;
67
69
  let result = await http2.auto.resolveProtocol(options);
68
70
  if (result.alpnProtocol == "http/1.1")
@@ -84,6 +86,7 @@ if (global.axios == null)
84
86
  axiosOptions.adapter = http2AdapterEnhancer(axios.defaults.adapter);
85
87
  }
86
88
  } else {
89
+ axios = global.axios;
87
90
  if (isNode)
88
91
  {
89
92
  let https;
@@ -230,17 +233,19 @@ module.exports = class EcRemote {
230
233
  url = EcRemote.upgradeHttpToHttps(url);
231
234
  let postHeaders = null;
232
235
  if (fd.getHeaders != null)
236
+ {
233
237
  postHeaders = fd.getHeaders();
234
- else
235
- postHeaders = {
236
- 'content-type': 'multipart/form-data'
237
- }
238
+ postHeaders["Content-Type"] = null;
239
+ }
240
+ else
241
+ postHeaders = {
242
+ "Content-Type": null
243
+ }
238
244
  if (fd.getLengthSync != null)
239
245
  postHeaders["content-length"] = fd.getLengthSync();
240
246
  if (headers !== undefined && headers != null)
241
247
  for (let header in headers) postHeaders[header] = headers[header];
242
- let p = axios
243
- .post(url, fd, {
248
+ let p = axios.post(url, fd, {
244
249
  ...axiosOptions,
245
250
  headers: postHeaders,
246
251
  maxContentLength: Infinity,
@@ -252,7 +257,7 @@ module.exports = class EcRemote {
252
257
  })
253
258
  .catch((err) => {
254
259
  if (err != null) {
255
- global.auditLogger.report(global.auditLogger.LogCategory.NETWORK, global.auditLogger.Severity.ERROR, "EcRemotePostInner", err && err.response && err.response.request.socket ? err.response.request.socket.remoteAddress : '', url, postHeaders, err);
260
+ global.auditLogger.report(global.auditLogger.LogCategory.NETWORK, global.auditLogger.Severity.ERROR, "EcRemotePostInner", err && err.response && err.response.request && err.response.request.socket ? err.response.request.socket.remoteAddress : '', url, postHeaders, err);
256
261
  if (err.response != null) {
257
262
  if (err.response.data != null)
258
263
  throw err.response.data;
@@ -303,7 +308,7 @@ module.exports = class EcRemote {
303
308
  return response.data;
304
309
  })
305
310
  .catch((err) => {
306
- global.auditLogger.report(global.auditLogger.LogCategory.NETWORK, global.auditLogger.Severity.ERROR, "EcRemoteGetExpectString", err && err.response && err.response.request.socket ? err.response.request.socket.remoteAddress : '', url, err);
311
+ global.auditLogger.report(global.auditLogger.LogCategory.NETWORK, global.auditLogger.Severity.ERROR, "EcRemoteGetExpectString", err && err.response && err.response.request && err.response.request.socket ? err.response.request.socket.remoteAddress : '', url, err);
307
312
  if (err) {
308
313
  if (err.response) {
309
314
  if (err.response.data)
@@ -317,7 +322,7 @@ module.exports = class EcRemote {
317
322
  }
318
323
  static urlAppend(server, service) {
319
324
  var url = server;
320
- if (!url.endsWith("/") && service != null && service.equals("")) {
325
+ if (!url.endsWith("/") && service != null && service == "") {
321
326
  url += "/";
322
327
  }
323
328
  if (service != null) {
@@ -350,7 +355,7 @@ module.exports = class EcRemote {
350
355
  return response.data;
351
356
  })
352
357
  .catch((err) => {
353
- global.auditLogger.report(global.auditLogger.LogCategory.NETWORK, global.auditLogger.Severity.ERROR, "EcRemoteDelete", err && err.response && err.response.request.socket ? err.response.request.socket.remoteAddress : '', url, signatureSheet, err);
358
+ global.auditLogger.report(global.auditLogger.LogCategory.NETWORK, global.auditLogger.Severity.ERROR, "EcRemoteDelete", err && err.response && err.response.request && err.response.request.socket ? err.response.request.socket.remoteAddress : '', url, signatureSheet, err);
354
359
  if (err) {
355
360
  if (err.response) {
356
361
  if (err.response.data)
@@ -21,6 +21,7 @@ module.exports = class CTDLASNCSVConceptImport {
21
21
  nameToCol[colNames[i]] = i;
22
22
  var conceptSchemeCounter = 0;
23
23
  var conceptCounter = 0;
24
+ var progressionCounter = 0;
24
25
  var typeCol = nameToCol["@type"];
25
26
  if (typeCol == null) {
26
27
  this.error("No @type in CSV.");
@@ -29,9 +30,10 @@ module.exports = class CTDLASNCSVConceptImport {
29
30
  for (var i = 0; i < tabularData.length; i++) {
30
31
  if (i == 0) continue;
31
32
  var col = tabularData[i];
32
- if (col[typeCol] == "skos:ConceptScheme")
33
- conceptSchemeCounter++;
33
+ if (col[typeCol] == "skos:ConceptScheme") conceptSchemeCounter++;
34
+ else if (col[typeCol] == "ceasn:ProgressionModel") progressionCounter++;
34
35
  else if (col[typeCol] == "skos:Concept") conceptCounter++;
36
+ else if (col[typeCol] == "ceasn:ProgressionLevel") conceptCounter++;
35
37
  else if (col[typeCol] == null || col[typeCol] == "")
36
38
  continue;
37
39
  else {
@@ -39,7 +41,7 @@ module.exports = class CTDLASNCSVConceptImport {
39
41
  return;
40
42
  }
41
43
  }
42
- success(conceptSchemeCounter, conceptCounter);
44
+ success(conceptSchemeCounter, conceptCounter, progressionCounter);
43
45
  },
44
46
  error: failure
45
47
  });
@@ -51,7 +53,8 @@ module.exports = class CTDLASNCSVConceptImport {
51
53
  failure,
52
54
  ceo,
53
55
  endpoint,
54
- eim
56
+ eim,
57
+ progressionsFlag
55
58
  ) {
56
59
  if (eim === undefined || eim == null)
57
60
  eim = EcIdentityManager.default;
@@ -64,6 +67,9 @@ module.exports = class CTDLASNCSVConceptImport {
64
67
  } else if (!file["name"].endsWith(".csv")) {
65
68
  failure("Invalid file type");
66
69
  }
70
+ if (progressionsFlag) {
71
+ return this.importProgressions(repo, file, success, failure, ceo, endpoint, eim);
72
+ }
67
73
  Papa.parse(file, {
68
74
  header: true,
69
75
  encoding: "UTF-8",
@@ -74,6 +80,15 @@ module.exports = class CTDLASNCSVConceptImport {
74
80
  var concepts = [];
75
81
  for (let each = 0; each < tabularData.length; each++) {
76
82
  let pretranslatedE = tabularData[each];
83
+ // Probably an empty newline, skip
84
+ if (!pretranslatedE["@id"]) {
85
+ continue;
86
+ }
87
+ if (
88
+ pretranslatedE["@type"].toLowerCase().startsWith('sample') || pretranslatedE["@type"].toLowerCase().startsWith('instruction')
89
+ ) {
90
+ continue;
91
+ }
77
92
  if (pretranslatedE["@type"] == "skos:ConceptScheme") {
78
93
  var translator = new EcLinkedData(null, null);
79
94
  translator.copyFrom(pretranslatedE);
@@ -291,4 +306,207 @@ module.exports = class CTDLASNCSVConceptImport {
291
306
  error: failure
292
307
  });
293
308
  }
309
+ static importProgressions(
310
+ repo,
311
+ file,
312
+ success,
313
+ failure,
314
+ ceo,
315
+ endpoint,
316
+ eim
317
+ ) {
318
+ Papa.parse(file, {
319
+ header: true,
320
+ encoding: "UTF-8",
321
+ complete: async function(results) {
322
+ var tabularData = results["data"];
323
+ const terms = JSON.parse(JSON.stringify((await EcRemote.getExpectingObject("https://schema.cassproject.org/0.4/jsonld1.1/ceasn2cassConceptsTerms"))));
324
+ var schemeArray = [];
325
+ var concepts = [];
326
+ for (let each = 0; each < tabularData.length; each++) {
327
+ let pretranslatedE = tabularData[each];
328
+ if (pretranslatedE["@type"] == "ceasn:ProgressionModel") {
329
+ var translator = new EcLinkedData(null, null);
330
+ translator.copyFrom(pretranslatedE);
331
+ CTDLASNCSVImport.cleanUpTranslator(
332
+ translator,
333
+ endpoint,
334
+ repo
335
+ );
336
+ if (translator["ceasn:name"] != null) {
337
+ var name = translator["ceasn:name"];
338
+ var nameWithLanguage = {};
339
+ nameWithLanguage["en-US"] = name;
340
+ translator["ceasn:name"] = nameWithLanguage;
341
+ }
342
+ for (let each in translator) {
343
+ if (terms[each]) {
344
+ translator[terms[each]] = translator[each];
345
+ delete translator[each];
346
+ }
347
+ }
348
+ let e = await translator.recast(
349
+ "https://schema.cassproject.org/0.4/jsonld1.1/ceasn2cassConcepts.json",
350
+ "https://schema.cassproject.org/0.4/skos"
351
+ );
352
+ e.type = "ConceptScheme";
353
+ var f = new EcConceptScheme();
354
+ f.copyFrom(e);
355
+ if (EcConceptScheme.template != null) {
356
+ for (var key in EcConceptScheme.template) {
357
+ if (key.equals("@owner")) {
358
+ f["owner"] =
359
+ EcConceptScheme.template[
360
+ key
361
+ ];
362
+ } else {
363
+ f[key] =
364
+ EcConceptScheme.template[
365
+ key
366
+ ];
367
+ }
368
+ }
369
+ }
370
+ if (e["owner"] != null) {
371
+ var id = new EcIdentity();
372
+ id.ppk = EcPpk.fromPem(e["owner"]);
373
+ f.addOwner(id.ppk.toPk());
374
+ eim.addIdentityQuietly(
375
+ id
376
+ );
377
+ }
378
+ if (ceo != null) f.addOwner(ceo.ppk.toPk());
379
+ f[
380
+ "schema:dateModified"
381
+ ] = new Date().toISOString();
382
+ if (
383
+ EcConceptScheme.template != null &&
384
+ EcConceptScheme.template[
385
+ "schema:dateCreated"
386
+ ] != null
387
+ ) {
388
+ CTDLASNCSVImport.setDateCreated(e, f);
389
+ }
390
+ f.subType = "Progression";
391
+ schemeArray.push(f);
392
+ } else if (pretranslatedE["@type"] == "ceasn:ProgressionLevel") {
393
+ var translator = new EcLinkedData(null, null);
394
+ translator.copyFrom(pretranslatedE);
395
+ CTDLASNCSVImport.cleanUpTranslator(
396
+ translator,
397
+ endpoint,
398
+ repo
399
+ );
400
+ if (translator["skos:prefLabel"] != null) {
401
+ var name = translator["skos:prefLabel"];
402
+ var nameWithLanguage = {};
403
+ nameWithLanguage["en-US"] = name;
404
+ translator["skos:prefLabel"] = nameWithLanguage;
405
+ }
406
+ for (let each in translator) {
407
+ if (terms[each]) {
408
+ translator[terms[each]] = translator[each];
409
+ delete translator[each];
410
+ }
411
+ }
412
+ let e = await translator.recast(
413
+ "https://schema.cassproject.org/0.4/jsonld1.1/ceasn2cassConcepts.json",
414
+ "https://schema.cassproject.org/0.4/skos"
415
+ );
416
+ e.type = "Concept";
417
+ var f = new EcConcept();
418
+ f.copyFrom(e);
419
+ if (e["id"] == null) {
420
+ return;
421
+ }
422
+ if (
423
+ EcConcept.template != null &&
424
+ EcConcept.template["@owner"] != null
425
+ ) {
426
+ f["owner"] =
427
+ EcConcept.template["@owner"];
428
+ }
429
+ if (e["owner"] != null) {
430
+ var id = new EcIdentity();
431
+ id.ppk = EcPpk.fromPem(e["owner"]);
432
+ if (id.ppk != null)
433
+ f.addOwner(id.ppk.toPk());
434
+ eim.addIdentityQuietly(
435
+ id
436
+ );
437
+ }
438
+ if (ceo != null) f.addOwner(ceo.ppk.toPk());
439
+ if (
440
+ EcConcept.template != null &&
441
+ EcConcept.template[
442
+ "schema:dateCreated"
443
+ ] != null
444
+ ) {
445
+ CTDLASNCSVImport.setDateCreated(e, f);
446
+ }
447
+ if (e["skos:narrower"] != null) {
448
+ var relation = e["skos:narrower"];
449
+ if (!EcArray.isArray(relation)) {
450
+ var array = [relation];
451
+ f["skos:narrower"] = array;
452
+ }
453
+ }
454
+ if (e["skos:broader"] != null) {
455
+ var relation = e["skos:broader"];
456
+ if (!EcArray.isArray(relation)) {
457
+ var array = [relation];
458
+ f["skos:broader"] = array;
459
+ }
460
+ }
461
+ if (e["skos:topConceptOf"] != null) {
462
+ var scheme = e["skos:topConceptOf"];
463
+ for (
464
+ var i = 0;
465
+ i < schemeArray.length;
466
+ i++
467
+ ) {
468
+ var schemeObj = schemeArray[i];
469
+ if (scheme == schemeObj["id"]) {
470
+ if (
471
+ schemeObj[
472
+ "skos:hasTopConcept"
473
+ ] == null
474
+ ) {
475
+ var hasTopConcept = [];
476
+ schemeObj[
477
+ "skos:hasTopConcept"
478
+ ] = hasTopConcept;
479
+ }
480
+ var conceptId = f.shortId();
481
+ EcArray.setAdd(
482
+ schemeObj[
483
+ "skos:hasTopConcept"
484
+ ],
485
+ conceptId
486
+ );
487
+ }
488
+ }
489
+ }
490
+ f[
491
+ "schema:dateModified"
492
+ ] = new Date().toISOString();
493
+ f.subType = "Progression";
494
+ concepts.push(f);
495
+ } else if (
496
+ pretranslatedE["@type"] == null ||
497
+ pretranslatedE["@type"] == ""
498
+ ) {
499
+ return;
500
+ } else {
501
+ this.error(
502
+ "Found unknown type:" + pretranslatedE["@type"]
503
+ );
504
+ return;
505
+ }
506
+ }
507
+ success(schemeArray, concepts);
508
+ },
509
+ error: failure
510
+ });
511
+ }
294
512
  };
@@ -46,7 +46,7 @@ module.exports = class CTDLASNCSVImport {
46
46
  col[typeCol].trim() == "ceasn:Competency"
47
47
  )
48
48
  competencyCounter++;
49
- else if (col[typeCol] == null || col[typeCol] == "")
49
+ else if (col[typeCol] == null || col[typeCol] == "" || col[typeCol].toLowerCase().startsWith('sample') || col[typeCol].toLowerCase().startsWith('instruction'))
50
50
  continue;
51
51
  else {
52
52
  this.error("Found unknown type:" + col[typeCol]);
@@ -97,6 +97,11 @@ module.exports = class CTDLASNCSVImport {
97
97
  var relationById = {};
98
98
  for (let i = 0; i < tabularData.length; i++) {
99
99
  let pretranslatedE = tabularData[i];
100
+ if (
101
+ pretranslatedE["@type"].toLowerCase().startsWith('sample') || pretranslatedE["@type"].toLowerCase().startsWith('instruction')
102
+ ) {
103
+ continue;
104
+ }
100
105
  if (
101
106
  pretranslatedE["@type"] ==
102
107
  "ceasn:CompetencyFramework"
@@ -517,6 +522,11 @@ module.exports = class CTDLASNCSVImport {
517
522
  var relationById = {};
518
523
  for (let i = 0; i < tabularData.length; i++) {
519
524
  let pretranslatedE = tabularData[i];
525
+ if (
526
+ pretranslatedE["@type"].toLowerCase().startsWith('sample') || pretranslatedE["@type"].toLowerCase().startsWith('instruction')
527
+ ) {
528
+ continue;
529
+ }
520
530
  if (
521
531
  pretranslatedE["@type"] ==
522
532
  "ceterms:Collection"
@@ -1,3 +1,4 @@
1
+ const EcCrypto = require("../../../../com/eduworks/ec/crypto/EcCrypto");
1
2
  const EcPk = require("../../../../com/eduworks/ec/crypto/EcPk");
2
3
  const EcPpkFacade = require("../../../../com/eduworks/ec/crypto/EcPpkFacade");
3
4
  const EcRsaOaepAsync = require("../../../../com/eduworks/ec/crypto/EcRsaOaepAsync");
@@ -20,6 +21,7 @@ module.exports = class EcIdentityManager {
20
21
  static default = new this();
21
22
  constructor() {
22
23
  }
24
+ eimId = EcCrypto.generateUUID();
23
25
  /**
24
26
  * The current user's owned identities (keys+displayName)
25
27
  *
@@ -0,0 +1,30 @@
1
+ const chai = require("chai");
2
+ const EcPpkFacade = require("../../../../com/eduworks/ec/crypto/EcPpkFacade");
3
+ const EcRsaOaepAsyncWorker = require("../../../../com/eduworks/ec/crypto/EcRsaOaepAsyncWorker");
4
+
5
+ let hrtime = function() {
6
+ try {
7
+ return [Math.round(performance.now()/1000), performance.now() * 1000];
8
+ } catch (e) {
9
+ // Eat quietly.
10
+ }
11
+ return process.hrtime();
12
+ };
13
+
14
+ var should = chai.should();
15
+ var expect = chai.expect;
16
+ var assert = chai.assert;
17
+
18
+ after(()=>EcRsaOaepAsyncWorker.teardown());
19
+
20
+ describe("EcIdentityManager", () => {
21
+ it('real simple stuff', () => {
22
+ assert.isTrue(new EcPpkFacade() instanceof EcPpkFacade);
23
+ })
24
+ it('real simple stuff 2', () => {
25
+ assert.isTrue(new EcPpkFacade() instanceof require("../../../../com/eduworks/ec/crypto/EcPpkFacade"));
26
+ })
27
+ it('real simple stuff 3', () => {
28
+ assert.isTrue(new (require("../../../../com/eduworks/ec/crypto/EcPpkFacade"))() instanceof require("../../../../com/eduworks/ec/crypto/EcPpkFacade"));
29
+ })
30
+ });
@@ -1,21 +1,21 @@
1
- let chai = require("chai");
2
- const EcAes = require("../../../../../com/eduworks/ec/crypto/EcAes");
3
- const EcPpk = require("../../../../../com/eduworks/ec/crypto/EcPpk");
4
- const EcIdentity = require("../EcIdentity");
5
- const EcIdentityManager = require("../EcIdentityManager");
6
- const EcRemoteIdentityManager = require("./EcRemoteIdentityManager");
7
-
8
- var should = chai.should();
9
- var expect = chai.expect;
10
- var assert = chai.assert;
11
-
12
- describe("EcRemoteIdentityManager", () => {
13
- it('splicePasswords', async () => {
14
- let rim= new EcRemoteIdentityManager();
15
- assert.equal(rim.splicePasswords(["abc","123"]),"a1b2c3");
16
- assert.equal(rim.splicePasswords(["abcde","123"]),"a1b2c3de");
17
- assert.equal(rim.splicePasswords(["abc","12345"]),"a1b2c345");
18
- assert.equal(rim.splicePasswords(["","123"]),"123");
19
- assert.equal(rim.splicePasswords(["abc",""]),"abc");
20
- });
1
+ const chai = require("chai");
2
+ const EcAes = require("../../../../../com/eduworks/ec/crypto/EcAes");
3
+ const EcPpk = require("../../../../../com/eduworks/ec/crypto/EcPpk");
4
+ const EcIdentity = require("../EcIdentity");
5
+ const EcIdentityManager = require("../EcIdentityManager");
6
+ const EcRemoteIdentityManager = require("./EcRemoteIdentityManager");
7
+
8
+ var should = chai.should();
9
+ var expect = chai.expect;
10
+ var assert = chai.assert;
11
+
12
+ describe("EcRemoteIdentityManager", () => {
13
+ it('splicePasswords', async () => {
14
+ let rim= new EcRemoteIdentityManager();
15
+ assert.equal(rim.splicePasswords(["abc","123"]),"a1b2c3");
16
+ assert.equal(rim.splicePasswords(["abcde","123"]),"a1b2c3de");
17
+ assert.equal(rim.splicePasswords(["abc","12345"]),"a1b2c345");
18
+ assert.equal(rim.splicePasswords(["","123"]),"123");
19
+ assert.equal(rim.splicePasswords(["abc",""]),"abc");
20
+ });
21
21
  });
@@ -1,3 +1,8 @@
1
+ const envHttp2 = process.env.HTTP2 != null ? process.env.HTTP2.trim() == 'true' : true;
2
+ if (!envHttp2)
3
+ {
4
+ global.axios = require("axios"); //Pre-empt http2 use.
5
+ }
1
6
  let FormData = require("form-data");
2
7
  const EcObject = require("../../../../com/eduworks/ec/array/EcObject");
3
8
  const EcEncryptedValue = require("./EcEncryptedValue");
@@ -71,6 +76,8 @@ module.exports = class EcRepository {
71
76
  .then(successCheck)
72
77
  .catch((error) => {
73
78
  global.auditLogger.report(global.auditLogger.LogCategory.SYSTEM, global.auditLogger.Severity.ERROR, "EcRepoTimeOffset", error);
79
+ if (failure != null)
80
+ failure(error);
74
81
  });
75
82
  };
76
83
  buildKeyForwardingTable = function (success, failure, eim) {
@@ -114,8 +121,13 @@ module.exports = class EcRepository {
114
121
  if (url.toLowerCase().indexOf("http") != 0) {
115
122
  throw "URL does not begin with http. Cannot EcRepository.get";
116
123
  }
124
+
117
125
  if (eim === undefined || eim == null)
118
126
  eim = EcIdentityManager.default;
127
+ if (EcRepository.fetching[url+eim.eimId] != null)
128
+ {
129
+ return cassPromisify(EcRepository.fetching[url+eim.eimId],success,failure);
130
+ }
119
131
  var originalUrl = url;
120
132
  if (EcRepository.caching) {
121
133
  if (EcRepository.cache[url] !== undefined) {
@@ -231,7 +243,13 @@ module.exports = class EcRepository {
231
243
  throw error;
232
244
  });
233
245
  }
234
- });
246
+ }).finally(
247
+ (result)=>{
248
+ delete EcRepository.fetching[url+eim.eimId];
249
+ return result;
250
+ }
251
+ );
252
+ EcRepository.fetching[url+eim.eimId] = p;
235
253
  return p;
236
254
  }
237
255
  static setOffset = function (url) {
@@ -465,7 +483,7 @@ module.exports = class EcRepository {
465
483
  };
466
484
  /**
467
485
  * Attempts to save a piece of data. Does some checks before saving to
468
- * ensure the data is valid. This version does not send a console warning,
486
+ * ensure the data is valid. This version does not send a console warning,
469
487
  * <p>
470
488
  * Uses a signature sheet informed by the owner field of the data.
471
489
  *
@@ -1,5 +1,5 @@
1
+ const EcRemote = require("../../../../com/eduworks/ec/remote/EcRemote.js");
1
2
  const EcFramework = require("../../../../org/cass/competency/EcFramework.js");
2
- let chai = require("chai");
3
3
  const EcRepository = require("../../../../org/cassproject/ebac/repository/EcRepository.js");
4
4
  const EcIdentity = require("../../../../org/cassproject/ebac/identity/EcIdentity.js");
5
5
  const EcAssertion = require("../../../../org/cass/profile/EcAssertion.js");
@@ -18,6 +18,8 @@ const schema = {
18
18
  "Thing": require("../../../schema/Thing.js")
19
19
  };
20
20
 
21
+ let chai = require("chai");
22
+
21
23
  let hrtime = function() {
22
24
  try {
23
25
  return [Math.round(performance.now()/1000), performance.now() * 1000];
@@ -59,7 +61,7 @@ if (fs.readFileSync != null) {
59
61
  // global.axiosOptions.cert = fs.readFileSync('client.crt');
60
62
  // global.axiosOptions.ca = fs.readFileSync('ca.crt');
61
63
  //When http2 supports client side self-signed certificates, don't use this.
62
- process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
64
+ //process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
63
65
  }
64
66
 
65
67
  let changeNameAndSaveAndCheck = async (rld) => {
@@ -196,7 +196,7 @@ global.jsonld = require("jsonld");
196
196
  /**
197
197
  * Also could be called "upcast", for those in the know.
198
198
  * <p>
199
- * Ghetto method of copying properties from some other object. As freshly
199
+ * A method of copying properties from some other object. As freshly
200
200
  * deserialized javascript objects do not inherently attach the functions of
201
201
  * their type, it is this or factory hell.
202
202
  *
@@ -3,34 +3,14 @@ const EcRepository = require("../cassproject/ebac/repository/EcRepository");
3
3
 
4
4
  module.exports = class EcPerson extends schema.Person {
5
5
  static async getByPk(repo, pk, success, failure, eim) {
6
- let p = await EcPerson.get(
7
- repo.selectedServer +
8
- (repo.selectedServer.endsWith("/") ? "" : "/") +
9
- "data/" +
10
- pk.fingerprint(),
11
- null,
12
- null, repo, eim
13
- );
14
- if (p != null)
15
- return cassReturnAsPromise(p, success, failure);
16
- return EcPerson.search(repo, pk.fingerprint(),
17
- (persons)=>{
18
- if (persons.length === 0) {
19
- if (failure != null)
20
- failure("Person not found.");
21
- return null;
22
- }
23
- if (EcRepository.caching)
24
- EcRepository.cache[repo.selectedServer +(repo.selectedServer.endsWith("/") ? "" : "/") +"data/" +pk.fingerprint()] = persons[0];
25
- return cassReturnAsPromise(persons[0], success, failure);
26
- },
27
- failure, repo, eim
28
- );
6
+ let p = new EcPerson();
7
+ p.assignId((repo.selectedServerProxy == null ? repo.selectedServer : repo.selectedServerProxy),pk.fingerprint());
8
+ let results = await EcPerson.get(p.shortId(),success,failure,repo,eim);
9
+ return results;
29
10
  }
30
11
  static getByPkBlocking(repo, pk, eim) {
31
12
  return EcPerson.get(
32
- repo.selectedServer +
33
- (repo.selectedServer.endsWith("/") ? "" : "/") +
13
+ repo.selectedServerProxy == null ? repo.selectedServer : repo.selectedServerProxy +
34
14
  "data/" +
35
15
  pk.fingerprint(), null, null, repo, eim
36
16
  );