Skip to content

Commit

Permalink
Fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lomilar committed Sep 26, 2024
1 parent 569384d commit 4a9b79a
Show file tree
Hide file tree
Showing 14 changed files with 112 additions and 47 deletions.
7 changes: 6 additions & 1 deletion cypressWebpack/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// the project's config changing)
const webpackPreprocessor = require('@cypress/webpack-preprocessor')
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
const webpack = require('webpack');

/**
* @type {Cypress.PluginConfig}
Expand All @@ -24,7 +25,11 @@ module.exports = (on, config) => {

on('file:preprocessor', webpackPreprocessor({
webpackOptions: {
plugins: [ new NodePolyfillPlugin() ],
plugins: [new NodePolyfillPlugin(),
new webpack.ProvidePlugin({
process: 'process/browser',
}),
],
externals: {
"http2-wrapper": "http2",
"node:dns":"commonjs node:dns"
Expand Down
2 changes: 1 addition & 1 deletion docker/cypress
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ COPY cypressWebpack.config.js cypressWebpack.config.js
COPY cypressBrowserify.config.js cypressBrowserify.config.js
COPY cypressVite cypressVite
COPY cypressVite.config.js cypressVite.config.js
ENTRYPOINT cypress run -e CASS_LOOPBACK=${CASS_LOOPBACK} --config-file cypressWebpack.config.js --browser edge && cypress run -e CASS_LOOPBACK=${CASS_LOOPBACK} --config-file cypressWebpack.config.js --browser chrome && cypress run -e CASS_LOOPBACK=${CASS_LOOPBACK} --config-file cypressWebpack.config.js
ENTRYPOINT cypress run --config-file cypressWebpack.config.js --browser edge -e CASS_LOOPBACK=${CASS_LOOPBACK} && cypress run --config-file cypressWebpack.config.js --browser chrome -e CASS_LOOPBACK=${CASS_LOOPBACK} && cypress run --config-file cypressWebpack.config.js -e CASS_LOOPBACK=${CASS_LOOPBACK}
2 changes: 1 addition & 1 deletion docker/cypressHttps
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ COPY cypressWebpack cypressWebpack
COPY cypressBrowserify cypressBrowserify
COPY cypressWebpack.config.js cypressWebpack.config.js
COPY cypressBrowserify.config.js cypressBrowserify.config.js
ENTRYPOINT cypress run -e CASS_LOOPBACK=${CASS_LOOPBACK} --config-file cypressWebpack.config.js --browser edge && cypress run -e CASS_LOOPBACK=${CASS_LOOPBACK} --config-file cypressWebpack.config.js --browser chrome && cypress run -e CASS_LOOPBACK=${CASS_LOOPBACK} --config-file cypressWebpack.config.js
ENTRYPOINT cypress run --config-file cypressWebpack.config.js --browser edge -e CASS_LOOPBACK=${CASS_LOOPBACK} && cypress run --config-file cypressWebpack.config.js --browser chrome -e CASS_LOOPBACK=${CASS_LOOPBACK} && cypress run --config-file cypressWebpack.config.js -e CASS_LOOPBACK=${CASS_LOOPBACK}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
"multitest": "concurrently --kill-others --kill-others-on-fail \"npm run test15\" \"npm run test14\" \"npm run test13\" \"npm run test12\"",
"testCassTest": "npm run testkill && docker run -d --network cass-net --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",
"testDevHttps": "npm run testkill && docker run -d --network cass-net --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",
"test15HttpsFips": "export CASS_LOOPBACK=https://cass-testsf15/api/|| set CASS_LOOPBACK=https://cass-testsf15/api/&& npm run testkill && docker run -d --network cass-net --name cass-testsf15 -p443:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.65 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode20HttpsForceFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkill",
"test15Https11Fips": "export CASS_LOOPBACK=https://cass-testsf1115/api/|| set CASS_LOOPBACK=https://cass-testsf1115/api/&& npm run testkill && docker run -d --network cass-net --name cass-testsf1115 -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.65 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode20HttpsForceFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkill",
"test15Https": "export CASS_LOOPBACK=https://cass-tests15/api/|| set CASS_LOOPBACK=https://cass-tests15/api/&& npm run testkill && docker run -d --network cass-net --name cass-tests15 -p443:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.65 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkill",
"test15Https11": "export CASS_LOOPBACK=https://cass-tests1115/api/|| set CASS_LOOPBACK=https://cass-tests1115/api/&& npm run testkill && docker run -d --network cass-net --name cass-tests1115 -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.65 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkill",
"test15Fips": "export CASS_LOOPBACK=http://cass-testf15/api/|| set CASS_LOOPBACK=http://cass-testf15/api/&& npm run testkillf15 && docker run -d --network cass-net -e CASS_LOOPBACK --name cass-testf15 -p80:80 cassproject/cass:1.5.65 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode20\" \"npm run testNode20Fips\" \"npm run testNode20ForceFips\" \"npm run testNode18\" \"npm run testNode18Fips\" \"npm run testNode16\" && npm run testkill15",
"test15HttpsFips": "export CASS_LOOPBACK=https://cass-testsf15/api/|| set CASS_LOOPBACK=https://cass-testsf15/api/&& npm run testkillsf15 && docker run -d --network cass-net --name cass-testsf15 -p446:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.65 && wait-on https://localhost:446/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode20HttpsForceFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkillsf15",
"test15Https11Fips": "export CASS_LOOPBACK=https://cass-testsf1115/api/|| set CASS_LOOPBACK=https://cass-testsf1115/api/&& npm run testkillsf1115 && docker run -d --network cass-net --name cass-testsf1115 -p447:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.65 && wait-on https://localhost:447/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode20HttpsForceFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkillsf1115",
"test15Https": "export CASS_LOOPBACK=https://cass-tests15/api/|| set CASS_LOOPBACK=https://cass-tests15/api/&& npm run testkills15 && docker run -d --network cass-net --name cass-tests15 -p444:443 -e CASS_LOOPBACK -e HTTPS=true cassproject/cass:1.5.65 && wait-on https://localhost:444/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run testkills15",
"test15Https11": "export CASS_LOOPBACK=https://cass-tests1115/api/|| set CASS_LOOPBACK=https://cass-tests1115/api/&& npm run testkills1115 && docker run -d --network cass-net --name cass-tests1115 -p443:443 -e CASS_LOOPBACK -e HTTPS=true -e HTTP2=false cassproject/cass:1.5.65 && wait-on https://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypressHttps\" \"npm run testNode20Https\" \"npm run testNode20HttpsFips\" \"npm run testNode18Https\" \"npm run testNode18HttpsFips\" \"npm run testNode16Https\" && npm run tests1115",
"test15Fips": "export CASS_LOOPBACK=http://cass-testf15/api/|| set CASS_LOOPBACK=http://cass-testf15/api/&& npm run testkillf15 && docker run -d --network cass-net -e CASS_LOOPBACK --name cass-testf15 -p81:80 cassproject/cass:1.5.65 && wait-on http://localhost:81/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode20\" \"npm run testNode20Fips\" \"npm run testNode20ForceFips\" \"npm run testNode18\" \"npm run testNode18Fips\" \"npm run testNode16\" && npm run testkillf15",
"test15": "export CASS_LOOPBACK=http://cass-test15/api/|| set CASS_LOOPBACK=http://cass-test15/api/&& npm run testkill15 && docker run -d --network cass-net -e CASS_LOOPBACK --name cass-test15 -p80:80 cassproject/cass:1.5.65 && wait-on http://localhost/api/ping && concurrently --kill-others-on-fail \"npm run testCypress\" \"npm run testNode20\" \"npm run testNode20Fips\" \"npm run testNode18\" \"npm run testNode18Fips\" \"npm run testNode16\" && npm run testkill15",
"test14": "npm run testkill14 && docker run -d --network cass-net -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",
"test13": "npm run testkill13 && docker run -d --network cass-net -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",
"test12": "npm run testkill12 && docker run -d --network cass-net -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",
"testkillsf15": "docker kill cass-testsf15 | exit 0 && docker rm cass-testsf15 | exit 0 && docker network create cass-net | exit 0",
"testkillsf1115": "docker kill cass-testsf1115 | exit 0 && docker rm cass-testsf1115 | exit 0 && docker network create cass-net | exit 0",
"testkillsf1115": "(docker kill cass-testsf1115 | exit 0) && (docker rm cass-testsf1115 | exit 0) && docker network create cass-net | exit 0",
"testkills15": "docker kill cass-tests15 | exit 0 && docker rm cass-tests15 | exit 0 && docker network create cass-net | exit 0",
"testkills1115": "docker kill cass-tests1115 | exit 0 && docker rm cass-tests1115 | exit 0 && docker network create cass-net | exit 0",
"testkillf15": "docker kill cass-testf15 | exit 0 && docker rm cass-testf15 | exit 0 && docker network create cass-net | exit 0",
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcAesCtr.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ const EcAes = require("../com/eduworks/ec/crypto/EcAes");
const EcAesCtr = require("../com/eduworks/ec/crypto/EcAesCtr");
const EcCrypto = require("../com/eduworks/ec/crypto/EcCrypto");

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcAesCtrAsync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ let EcAes = require("../com/eduworks/ec/crypto/EcAes.js");
let EcCrypto = require("../com/eduworks/ec/crypto/EcCrypto.js");
let chai = require("chai");

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcAesCtrAsyncWorker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ let EcAes = require("../com/eduworks/ec/crypto/EcAes.js");
let EcCrypto = require("../com/eduworks/ec/crypto/EcCrypto.js");
let chai = require("chai");

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcCrypto.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ try {
console.log("Webcrypto not available. Tests will fail. Please upgrade, if possible, to Node 16. Non-test mode will fallback to slower cryptograpy methods.: " + err);
}

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcFrameworkGraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ const EcFramework = require("../org/cass/competency/EcFramework");
const EcIdentity = require("../org/cassproject/ebac/identity/EcIdentity");
const EcFrameworkGraph = require("../com/eduworks/ec/graph/EcFrameworkGraph");

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcIdentityManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ const chai = require("chai");
const EcRsaOaepAsyncWorker = require("../com/eduworks/ec/crypto/EcRsaOaepAsyncWorker");
const EcPpkFacade = require("../com/eduworks/ec/crypto/EcPpkFacade");

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcRepository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ const EcIdentityManager = require('../org/cassproject/ebac/identity/EcIdentityMa
const EcIdentity = require('../org/cassproject/ebac/identity/EcIdentity.js');
const EcPpk = require('../com/eduworks/ec/crypto/EcPpk.js');

let hrtime = function() {
let hrtime = function () {
try {
return [Math.round(performance.now()/1000), performance.now() * 1000];
return [Math.round(performance.now() / 1000), performance.now() * 1000];
} catch (e) {
// Eat quietly.
try {
if (typeof process !== 'undefined')
return process.hrtime();
return [new Date().getTime(), new Date().getTime() * 1000];
}
catch (ex) {
return [new Date().getTime(), new Date().getTime() * 1000];
}
}
return process.hrtime();
};

let should = chai.should();
Expand Down
14 changes: 10 additions & 4 deletions src/test/EcRsaOaep.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/test/EcRsaOaepAsync.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/test/EcRsaOaepAsyncWorker.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4a9b79a

Please sign in to comment.