@@ -48,6 +48,7 @@ var buildTests = []func(t *testing.T, sb integration.Sandbox){
4848 testBuildAlias ,
4949 testBuildStdin ,
5050 testBuildRemote ,
51+ testBuildRemoteAuth ,
5152 testBuildLocalState ,
5253 testBuildLocalStateStdin ,
5354 testBuildLocalStateRemote ,
@@ -267,6 +268,41 @@ COPY foo /foo
267268 })
268269}
269270
271+ func testBuildRemoteAuth (t * testing.T , sb integration.Sandbox ) {
272+ dockerfile := []byte (`
273+ FROM busybox:latest
274+ COPY foo /foo
275+ ` )
276+ dir := tmpdir (
277+ t ,
278+ fstest .CreateFile ("Dockerfile" , dockerfile , 0600 ),
279+ fstest .CreateFile ("foo" , []byte ("foo" ), 0600 ),
280+ )
281+ dirDest := t .TempDir ()
282+
283+ git , err := gitutil .New (gitutil .WithWorkingDir (dir ))
284+ require .NoError (t , err )
285+
286+ gittestutil .GitInit (git , t )
287+ gittestutil .GitAdd (git , t , "Dockerfile" , "foo" )
288+ gittestutil .GitCommit (git , t , "initial commit" )
289+
290+ token := identity .NewID ()
291+ addr := gittestutil .GitServeHTTP (git , t , gittestutil .WithAccessToken (token ))
292+
293+ out , err := buildCmd (sb , withDir (dir ),
294+ withEnv ("GIT_AUTH_TOKEN=" + token ),
295+ withArgs (
296+ "--secret" , "id=GIT_AUTH_TOKEN,env=GIT_AUTH_TOKEN" ,
297+ "--output=type=local,dest=" + dirDest ,
298+ addr ,
299+ ),
300+ )
301+ require .NoError (t , err , out )
302+
303+ require .FileExists (t , filepath .Join (dirDest , "foo" ))
304+ }
305+
270306func testBuildLocalState (t * testing.T , sb integration.Sandbox ) {
271307 dockerfile := []byte (`
272308FROM busybox:latest AS base
0 commit comments