Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy committed Feb 27, 2025
1 parent 72785d8 commit 0e689d0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spec/unit/http-api/fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ describe("FetchHttpApi", () => {
fetchFn,
doNotAttemptTokenRefresh: false,
tokenRefreshFunction,
accessToken: "ACCESS_TOKEN",

Check failure

Code scanning / CodeQL

Hard-coded credentials Critical test

The hard-coded value "ACCESS_TOKEN" is used as
authorization header
.
refreshToken: "REFRESH_TOKEN",
});

Expand All @@ -514,11 +515,13 @@ describe("FetchHttpApi", () => {
get: jest.fn().mockReturnValue("application/json"),
},
});
deferredTokenRefresh.resolve({ accessToken: "NEW_TOKEN", refreshToken: "NEW_REFRESH" });
deferredTokenRefresh.resolve({ accessToken: "NEW_ACCESS_TOKEN", refreshToken: "NEW_REFRESH_TOKEN" });

await prom1;
await prom2;
expect(fetchFn).toHaveBeenCalledTimes(4); // 2 original calls + 2 retries
expect(tokenRefreshFunction).toHaveBeenCalledTimes(1);
expect(api.opts.accessToken).toBe("NEW_ACCESS_TOKEN");
expect(api.opts.refreshToken).toBe("NEW_REFRESH_TOKEN");
});
});

0 comments on commit 0e689d0

Please sign in to comment.