@@ -175,11 +175,24 @@ test('prepareMetroRuntime rejects incomplete proxy configuration', async () => {
175175 prepareMetroRuntime ( {
176176 publicBaseUrl : 'https://sandbox.example.test' ,
177177 proxyBaseUrl : 'https://proxy.example.test' ,
178+ env : { } ,
178179 } ) ,
179180 ( error ) =>
180181 error instanceof AppError &&
181182 error . code === 'INVALID_ARGS' &&
182- error . message . includes ( 'AGENT_DEVICE_PROXY_TOKEN' ) ,
183+ error . message . includes ( 'AGENT_DEVICE_METRO_BEARER_TOKEN' ) ,
184+ ) ;
185+
186+ await assert . rejects (
187+ ( ) =>
188+ prepareMetroRuntime ( {
189+ publicBaseUrl : 'https://sandbox.example.test' ,
190+ env : { AGENT_DEVICE_METRO_BEARER_TOKEN : TEST_TOKEN } ,
191+ } ) ,
192+ ( error ) =>
193+ error instanceof AppError &&
194+ error . code === 'INVALID_ARGS' &&
195+ error . message . includes ( 'requires --proxy-base-url' ) ,
183196 ) ;
184197
185198 await assert . rejects (
@@ -188,6 +201,37 @@ test('prepareMetroRuntime rejects incomplete proxy configuration', async () => {
188201 publicBaseUrl : 'https://sandbox.example.test' ,
189202 proxyBaseUrl : 'https://proxy.example.test' ,
190203 proxyBearerToken : TEST_TOKEN ,
204+ env : { } ,
205+ } ) ,
206+ ( error ) =>
207+ error instanceof AppError &&
208+ error . code === 'INVALID_ARGS' &&
209+ error . message . includes ( 'tenantId, runId, and leaseId bridge scope' ) ,
210+ ) ;
211+ } ) ;
212+
213+ test ( 'prepareMetroRuntime falls back to daemon auth token for proxy auth' , async ( ) => {
214+ await assert . rejects (
215+ ( ) =>
216+ prepareMetroRuntime ( {
217+ publicBaseUrl : 'https://sandbox.example.test' ,
218+ proxyBaseUrl : 'https://proxy.example.test' ,
219+ env : { AGENT_DEVICE_DAEMON_AUTH_TOKEN : TEST_TOKEN } ,
220+ } ) ,
221+ ( error ) =>
222+ error instanceof AppError &&
223+ error . code === 'INVALID_ARGS' &&
224+ error . message . includes ( 'tenantId, runId, and leaseId bridge scope' ) ,
225+ ) ;
226+ } ) ;
227+
228+ test ( 'prepareMetroRuntime honors metro bearer token env for proxy auth' , async ( ) => {
229+ await assert . rejects (
230+ ( ) =>
231+ prepareMetroRuntime ( {
232+ publicBaseUrl : 'https://sandbox.example.test' ,
233+ proxyBaseUrl : 'https://proxy.example.test' ,
234+ env : { AGENT_DEVICE_METRO_BEARER_TOKEN : TEST_TOKEN } ,
191235 } ) ,
192236 ( error ) =>
193237 error instanceof AppError &&
0 commit comments