Skip to content

Commit 37d4ded

Browse files
authored
fix: SSH tunnel not started in BAS for on-premise connectivity for CF ADP (#4559)
* fix: remove bas check * chore: add cset
1 parent 4bc4c4b commit 37d4ded

3 files changed

Lines changed: 6 additions & 25 deletions

File tree

.changeset/tall-rivers-tie.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sap-ux/backend-proxy-middleware-cf': patch
3+
---
4+
5+
fix: SSH tunnel not started in BAS for on-premise connectivity for CF ADP

packages/backend-proxy-middleware-cf/src/tunnel/tunnel.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import net from 'node:net';
22
import { spawn } from 'node:child_process';
33
import type { ChildProcess } from 'node:child_process';
44

5-
import { isAppStudio } from '@sap-ux/btp-utils';
65
import type { ToolsLogger } from '@sap-ux/logger';
76
import { ensureTunnelAppExists, enableSshAndRestart, DEFAULT_TUNNEL_APP_NAME } from '@sap-ux/adp-tooling';
87

@@ -118,7 +117,7 @@ function registerCleanup(tunnelProcess: ChildProcess, logger: ToolsLogger): void
118117

119118
/**
120119
* Start an SSH tunnel to the connectivity proxy if needed.
121-
* Skips if running in BAS, if the port is already in use, or if no connectivity service is present.
120+
* Skips if the port is already in use or if no connectivity service is present.
122121
* Errors are logged as warnings; the middleware continues without the tunnel.
123122
*
124123
* @param connectivityInfo - Original connectivity proxy host and port from VCAP_SERVICES.
@@ -134,11 +133,6 @@ export async function startSshTunnelIfNeeded(
134133
options?: SshTunnelOptions
135134
): Promise<ChildProcess | undefined> {
136135
try {
137-
if (isAppStudio()) {
138-
logger.debug('Running in BAS, SSH tunnel not needed.');
139-
return undefined;
140-
}
141-
142136
const localPort = options?.localPort ?? connectivityInfo.port;
143137

144138
if (await isPortInUse(localPort)) {

packages/backend-proxy-middleware-cf/test/unit/tunnel/tunnel.test.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import net from 'node:net';
22
import { EventEmitter } from 'node:events';
33

44
import type { ToolsLogger } from '@sap-ux/logger';
5-
import { isAppStudio } from '@sap-ux/btp-utils';
65
import { ensureTunnelAppExists, enableSshAndRestart } from '@sap-ux/adp-tooling';
76
import { spawn } from 'node:child_process';
87

@@ -14,10 +13,6 @@ jest.mock('node:child_process', () => ({
1413
spawn: jest.fn()
1514
}));
1615

17-
jest.mock('@sap-ux/btp-utils', () => ({
18-
isAppStudio: jest.fn()
19-
}));
20-
2116
jest.mock('@sap-ux/adp-tooling', () => ({
2217
ensureTunnelAppExists: jest.fn(),
2318
enableSshAndRestart: jest.fn(),
@@ -29,7 +24,6 @@ jest.mock('../../../src/tunnel/destination-check', () => ({
2924
}));
3025

3126
const mockSpawn = spawn as jest.Mock;
32-
const mockIsAppStudio = isAppStudio as jest.Mock;
3327
const mockEnsureTunnel = ensureTunnelAppExists as jest.Mock;
3428
const mockEnableSsh = enableSshAndRestart as jest.Mock;
3529
const mockHasOnPremise = hasOnPremiseDestination as jest.Mock;
@@ -100,7 +94,6 @@ describe('tunnel', () => {
10094

10195
beforeEach(() => {
10296
jest.clearAllMocks();
103-
mockIsAppStudio.mockReturnValue(false);
10497
processOnSpy = jest.spyOn(process, 'on');
10598
processOnceSpy = jest.spyOn(process, 'once');
10699
});
@@ -125,15 +118,6 @@ describe('tunnel', () => {
125118
}
126119

127120
describe('startSshTunnelIfNeeded', () => {
128-
test('should return undefined when running in BAS', async () => {
129-
mockIsAppStudio.mockReturnValue(true);
130-
131-
const result = await startSshTunnelIfNeeded(connectivityInfo, 'tunnel-app', logger);
132-
133-
expect(result).toBeUndefined();
134-
expect(logger.debug).toHaveBeenCalledWith(expect.stringContaining('BAS'));
135-
});
136-
137121
test('should return undefined when port is already in use', async () => {
138122
createServerSpy = jest
139123
.spyOn(net, 'createServer')
@@ -254,7 +238,6 @@ describe('tunnel', () => {
254238
test('should deploy tunnel app and start tunnel when OnPremise found', async () => {
255239
mockHasOnPremise.mockResolvedValue(true);
256240
mockEnsureTunnel.mockResolvedValue(undefined);
257-
mockIsAppStudio.mockReturnValue(true);
258241

259242
await setupSshTunnel('/root', connectivityInfo, effectiveOptions, logger);
260243

@@ -264,7 +247,6 @@ describe('tunnel', () => {
264247
test('should use custom tunnelAppName from options', async () => {
265248
mockHasOnPremise.mockResolvedValue(true);
266249
mockEnsureTunnel.mockResolvedValue(undefined);
267-
mockIsAppStudio.mockReturnValue(true);
268250

269251
const opts = { ...effectiveOptions, tunnelAppName: 'custom-app' } as unknown as EffectiveOptions;
270252
await setupSshTunnel('/root', connectivityInfo, opts, logger);

0 commit comments

Comments
 (0)