Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marikaner committed Sep 24, 2024
1 parent 42bdc72 commit 1539eaf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
destinationName,
oauthMultipleResponse
} from '../../../../../test-resources/test/test-util/example-destination-service-responses';
import * as jwt from '../jwt';
import {
getAllDestinationsFromDestinationService,
getDestination
Expand All @@ -34,9 +33,7 @@ describe('Failure cases', () => {
xsuaa: [xsuaaBindingMock]
});

jest
.spyOn(jwt, 'verifyJwt')
.mockResolvedValue(jwt.decodeJwt(subscriberServiceToken));
mockVerifyJwt();

await expect(
getDestination({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import {
customSubscriberUserToken,
mockServiceBindings,
mockVerifyJwt,
onlyIssuerServiceToken,
onlyIssuerXsuaaUrl,
subscriberServiceToken,
subscriberUserToken
} from '../../../../../test-resources/test/test-util';
import * as tokenAccessor from '../token-accessor';
import * as jwtModule from '../jwt';
import { getJwtPair } from '../jwt';
import { getSubscriberToken } from './get-subscriber-token';

describe('getSubscriberToken()', () => {
let verifyJwtSpy;
beforeEach(() => {
mockServiceBindings();
verifyJwtSpy = jest
.spyOn(jwtModule, 'verifyJwt')
.mockResolvedValue(undefined as any);
verifyJwtSpy = mockVerifyJwt();
});

afterEach(() => {
Expand Down
9 changes: 5 additions & 4 deletions test-resources/test/test-util/destination-service-mocks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import nock from 'nock';
import * as sdkJwt from '@sap-cloud-sdk/connectivity/src/scp-cf/jwt';
import {
import * as sdkJwtVerify from '@sap-cloud-sdk/connectivity/src/scp-cf/jwt/verify';
import * as sdkJwtJwt from '@sap-cloud-sdk/connectivity/src/scp-cf/jwt/jwt';
import type {
DestinationConfiguration,
DestinationJson
} from '@sap-cloud-sdk/connectivity';
Expand Down Expand Up @@ -232,6 +233,6 @@ export function mockFetchDestinationCalls(

export function mockVerifyJwt() {
return jest
.spyOn(sdkJwt, 'verifyJwt')
.mockImplementation(token => Promise.resolve(sdkJwt.decodeJwt(token)));
.spyOn(sdkJwtVerify, 'verifyJwt')
.mockImplementation(token => Promise.resolve(sdkJwtJwt.decodeJwt(token)));
}

0 comments on commit 1539eaf

Please sign in to comment.