@@ -17,11 +17,14 @@ import { createRunner, AwfRunner } from '../fixtures/awf-runner';
1717import { cleanup } from '../fixtures/cleanup' ;
1818import { createDockerHelper , DockerHelper } from '../fixtures/docker-helper' ;
1919import * as fs from 'fs' ;
20+ import * as os from 'os' ;
21+ import * as path from 'path' ;
2022
2123describe ( 'Host Access Integration Tests' , ( ) => {
2224 let runner : AwfRunner ;
2325 let docker : DockerHelper ;
2426 let testConfigPath : string ;
27+ const tmpDir = os . tmpdir ( ) ;
2528
2629 beforeAll ( async ( ) => {
2730 // Clean up any leftover resources
@@ -31,7 +34,7 @@ describe('Host Access Integration Tests', () => {
3134 docker = createDockerHelper ( ) ;
3235
3336 // Create a test config file for volume mount tests
34- testConfigPath = `/tmp/ awf-test-config-${ Date . now ( ) } .json`;
37+ testConfigPath = path . join ( tmpDir , ` awf-test-config-${ Date . now ( ) } .json`) ;
3538 const testConfig = {
3639 testKey : 'testValue' ,
3740 servers : {
@@ -108,7 +111,7 @@ describe('Host Access Integration Tests', () => {
108111 `cat ${ testConfigPath } ` ,
109112 {
110113 allowDomains : [ 'github.com' ] ,
111- volumeMounts : [ `/tmp:/tmp :ro` ] ,
114+ volumeMounts : [ `${ tmpDir } : ${ tmpDir } :ro` ] ,
112115 logLevel : 'debug' ,
113116 timeout : 60000 ,
114117 }
@@ -121,29 +124,29 @@ describe('Host Access Integration Tests', () => {
121124
122125 test ( 'Config file with host.docker.internal URL accessible' , async ( ) => {
123126 const result = await runner . runWithSudo (
124- `cat ${ testConfigPath } | grep host.docker.internal` ,
127+ `cat ${ testConfigPath } | grep -q host.docker.internal && echo "Found host.docker.internal" ` ,
125128 {
126129 allowDomains : [ 'github.com' ] ,
127130 enableHostAccess : true ,
128- volumeMounts : [ `/tmp:/tmp :ro` ] ,
131+ volumeMounts : [ `${ tmpDir } : ${ tmpDir } :ro` ] ,
129132 logLevel : 'debug' ,
130133 timeout : 60000 ,
131134 }
132135 ) ;
133136
134137 expect ( result ) . toSucceed ( ) ;
135- expect ( result . stdout ) . toContain ( 'host.docker.internal' ) ;
138+ expect ( result . stdout ) . toContain ( 'Found host.docker.internal' ) ;
136139 } , 120000 ) ;
137140
138141 test ( 'Read-write mount allows file creation' , async ( ) => {
139- const testFile = `/tmp/ awf-rw-test-${ Date . now ( ) } .txt`;
142+ const testFile = path . join ( tmpDir , ` awf-rw-test-${ Date . now ( ) } .txt`) ;
140143 const testContent = 'AWF read-write mount test' ;
141144
142145 const result = await runner . runWithSudo (
143146 `echo "${ testContent } " > ${ testFile } && cat ${ testFile } ` ,
144147 {
145148 allowDomains : [ 'github.com' ] ,
146- volumeMounts : [ `/tmp:/tmp :rw` ] ,
149+ volumeMounts : [ `${ tmpDir } : ${ tmpDir } :rw` ] ,
147150 logLevel : 'debug' ,
148151 timeout : 60000 ,
149152 }
@@ -246,7 +249,7 @@ describe('Host Access Integration Tests', () => {
246249 {
247250 allowDomains : [ 'github.com' , 'api.github.com' ] ,
248251 enableHostAccess : true ,
249- volumeMounts : [ `/tmp:/tmp :ro` ] ,
252+ volumeMounts : [ `${ tmpDir } : ${ tmpDir } :ro` ] ,
250253 env : {
251254 TEST_VAR : testEnvValue ,
252255 } ,
@@ -265,7 +268,7 @@ describe('Host Access Integration Tests', () => {
265268 // This test verifies that the enableHostAccess option is correctly
266269 // passed through the runner and into the AWF CLI
267270 const result = await runner . runWithSudo (
268- 'cat /etc/hosts | grep host.docker' ,
271+ 'cat /etc/hosts | grep -q host.docker && echo "host.docker.internal configured" ' ,
269272 {
270273 allowDomains : [ 'github.com' ] ,
271274 enableHostAccess : true ,
@@ -276,7 +279,7 @@ describe('Host Access Integration Tests', () => {
276279
277280 expect ( result ) . toSucceed ( ) ;
278281 // The /etc/hosts file should contain the host.docker.internal entry
279- expect ( result . stdout ) . toContain ( 'host.docker.internal' ) ;
282+ expect ( result . stdout ) . toContain ( 'host.docker.internal configured ' ) ;
280283 } , 120000 ) ;
281284 } ) ;
282285} ) ;
0 commit comments