-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdev-check-environment.js
More file actions
54 lines (48 loc) · 1.6 KB
/
dev-check-environment.js
File metadata and controls
54 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { expect, config } from "chai";
config.truncateThreshold = 0;
import { describe, it } from "mocha";
import * as jose from "jose";
describe("environment", function () {
const requiredEnvVars = [
"TEST_CLIENT_ID",
"API_KEY",
"SMARTAGENT_API_KEY",
"SMARTAGENT_API_URL",
"SMARTAGENT_WEBFORM_ID",
"URL_FOR_SUPPORT_LINKS",
"STUB_HOSTNAME",
];
requiredEnvVars.forEach((envVar) => {
it(`$${envVar} should be defined`, function () {
expect(process.env[envVar]).to.not.be.undefined;
});
it(`$${envVar} should not be empty`, function () {
if (process.env[envVar] === undefined) return this.skip();
expect(process.env[envVar]).to.not.be.empty;
});
});
describe("$ORCH_STUB_TO_AUTH_SIGNING_KEY", async function () {
const key = process.env.ORCH_STUB_TO_AUTH_SIGNING_KEY;
it("should be defined", function () {
expect(key).to.not.be.undefined;
});
it("should not be empty", function () {
if (key === undefined) return this.skip();
expect(key).to.not.be.empty;
});
it("should be importable by jose", async function () {
if (key === undefined) return this.skip();
try {
await jose.importSPKI(key, "ES256");
} catch (error) {
expect.fail(
`jose could not import the PEM. Other failing tests may help you identify why. Message: ${error.message}`
);
}
});
it("should not contain '\\n'", function () {
if (key === undefined) return this.skip();
expect(key).to.not.contain("\\n"); //this is a string literal, not a newline character
});
});
});