Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions go/adk/pkg/config/config_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"runtime"
"testing"
)

Expand Down Expand Up @@ -110,6 +111,18 @@ func TestMaterializeFromEnv(t *testing.T) {
if string(srtData) != `{"skills":[]}` {
t.Fatalf("srt settings = %q", string(srtData))
}

if runtime.GOOS != "windows" {
for _, name := range []string{"config.json", "agent-card.json", srtSettingsFile} {
fi, err := os.Stat(filepath.Join(tmpDir, name))
if err != nil {
t.Fatalf("stat %s: %v", name, err)
}
if perm := fi.Mode().Perm(); perm != 0o600 {
t.Errorf("%s permissions = %o, want 0600", name, perm)
}
}
}
}

func TestMaterializeFromEnv_SkipsUnset(t *testing.T) {
Expand Down
5 changes: 4 additions & 1 deletion go/adk/pkg/config/config_materialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ func materializeEnvToFile(envKey, path string) error {
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
return fmt.Errorf("create directory for %s: %w", path, err)
}
if err := os.WriteFile(path, []byte(value), 0o644); err != nil {
if err := os.WriteFile(path, []byte(value), 0o600); err != nil {
Comment thread
mesutoezdil marked this conversation as resolved.
return fmt.Errorf("write %s: %w", path, err)
}
if err := os.Chmod(path, 0o600); err != nil {
return fmt.Errorf("chmod %s: %w", path, err)
}
return nil
}
Loading