Skip to content

Commit

Permalink
fix: corrected the strictSSL setting for the jira client (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Nemtyrev.S <[email protected]>
  • Loading branch information
Batyodie and Nemtyrev.S authored Apr 1, 2024
1 parent 0bbece7 commit 03da7b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
18 changes: 16 additions & 2 deletions src/jira.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function createTestInstance(actualOptions: Partial<JiraApiOptions> = {}) {
if ("axios" in actualOptions) {
finalOptions.axios = actualOptions.axios;
} else {
finalOptions.strictSSL = finalOptions.strictSSL ?? true;
finalOptions.strictSSL = actualOptions.strictSSL ?? true;
finalOptions.ca = finalOptions.ca ?? undefined;
}

Expand Down Expand Up @@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/jira.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 03da7b2

Please sign in to comment.