MCPcopy Create free account
hub / github.com/Driver-C/tryssh / TestEncryptConfigForSave_WithPasswords

Function TestEncryptConfigForSave_WithPasswords

pkg/config/loader_test.go:366–381  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

364}
365
366func 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
383func TestEncryptConfigForSave_EncryptsPassword(t *testing.T) {
384 os.Unsetenv("TRYSSH_MASTER_KEY")

Callers

nothing calls this directly

Calls 1

encryptConfigForSaveFunction · 0.85

Tested by

no test coverage detected