|
1 | 1 | import { ConfigLoader } from "../src/ConfigLoader"; |
2 | 2 |
|
3 | 3 | 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({ |
6 | 8 | 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, |
17 | 11 | }); |
18 | 12 | }); |
| 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 | + }; |
19 | 33 | }); |
0 commit comments