Skip to content

Commit 5a0e8d2

Browse files
committed
Add test case for user/pass configuration
1 parent 3bb42f8 commit 5a0e8d2

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

tests/ConfigLoader.test.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
import { ConfigLoader } from "../src/ConfigLoader";
22

33
describe("ConfigLoader", () => {
4-
it("fails", async () => {
5-
expect(await ConfigLoader.load(__dirname + "/test-config.json")).toEqual({
4+
it("should create bearer token from personal access token", async () => {
5+
expect(
6+
await ConfigLoader.load(__dirname + "/resources/test-config-with-personal-access-token-auth.json"),
7+
).toEqual({
68
authorizationToken: "Bearer unbearable",
7-
baseUrl: "https://confluence.custom.host/rest/api",
8-
cachePath: "cache/",
9-
configPath: __dirname + "/test-config.json",
10-
pages: [
11-
{
12-
file: __dirname + "/README.md",
13-
pageId: "123456789",
14-
},
15-
],
16-
prefix: "This document is automatically generated. Please don't edit it directly!",
9+
configPath: __dirname + "/resources/test-config-with-personal-access-token-auth.json",
10+
...irrelevantConfigFields,
1711
});
1812
});
13+
14+
it("should create base64 basic token from username and password", async () => {
15+
expect(await ConfigLoader.load(__dirname + "/resources/test-config-with-user-pass-auth.json")).toEqual({
16+
authorizationToken: "Basic dXNlcjpwYXNz",
17+
configPath: __dirname + "/resources/test-config-with-user-pass-auth.json",
18+
...irrelevantConfigFields,
19+
});
20+
});
21+
22+
const irrelevantConfigFields = {
23+
baseUrl: "https://confluence.custom.host/rest/api",
24+
cachePath: "cache/",
25+
pages: [
26+
{
27+
file: __dirname + "/resources/README.md",
28+
pageId: "123456789",
29+
},
30+
],
31+
prefix: "This document is automatically generated. Please don't edit it directly!",
32+
};
1933
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"baseUrl": "https://confluence.custom.host/rest/api",
3+
"user": "user",
4+
"pass": "pass",
5+
"prefix": "This document is automatically generated. Please don't edit it directly!",
6+
"cachePath": "cache/",
7+
"pages": [
8+
{
9+
"pageId": "123456789",
10+
"file": "README.md"
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)