Skip to content

Commit a09d4c1

Browse files
committed
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.
1 parent 579bbe7 commit a09d4c1

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

pkg/compose/publish_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package compose
1818

1919
import (
2020
"errors"
21+
"os"
2122
"slices"
2223
"testing"
2324

@@ -102,18 +103,22 @@ services:
102103
}, cmp.Ignore()))
103104
}
104105

105-
func Test_preChecks_decline_returns_ErrPublishAborted(t *testing.T) {
106+
func Test_preChecks_sensitive_data_detected_decline(t *testing.T) {
107+
108+
dir := t.TempDir()
109+
envPath := dir + "/secrets.env"
110+
secretData := `AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"`
111+
err := os.WriteFile(envPath, []byte(secretData), 0o600)
112+
assert.NilError(t, err)
113+
106114
project := &types.Project{
115+
107116
Services: types.Services{
108117
"web": {
109118
Name: "web",
110119
Image: "nginx",
111-
Volumes: []types.ServiceVolumeConfig{
112-
{
113-
Type: types.VolumeTypeBind,
114-
Source: "/host/path",
115-
Target: "/container/path",
116-
},
120+
EnvFiles: []types.EnvFile{
121+
{Path: envPath, Required: true},
117122
},
118123
},
119124
},

0 commit comments

Comments
 (0)