(t *testing.T)
| 364 | } |
| 365 | |
| 366 | func TestEncryptConfigForSave_WithPasswords(t *testing.T) { |
| 367 | // Test that encryptConfigForSave encrypts passwords when a master key is available |
| 368 | // Since we can't easily set up a master key in unit tests, test the no-key path |
| 369 | conf := &MainConfig{} |
| 370 | conf.Main.Ports = []string{"22"} |
| 371 | conf.Main.Users = []string{"root"} |
| 372 | conf.Main.Passwords = []string{"secret"} |
| 373 | conf.ServerLists = []ServerListConfig{ |
| 374 | {IP: "10.0.0.1", Port: "22", User: "root", Password: "cached_pass"}, |
| 375 | } |
| 376 | |
| 377 | // Without a master key, should return the same config |
| 378 | result, err := encryptConfigForSave(conf) |
| 379 | assert.NoError(t, err) |
| 380 | assert.Equal(t, conf.Main.Passwords, result.Main.Passwords, "without master key, passwords unchanged") |
| 381 | } |
| 382 | |
| 383 | func TestEncryptConfigForSave_EncryptsPassword(t *testing.T) { |
| 384 | os.Unsetenv("TRYSSH_MASTER_KEY") |
nothing calls this directly
no test coverage detected