(t *testing.T)
| 414 | } |
| 415 | |
| 416 | func TestDecryptConfig_WithEncryptedData(t *testing.T) { |
| 417 | os.Setenv("TRYSSH_MASTER_KEY", "testpassword123") |
| 418 | defer os.Unsetenv("TRYSSH_MASTER_KEY") |
| 419 | clearMasterKeyForTest() |
| 420 | |
| 421 | key := deriveTestKey(t, "testpassword123") |
| 422 | encPass, err := utils.Encrypt("mysecret", key) |
| 423 | assert.NoError(t, err) |
| 424 | |
| 425 | conf := &MainConfig{} |
| 426 | conf.Main.Ports = []string{"22"} |
| 427 | conf.Main.Passwords = []string{encPass} |
| 428 | conf.ServerLists = []ServerListConfig{ |
| 429 | {IP: "10.0.0.1", Port: "22", User: "root", Password: encPass}, |
| 430 | } |
| 431 | |
| 432 | err = decryptConfig(conf) |
| 433 | assert.NoError(t, err) |
| 434 | assert.Equal(t, "mysecret", conf.Main.Passwords[0]) |
| 435 | assert.Equal(t, "mysecret", conf.ServerLists[0].Password) |
| 436 | } |
| 437 | |
| 438 | func TestDecryptConfig_WrongKey(t *testing.T) { |
| 439 | // Set master key to "testpassword123" |
nothing calls this directly
no test coverage detected