mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-11-02 07:49:51 +00:00
Make sure plugins only mount the workspace base in a predefinde location (#3933)
This commit is contained in:
@@ -61,13 +61,14 @@ func TestSecretAvailable(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCompilerCompile(t *testing.T) {
|
||||
repoURL := "https://github.com/octocat/hello-world"
|
||||
compiler := New(
|
||||
WithMetadata(metadata.Metadata{
|
||||
Repo: metadata.Repo{
|
||||
Owner: "octacat",
|
||||
Name: "hello-world",
|
||||
Private: true,
|
||||
ForgeURL: "https://github.com/octocat/hello-world",
|
||||
ForgeURL: repoURL,
|
||||
CloneURL: "https://github.com/octocat/hello-world.git",
|
||||
},
|
||||
}),
|
||||
@@ -76,6 +77,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
"COLORED": "true",
|
||||
}),
|
||||
WithPrefix("test"),
|
||||
// we use "/test" as custom workspace base to ensure the enforcement of the pluginWorkspaceBase is applied
|
||||
WithWorkspaceFromURL("/test", repoURL),
|
||||
)
|
||||
|
||||
defaultNetworks := []*backend_types.Network{{
|
||||
@@ -92,7 +95,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Image: constant.DefaultCloneImage,
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/woodpecker"},
|
||||
WorkingDir: "/woodpecker/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"clone"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}},
|
||||
@@ -137,7 +141,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Image: "dummy_img",
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/woodpecker"},
|
||||
WorkingDir: "/woodpecker/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"dummy"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}},
|
||||
@@ -172,7 +177,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Commands: []string{"env"},
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/test"},
|
||||
WorkingDir: "/test/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"echo env"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}},
|
||||
@@ -184,7 +190,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Commands: []string{"echo 1"},
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/test"},
|
||||
WorkingDir: "/test/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"parallel echo 1"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}, {
|
||||
@@ -194,7 +201,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Commands: []string{"echo 2"},
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/test"},
|
||||
WorkingDir: "/test/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"parallel echo 2"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}},
|
||||
@@ -228,7 +236,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Commands: []string{"env"},
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/test"},
|
||||
WorkingDir: "/test/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"echo env"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}, {
|
||||
@@ -238,7 +247,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Commands: []string{"echo 2"},
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/test"},
|
||||
WorkingDir: "/test/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"echo 2"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}},
|
||||
@@ -250,7 +260,8 @@ func TestCompilerCompile(t *testing.T) {
|
||||
Commands: []string{"echo 1"},
|
||||
OnSuccess: true,
|
||||
Failure: "fail",
|
||||
Volumes: []string{defaultVolumes[0].Name + ":"},
|
||||
Volumes: []string{defaultVolumes[0].Name + ":/test"},
|
||||
WorkingDir: "/test/src/github.com/octocat/hello-world",
|
||||
Networks: []backend_types.Conn{{Name: "test_default", Aliases: []string{"echo 1"}}},
|
||||
ExtraHosts: []backend_types.HostAlias{},
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user