(t *testing.T)
| 42 | } |
| 43 | |
| 44 | func TestConfigLoadEncryptedWithValidPassCommand(t *testing.T) { |
| 45 | ctx := context.Background() |
| 46 | ci := fs.GetConfig(ctx) |
| 47 | oldConfigPath := config.GetConfigPath() |
| 48 | oldConfig := *ci |
| 49 | assert.NoError(t, config.SetConfigPath("./testdata/encrypted.conf")) |
| 50 | // using ci.PasswordCommand, correct password |
| 51 | ci.PasswordCommand = fs.SpaceSepList{"echo", "asdf"} |
| 52 | defer func() { |
| 53 | assert.NoError(t, config.SetConfigPath(oldConfigPath)) |
| 54 | config.ClearConfigPassword() |
| 55 | *ci = oldConfig |
| 56 | ci.PasswordCommand = nil |
| 57 | }() |
| 58 | |
| 59 | config.ClearConfigPassword() |
| 60 | |
| 61 | err := config.Data().Load() |
| 62 | require.NoError(t, err) |
| 63 | |
| 64 | sections := config.Data().GetSectionList() |
| 65 | var expect = []string{"nounc", "unc"} |
| 66 | assert.Equal(t, expect, sections) |
| 67 | |
| 68 | keys := config.Data().GetKeyList("nounc") |
| 69 | expect = []string{"type", "nounc"} |
| 70 | assert.Equal(t, expect, keys) |
| 71 | } |
| 72 | |
| 73 | func TestConfigLoadEncryptedWithInvalidPassCommand(t *testing.T) { |
| 74 | ctx := context.Background() |
nothing calls this directly
no test coverage detected
searching dependent graphs…