@@ -43,13 +43,15 @@ import (
43
43
44
44
const (
45
45
testContainerLabel = "envbox-integration-test"
46
+ testImageAlpine = "localhost:5000/envbuilder-test-alpine:latest"
47
+ testImageUbuntu = "localhost:5000/envbuilder-test-ubuntu:latest"
46
48
)
47
49
48
50
func TestFailsGitAuth (t * testing.T ) {
49
51
t .Parallel ()
50
52
url := createGitServer (t , gitServerOptions {
51
53
files : map [string ]string {
52
- "Dockerfile" : "FROM alpine:latest" ,
54
+ "Dockerfile" : "FROM " + testImageAlpine ,
53
55
},
54
56
username : "kyle" ,
55
57
password : "testing" ,
@@ -64,7 +66,7 @@ func TestSucceedsGitAuth(t *testing.T) {
64
66
t .Parallel ()
65
67
url := createGitServer (t , gitServerOptions {
66
68
files : map [string ]string {
67
- "Dockerfile" : "FROM alpine:latest" ,
69
+ "Dockerfile" : "FROM " + testImageAlpine ,
68
70
},
69
71
username : "kyle" ,
70
72
password : "testing" ,
@@ -166,7 +168,7 @@ func TestBuildFromDockerfile(t *testing.T) {
166
168
// Ensures that a Git repository with a Dockerfile is cloned and built.
167
169
url := createGitServer (t , gitServerOptions {
168
170
files : map [string ]string {
169
- "Dockerfile" : "FROM alpine:latest" ,
171
+ "Dockerfile" : "FROM " + testImageAlpine ,
170
172
},
171
173
})
172
174
ctr , err := runEnvbuilder (t , options {env : []string {
@@ -183,7 +185,7 @@ func TestBuildPrintBuildOutput(t *testing.T) {
183
185
// Ensures that a Git repository with a Dockerfile is cloned and built.
184
186
url := createGitServer (t , gitServerOptions {
185
187
files : map [string ]string {
186
- "Dockerfile" : "FROM alpine:latest \n RUN echo hello" ,
188
+ "Dockerfile" : "FROM " + testImageAlpine + " \n RUN echo hello" ,
187
189
},
188
190
})
189
191
ctr , err := runEnvbuilder (t , options {env : []string {
@@ -211,7 +213,7 @@ func TestBuildIgnoreVarRunSecrets(t *testing.T) {
211
213
// Ensures that a Git repository with a Dockerfile is cloned and built.
212
214
url := createGitServer (t , gitServerOptions {
213
215
files : map [string ]string {
214
- "Dockerfile" : "FROM alpine:latest" ,
216
+ "Dockerfile" : "FROM " + testImageAlpine ,
215
217
},
216
218
})
217
219
dir := t .TempDir ()
@@ -234,7 +236,7 @@ func TestBuildWithSetupScript(t *testing.T) {
234
236
// Ensures that a Git repository with a Dockerfile is cloned and built.
235
237
url := createGitServer (t , gitServerOptions {
236
238
files : map [string ]string {
237
- "Dockerfile" : "FROM alpine:latest" ,
239
+ "Dockerfile" : "FROM " + testImageAlpine ,
238
240
},
239
241
})
240
242
ctr , err := runEnvbuilder (t , options {env : []string {
@@ -323,7 +325,7 @@ func TestBuildFromDevcontainerInRoot(t *testing.T) {
323
325
func TestBuildCustomCertificates (t * testing.T ) {
324
326
srv := httptest .NewTLSServer (createGitHandler (t , gitServerOptions {
325
327
files : map [string ]string {
326
- "Dockerfile" : "FROM alpine:latest" ,
328
+ "Dockerfile" : "FROM " + testImageAlpine ,
327
329
},
328
330
}))
329
331
ctr , err := runEnvbuilder (t , options {env : []string {
@@ -344,7 +346,7 @@ func TestBuildStopStartCached(t *testing.T) {
344
346
// Ensures that a Git repository with a Dockerfile is cloned and built.
345
347
url := createGitServer (t , gitServerOptions {
346
348
files : map [string ]string {
347
- "Dockerfile" : "FROM alpine:latest" ,
349
+ "Dockerfile" : "FROM " + testImageAlpine ,
348
350
},
349
351
})
350
352
ctr , err := runEnvbuilder (t , options {env : []string {
@@ -439,7 +441,7 @@ RUN exit 1`,
439
441
})
440
442
ctr , err := runEnvbuilder (t , options {env : []string {
441
443
"GIT_URL=" + url ,
442
- "FALLBACK_IMAGE=alpine:latest" ,
444
+ "FALLBACK_IMAGE=" + testImageAlpine ,
443
445
}})
444
446
require .NoError (t , err )
445
447
@@ -458,7 +460,7 @@ func TestExitBuildOnFailure(t *testing.T) {
458
460
_ , err := runEnvbuilder (t , options {env : []string {
459
461
"GIT_URL=" + url ,
460
462
"DOCKERFILE_PATH=Dockerfile" ,
461
- "FALLBACK_IMAGE=alpine" ,
463
+ "FALLBACK_IMAGE=" + testImageAlpine ,
462
464
// Ensures that the fallback doesn't work when an image is specified.
463
465
"EXIT_ON_BUILD_FAILURE=true" ,
464
466
}})
@@ -486,7 +488,7 @@ func TestContainerEnv(t *testing.T) {
486
488
"REMOTE_BAR": "${FROM_CONTAINER_ENV}"
487
489
}
488
490
}` ,
489
- ".devcontainer/Dockerfile" : "FROM alpine:latest \n ENV FROM_DOCKERFILE=foo" ,
491
+ ".devcontainer/Dockerfile" : "FROM " + testImageAlpine + " \n ENV FROM_DOCKERFILE=foo" ,
490
492
},
491
493
})
492
494
ctr , err := runEnvbuilder (t , options {env : []string {
@@ -586,7 +588,7 @@ func TestPrivateRegistry(t *testing.T) {
586
588
t .Parallel ()
587
589
t .Run ("NoAuth" , func (t * testing.T ) {
588
590
t .Parallel ()
589
- image := setupPassthroughRegistry (t , "library/alpine " , & registryAuth {
591
+ image := setupPassthroughRegistry (t , "thisimagedoesnotexist " , & registryAuth {
590
592
Username : "user" ,
591
593
Password : "test" ,
592
594
})
@@ -605,7 +607,7 @@ func TestPrivateRegistry(t *testing.T) {
605
607
})
606
608
t .Run ("Auth" , func (t * testing.T ) {
607
609
t .Parallel ()
608
- image := setupPassthroughRegistry (t , "library/ alpine" , & registryAuth {
610
+ image := setupPassthroughRegistry (t , "envbuilder-test- alpine:latest " , & registryAuth {
609
611
Username : "user" ,
610
612
Password : "test" ,
611
613
})
@@ -635,7 +637,7 @@ func TestPrivateRegistry(t *testing.T) {
635
637
})
636
638
t .Run ("InvalidAuth" , func (t * testing.T ) {
637
639
t .Parallel ()
638
- image := setupPassthroughRegistry (t , "library/alpine " , & registryAuth {
640
+ image := setupPassthroughRegistry (t , "thisimagedoesnotexist " , & registryAuth {
639
641
Username : "user" ,
640
642
Password : "banana" ,
641
643
})
@@ -672,22 +674,22 @@ type registryAuth struct {
672
674
673
675
func setupPassthroughRegistry (t * testing.T , image string , auth * registryAuth ) string {
674
676
t .Helper ()
675
- dockerURL , err := url .Parse ("https ://registry-1.docker.io " )
677
+ dockerURL , err := url .Parse ("http ://localhost:5000 " )
676
678
require .NoError (t , err )
677
679
proxy := httputil .NewSingleHostReverseProxy (dockerURL )
678
680
679
681
// The Docker registry uses short-lived JWTs to authenticate
680
682
// anonymously to pull images. To test our MITM auth, we need to
681
683
// generate a JWT for the proxy to use.
682
- registry , err := name .NewRegistry ("registry-1.docker.io " )
684
+ registry , err := name .NewRegistry ("localhost:5000 " )
683
685
require .NoError (t , err )
684
686
proxy .Transport , err = transport .NewWithContext (context .Background (), registry , authn .Anonymous , http .DefaultTransport , []string {})
685
687
require .NoError (t , err )
686
688
687
689
srv := httptest .NewServer (http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
688
- r .Host = "registry-1.docker.io "
689
- r .URL .Host = "registry-1.docker.io "
690
- r .URL .Scheme = "https "
690
+ r .Host = "localhost:5000 "
691
+ r .URL .Host = "localhost:5000 "
692
+ r .URL .Scheme = "http "
691
693
692
694
if auth != nil {
693
695
user , pass , ok := r .BasicAuth ()
0 commit comments