diff --git a/src/jira.test.ts b/src/jira.test.ts index e9954e8..fbf4058 100644 --- a/src/jira.test.ts +++ b/src/jira.test.ts @@ -19,7 +19,7 @@ function createTestInstance(actualOptions: Partial = {}) { if ("axios" in actualOptions) { finalOptions.axios = actualOptions.axios; } else { - finalOptions.strictSSL = finalOptions.strictSSL ?? true; + finalOptions.strictSSL = actualOptions.strictSSL ?? true; finalOptions.ca = finalOptions.ca ?? undefined; } @@ -75,7 +75,21 @@ describe("Jira API Tests", () => { strictSSL: false, }); - expect(jira.httpsAgent).toBeDefined(); + expect(jira.httpsAgent.options.rejectUnauthorized).toBe(false); + }); + + it("Constructor with ssl default empty", () => { + const { jira } = createTestInstance({}); + + expect(jira.httpsAgent.options.rejectUnauthorized).toBe(true); + }); + + it("Constructor with with ssl checking enabled", () => { + const { jira } = createTestInstance({ + strictSSL: true, + }); + + expect(jira.httpsAgent.options.rejectUnauthorized).toBe(true); }); it("should allow the user to pass in a certificate authority", () => { diff --git a/src/jira.ts b/src/jira.ts index b2861a4..8bb16a2 100644 --- a/src/jira.ts +++ b/src/jira.ts @@ -78,7 +78,7 @@ export class JiraApi { if ("axios" in options) { this.axios = options.axios; } else if ("strictSSL" in options || "ca" in options) { - this.httpsAgent = new Agent({ rejectUnauthorized: !options.strictSSL, ca: options.ca }); + this.httpsAgent = new Agent({ rejectUnauthorized: options.strictSSL ?? true, ca: options.ca }); this.axios = axios.create({ httpsAgent: this.httpsAgent, });