mirror of
https://github.com/docker/compose.git
synced 2026-08-04 14:47:40 +00:00
test: repurpose decline test to cover sensitive data detection path
Renames test to Test_preChecks_sensitive_data_detected_decline. Uses a temporary .env file with an AWS token to reliably trigger the DefangLabs secret detector, and confirms that preChecks correctly aborts early on user decline. Signed-off-by: Ishwar <ishwarcm@iitbhilai.ac.in>
This commit is contained in:
parent
9c5fd50989
commit
37cbf7a9cd
1 changed files with 12 additions and 7 deletions
|
|
@ -18,6 +18,7 @@ package compose
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
|
|
@ -102,18 +103,22 @@ services:
|
|||
}, cmp.Ignore()))
|
||||
}
|
||||
|
||||
func Test_preChecks_decline_returns_ErrPublishAborted(t *testing.T) {
|
||||
func Test_preChecks_sensitive_data_detected_decline(t *testing.T) {
|
||||
|
||||
dir := t.TempDir()
|
||||
envPath := dir + "/secrets.env"
|
||||
secretData := `AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"`
|
||||
err := os.WriteFile(envPath, []byte(secretData), 0o600)
|
||||
assert.NilError(t, err)
|
||||
|
||||
project := &types.Project{
|
||||
|
||||
Services: types.Services{
|
||||
"web": {
|
||||
Name: "web",
|
||||
Image: "nginx",
|
||||
Volumes: []types.ServiceVolumeConfig{
|
||||
{
|
||||
Type: types.VolumeTypeBind,
|
||||
Source: "/host/path",
|
||||
Target: "/container/path",
|
||||
},
|
||||
EnvFiles: []types.EnvFile{
|
||||
{Path: envPath, Required: true},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue