Skip to content

Commit

Permalink
add test for xssec (#229)
Browse files Browse the repository at this point in the history
* add test for xssec

* add test for xssec

---------

Co-authored-by: Max Gruenfelder <[email protected]>
  • Loading branch information
soccermax and Max Gruenfelder authored Aug 23, 2024
1 parent 2a0f81c commit 631e9b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## v1.6.5 - 2024-08-22
## v1.6.5 - 2024-08-23

### Added

- Introduced the `retryFailedAfter` configuration option, allowing you to specify the interval (in milliseconds) after which failed events should be retried, provided the retry limit has not been exceeded.
- Increased test coverage for fetching authInfo with @sap/xssec

## v1.6.4 - 2024-08-14

Expand Down
14 changes: 14 additions & 0 deletions test/common.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ describe("getAuthInfo", () => {
expect(cds.log().warn.mock.calls).toHaveLength(0);
});

it("should correctly pass tenant id to xssec", async () => {
const fetchClientCredentialsTokenSpy = jest
.spyOn(xssec.XsuaaService.prototype, "fetchClientCredentialsToken")
.mockResolvedValueOnce({ access_token: "token" });
jest.spyOn(xssec.XsuaaService.prototype, "createSecurityContext").mockResolvedValueOnce({
getExpirationDate: () => new Date(),
});
const result = await getAuthInfo("1");
expect(result).toBeDefined();
expect(fetchClientCredentialsTokenSpy).toHaveBeenCalledWith({ zid: "1" });
expect(cds.log().warn.mock.calls).toHaveLength(0);
fetchClientCredentialsTokenSpy;
});

it("should use cache for the second call", async () => {
jest
.spyOn(xssec.XsuaaService.prototype, "fetchClientCredentialsToken")
Expand Down

0 comments on commit 631e9b4

Please sign in to comment.