|
1 | | -import { generateDockerCompose, generateMavenSettings, subnetsOverlap, writeConfigs, startContainers, stopContainers, cleanup, runAgentCommand, validateIdNotInSystemRange, getSafeHostUid, getSafeHostGid, getRealUserHome, MIN_REGULAR_UID, ACT_PRESET_BASE_IMAGE } from './docker-manager'; |
| 1 | +import { generateDockerCompose, subnetsOverlap, writeConfigs, startContainers, stopContainers, cleanup, runAgentCommand, validateIdNotInSystemRange, getSafeHostUid, getSafeHostGid, getRealUserHome, MIN_REGULAR_UID, ACT_PRESET_BASE_IMAGE } from './docker-manager'; |
2 | 2 | import { WrapperConfig } from './types'; |
3 | 3 | import * as fs from 'fs'; |
4 | 4 | import * as path from 'path'; |
@@ -485,65 +485,6 @@ describe('docker-manager', () => { |
485 | 485 | expect(env.SQUID_PROXY_PORT).toBe('3128'); |
486 | 486 | }); |
487 | 487 |
|
488 | | - it('should configure JAVA_TOOL_OPTIONS with proxy settings for Java applications', () => { |
489 | | - const result = generateDockerCompose(mockConfig, mockNetworkConfig); |
490 | | - const agent = result.services.agent; |
491 | | - const env = agent.environment as Record<string, string>; |
492 | | - |
493 | | - expect(env.JAVA_TOOL_OPTIONS).toBeDefined(); |
494 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('-Dhttp.proxyHost=172.30.0.10'); |
495 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('-Dhttp.proxyPort=3128'); |
496 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('-Dhttps.proxyHost=172.30.0.10'); |
497 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('-Dhttps.proxyPort=3128'); |
498 | | - }); |
499 | | - |
500 | | - it('should add http.nonProxyHosts to JAVA_TOOL_OPTIONS when host access is enabled', () => { |
501 | | - const configWithHostAccess = { ...mockConfig, enableHostAccess: true }; |
502 | | - const result = generateDockerCompose(configWithHostAccess, mockNetworkConfig); |
503 | | - const agent = result.services.agent; |
504 | | - const env = agent.environment as Record<string, string>; |
505 | | - |
506 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('-Dhttp.nonProxyHosts='); |
507 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('localhost'); |
508 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('127.0.0.1'); |
509 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('host.docker.internal'); |
510 | | - }); |
511 | | - |
512 | | - it('should not include quotes in JAVA_TOOL_OPTIONS nonProxyHosts value', () => { |
513 | | - const configWithHostAccess = { ...mockConfig, enableHostAccess: true }; |
514 | | - const result = generateDockerCompose(configWithHostAccess, mockNetworkConfig); |
515 | | - const agent = result.services.agent; |
516 | | - const env = agent.environment as Record<string, string>; |
517 | | - |
518 | | - // Verify no embedded quotes in nonProxyHosts value |
519 | | - // JAVA_TOOL_OPTIONS parsing treats quotes as literal characters, not grouping |
520 | | - expect(env.JAVA_TOOL_OPTIONS).not.toContain('"localhost'); |
521 | | - expect(env.JAVA_TOOL_OPTIONS).not.toContain('internal"'); |
522 | | - expect(env.JAVA_TOOL_OPTIONS).toContain('-Dhttp.nonProxyHosts=localhost|'); |
523 | | - }); |
524 | | - |
525 | | - it('should mount Maven settings.xml for proxy configuration', () => { |
526 | | - const result = generateDockerCompose(mockConfig, mockNetworkConfig); |
527 | | - const agent = result.services.agent; |
528 | | - const volumes = agent.volumes as string[]; |
529 | | - |
530 | | - const mavenMount = volumes.find((v: string) => v.includes('maven-settings.xml')); |
531 | | - expect(mavenMount).toBeDefined(); |
532 | | - expect(mavenMount).toContain('.m2/settings.xml:ro'); |
533 | | - }); |
534 | | - |
535 | | - it('should mount Maven settings.xml under /host in chroot mode', () => { |
536 | | - const chrootConfig = { ...mockConfig, enableChroot: true }; |
537 | | - const result = generateDockerCompose(chrootConfig, mockNetworkConfig); |
538 | | - const agent = result.services.agent; |
539 | | - const volumes = agent.volumes as string[]; |
540 | | - |
541 | | - const mavenMount = volumes.find((v: string) => v.includes('maven-settings.xml')); |
542 | | - expect(mavenMount).toBeDefined(); |
543 | | - expect(mavenMount).toContain('/host'); |
544 | | - expect(mavenMount).toContain('.m2/settings.xml:ro'); |
545 | | - }); |
546 | | - |
547 | 488 | it('should mount required volumes in agent container (default behavior)', () => { |
548 | 489 | const result = generateDockerCompose(mockConfig, mockNetworkConfig); |
549 | 490 | const agent = result.services.agent; |
@@ -1871,32 +1812,4 @@ describe('docker-manager', () => { |
1871 | 1812 | await expect(cleanup(nonExistentDir, false)).resolves.not.toThrow(); |
1872 | 1813 | }); |
1873 | 1814 | }); |
1874 | | - |
1875 | | - describe('generateMavenSettings', () => { |
1876 | | - it('should generate valid Maven settings.xml with proxy configuration', () => { |
1877 | | - const result = generateMavenSettings('172.30.0.10', 3128); |
1878 | | - |
1879 | | - expect(result).toContain('<settings'); |
1880 | | - expect(result).toContain('<proxies>'); |
1881 | | - expect(result).toContain('<protocol>http</protocol>'); |
1882 | | - expect(result).toContain('<protocol>https</protocol>'); |
1883 | | - expect(result).toContain('<host>172.30.0.10</host>'); |
1884 | | - expect(result).toContain('<port>3128</port>'); |
1885 | | - // Should not include nonProxyHosts when not provided |
1886 | | - expect(result).not.toContain('<nonProxyHosts>'); |
1887 | | - }); |
1888 | | - |
1889 | | - it('should include nonProxyHosts when provided', () => { |
1890 | | - const result = generateMavenSettings('172.30.0.10', 3128, 'localhost|127.0.0.1|host.docker.internal'); |
1891 | | - |
1892 | | - expect(result).toContain('<nonProxyHosts>localhost|127.0.0.1|host.docker.internal</nonProxyHosts>'); |
1893 | | - }); |
1894 | | - |
1895 | | - it('should have both HTTP and HTTPS proxy entries', () => { |
1896 | | - const result = generateMavenSettings('172.30.0.10', 3128); |
1897 | | - |
1898 | | - expect(result).toContain('<id>awf-http</id>'); |
1899 | | - expect(result).toContain('<id>awf-https</id>'); |
1900 | | - }); |
1901 | | - }); |
1902 | 1815 | }); |
0 commit comments