summaryrefslogtreecommitdiff
path: root/internal/cli/profile_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/cli/profile_test.go')
-rw-r--r--internal/cli/profile_test.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/internal/cli/profile_test.go b/internal/cli/profile_test.go
index e08ffc5..d373e95 100644
--- a/internal/cli/profile_test.go
+++ b/internal/cli/profile_test.go
@@ -50,11 +50,19 @@ func TestProfileImport(t *testing.T) {
t.Errorf("expected no error, got %v", err)
}
- // Verify the file was actually copied to derived name
+ // Verify the file was actually copied to derived name and has correct permissions
destFile := filepath.Join(profilesDir, "source.conf")
if _, err := os.Stat(destFile); os.IsNotExist(err) {
t.Errorf("expected profile to be imported to %s", destFile)
}
+ var info os.FileInfo
+ info, err = os.Stat(destFile)
+ if err != nil {
+ t.Fatalf("failed to stat imported profile: %v", err)
+ }
+ if info.Mode().Perm() != 0600 {
+ t.Errorf("expected imported profile to have permissions 0600, got %o", info.Mode().Perm())
+ }
// 2. Test importing with explicit name argument
customName := "custom-vpn"
@@ -70,6 +78,13 @@ func TestProfileImport(t *testing.T) {
if _, err := os.Stat(destCustomFile); os.IsNotExist(err) {
t.Errorf("expected profile to be imported to %s", destCustomFile)
}
+ info, err = os.Stat(destCustomFile)
+ if err != nil {
+ t.Fatalf("failed to stat imported profile: %v", err)
+ }
+ if info.Mode().Perm() != 0600 {
+ t.Errorf("expected imported profile to have permissions 0600, got %o", info.Mode().Perm())
+ }
// 3. Test duplicate import (should fail)
appDup := NewApp([]string{"wg-wrap", "profile", "import", srcFile, customName})