Skip to content

Commit 903e36b

Browse files
authored
chore: Rename getIasDestination() to createDestinationFromIasService() (#6573)
* chore: Rename IAS convenience functions * revert back to getIasToken()
1 parent 0722cd8 commit 903e36b

4 files changed

Lines changed: 14 additions & 12 deletions

File tree

.changeset/empty-dryers-boil.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
'@sap-cloud-sdk/connectivity': minor
33
---
44

5-
[New Functionality] Add `getIasDestination()` convenience function to build IAS-backed destinations.
5+
[New Functionality] Add `createDestinationFromIasService()` convenience function to build IAS-backed destinations.
66
This function aims to offer more convenience for obtaining IAS-backed destinations outside SAP BTP-environments.

packages/connectivity/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export {
1818
jwtBearerToken,
1919
serviceToken,
2020
getIasToken,
21-
getIasDestination,
21+
createDestinationFromIasService,
2222
isHttpDestination,
2323
assertHttpDestination,
2424
DestinationSelectionStrategies,

packages/connectivity/src/scp-cf/token-accessor.spec.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
jwtBearerToken,
3333
serviceToken,
3434
getIasToken,
35-
getIasDestination
35+
createDestinationFromIasService
3636
} from './token-accessor';
3737
import { clearXsuaaServices } from './environment-accessor';
3838
import type { Service } from './environment-accessor';
@@ -595,7 +595,9 @@ describe('getIasToken()', () => {
595595

596596
describe('resource parameter', () => {
597597
it('passes resource (by name) to fetchIasToken', async () => {
598-
await getIasToken(mockService, { resource: { name: 'my-app' } });
598+
await getIasToken(mockService, {
599+
resource: { name: 'my-app' }
600+
});
599601

600602
expect(mockFetchIasToken).toHaveBeenCalledWith(
601603
expect.anything(),
@@ -644,7 +646,7 @@ describe('getIasToken()', () => {
644646
});
645647
});
646648

647-
describe('getIasDestination()', () => {
649+
describe('createDestinationFromIasService()', () => {
648650
const identityServiceMock = jest.requireMock('./identity-service');
649651
let mockFetchIasToken: jest.Mock;
650652
let mockGetIasAppTid: jest.Mock;
@@ -689,7 +691,7 @@ describe('getIasDestination()', () => {
689691
});
690692

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

694696
expect(destination).toEqual(
695697
expect.objectContaining({
@@ -707,7 +709,7 @@ describe('getIasDestination()', () => {
707709
});
708710

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

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

721-
const destination = await getIasDestination(credsWithoutCert);
723+
const destination = await createDestinationFromIasService(credsWithoutCert);
722724

723725
expect(destination.mtlsKeyPair).toBeUndefined();
724726
});
725727

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

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

737-
const destination = await getIasDestination(mockCredentials, {
739+
const destination = await createDestinationFromIasService(mockCredentials, {
738740
authenticationType: 'OAuth2JWTBearer',
739741
assertion
740742
});
@@ -743,7 +745,7 @@ describe('getIasDestination()', () => {
743745
});
744746

745747
it('delegates to getIasToken with the provided options', async () => {
746-
await getIasDestination(mockCredentials, {
748+
await createDestinationFromIasService(mockCredentials, {
747749
useCache: false,
748750
jwt: { app_tid: 'tenant-123' }
749751
});

packages/connectivity/src/scp-cf/token-accessor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export async function getIasToken(
165165
* @param options - Options for IAS token retrieval and destination configuration. See {@link IasTokenOptions}.
166166
* @returns A promise that resolves to an HTTP destination.
167167
*/
168-
export async function getIasDestination(
168+
export async function createDestinationFromIasService(
169169
service: ServiceCredentials | 'identity' | Service = 'identity',
170170
options?: IasTokenOptions
171171
): Promise<Destination> {

0 commit comments

Comments
 (0)