| ... | ... |
@@ -1317,7 +1317,7 @@ func TestBuildEntrypointRunCleanup(t *testing.T) {
|
| 1317 | 1317 |
logDone("build - cleanup cmd after RUN")
|
| 1318 | 1318 |
} |
| 1319 | 1319 |
|
| 1320 |
-func TestBuldForbiddenContextPath(t *testing.T) {
|
|
| 1320 |
+func TestBuildForbiddenContextPath(t *testing.T) {
|
|
| 1321 | 1321 |
name := "testbuildforbidpath" |
| 1322 | 1322 |
defer deleteImages(name) |
| 1323 | 1323 |
ctx, err := fakeContext(`FROM scratch |
| ... | ... |
@@ -1327,18 +1327,16 @@ func TestBuldForbiddenContextPath(t *testing.T) {
|
| 1327 | 1327 |
"test.txt": "test1", |
| 1328 | 1328 |
"other.txt": "other", |
| 1329 | 1329 |
}) |
| 1330 |
- |
|
| 1331 | 1330 |
defer ctx.Close() |
| 1332 | 1331 |
if err != nil {
|
| 1333 | 1332 |
t.Fatal(err) |
| 1334 | 1333 |
} |
| 1335 |
- if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
| 1336 |
- if !strings.Contains(err.Error(), "Forbidden path outside the build context: ../../ (/)") {
|
|
| 1337 |
- t.Fatal("Wrong error, must be about forbidden ../../ path")
|
|
| 1338 |
- } |
|
| 1339 |
- } else {
|
|
| 1340 |
- t.Fatal("Error must not be nil")
|
|
| 1334 |
+ |
|
| 1335 |
+ expected := "Forbidden path outside the build context: ../../ " |
|
| 1336 |
+ if _, err := buildImageFromContext(name, ctx, true); err == nil || !strings.Contains(err.Error(), expected) {
|
|
| 1337 |
+ t.Fatalf("Wrong error: (should contain \"%s\") got:\n%v", expected, err)
|
|
| 1341 | 1338 |
} |
| 1339 |
+ |
|
| 1342 | 1340 |
logDone("build - forbidden context path")
|
| 1343 | 1341 |
} |
| 1344 | 1342 |
|
| ... | ... |
@@ -31,6 +31,7 @@ const ( |
| 31 | 31 |
unitTestImageIDShort = "83599e29c455" |
| 32 | 32 |
unitTestNetworkBridge = "testdockbr0" |
| 33 | 33 |
unitTestStoreBase = "/var/lib/docker/unit-tests" |
| 34 |
+ unitTestDockerTmpdir = "/var/lib/docker/tmp" |
|
| 34 | 35 |
testDaemonAddr = "127.0.0.1:4270" |
| 35 | 36 |
testDaemonProto = "tcp" |
| 36 | 37 |
testDaemonHttpsProto = "tcp" |
| ... | ... |
@@ -90,6 +91,7 @@ func init() {
|
| 90 | 90 |
// To test other drivers, we need a dedicated driver validation suite. |
| 91 | 91 |
os.Setenv("DOCKER_DRIVER", "vfs")
|
| 92 | 92 |
os.Setenv("TEST", "1")
|
| 93 |
+ os.Setenv("DOCKER_TMPDIR", unitTestDockerTmpdir)
|
|
| 93 | 94 |
|
| 94 | 95 |
// Hack to run sys init during unit testing |
| 95 | 96 |
if selfPath := utils.SelfPath(); strings.Contains(selfPath, ".dockerinit") {
|