Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/empty-dryers-boil.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
'@sap-cloud-sdk/connectivity': minor
---

[New Functionality] Add `getIasDestination()` convenience function to build IAS-backed destinations.
[New Functionality] Add `createDestinationFromIasService()` convenience function to build IAS-backed destinations.
This function aims to offer more convenience for obtaining IAS-backed destinations outside SAP BTP-environments.
2 changes: 1 addition & 1 deletion packages/connectivity/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export {
jwtBearerToken,
serviceToken,
getIasToken,
getIasDestination,
createDestinationFromIasService,
isHttpDestination,
assertHttpDestination,
DestinationSelectionStrategies,
Expand Down
20 changes: 11 additions & 9 deletions packages/connectivity/src/scp-cf/token-accessor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
jwtBearerToken,
serviceToken,
getIasToken,
getIasDestination
createDestinationFromIasService
} from './token-accessor';
import { clearXsuaaServices } from './environment-accessor';
import type { Service } from './environment-accessor';
Expand Down Expand Up @@ -595,7 +595,9 @@ describe('getIasToken()', () => {

describe('resource parameter', () => {
it('passes resource (by name) to fetchIasToken', async () => {
await getIasToken(mockService, { resource: { name: 'my-app' } });
await getIasToken(mockService, {
resource: { name: 'my-app' }
});

expect(mockFetchIasToken).toHaveBeenCalledWith(
expect.anything(),
Expand Down Expand Up @@ -644,7 +646,7 @@ describe('getIasToken()', () => {
});
});

describe('getIasDestination()', () => {
describe('createDestinationFromIasService()', () => {
const identityServiceMock = jest.requireMock('./identity-service');
let mockFetchIasToken: jest.Mock;
let mockGetIasAppTid: jest.Mock;
Expand Down Expand Up @@ -689,7 +691,7 @@ describe('getIasDestination()', () => {
});

it('returns an HttpDestination with token and service URL', async () => {
const destination = await getIasDestination(mockCredentials);
const destination = await createDestinationFromIasService(mockCredentials);

expect(destination).toEqual(
expect.objectContaining({
Expand All @@ -707,7 +709,7 @@ describe('getIasDestination()', () => {
});

it('includes mTLS key pair when certificate and key are present', async () => {
const destination = await getIasDestination(mockCredentials);
const destination = await createDestinationFromIasService(mockCredentials);

expect(destination.mtlsKeyPair).toEqual({
cert: '-----BEGIN CERTIFICATE-----\ntest\n-----END CERTIFICATE-----',
Expand All @@ -718,13 +720,13 @@ describe('getIasDestination()', () => {
it('does not include mTLS key pair when certificate/key are absent', async () => {
const { certificate: _c, key: _k, ...credsWithoutCert } = mockCredentials;

const destination = await getIasDestination(credsWithoutCert);
const destination = await createDestinationFromIasService(credsWithoutCert);

expect(destination.mtlsKeyPair).toBeUndefined();
});

it('uses targetUrl when provided', async () => {
const destination = await getIasDestination(mockCredentials, {
const destination = await createDestinationFromIasService(mockCredentials, {
targetUrl: 'https://custom-target.example.com'
});

Expand All @@ -734,7 +736,7 @@ describe('getIasDestination()', () => {
it('uses OAuth2JWTBearer authentication type when specified', async () => {
const assertion = signedJwt({ user_uuid: 'user-1', app_tid: 'tid' });

const destination = await getIasDestination(mockCredentials, {
const destination = await createDestinationFromIasService(mockCredentials, {
authenticationType: 'OAuth2JWTBearer',
assertion
});
Expand All @@ -743,7 +745,7 @@ describe('getIasDestination()', () => {
});

it('delegates to getIasToken with the provided options', async () => {
await getIasDestination(mockCredentials, {
await createDestinationFromIasService(mockCredentials, {
useCache: false,
jwt: { app_tid: 'tenant-123' }
});
Expand Down
2 changes: 1 addition & 1 deletion packages/connectivity/src/scp-cf/token-accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export async function getIasToken(
* @param options - Options for IAS token retrieval and destination configuration. See {@link IasTokenOptions}.
* @returns A promise that resolves to an HTTP destination.
*/
export async function getIasDestination(
export async function createDestinationFromIasService(
service: ServiceCredentials | 'identity' | Service = 'identity',
options?: IasTokenOptions
): Promise<Destination> {
Expand Down
Loading