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

Function TestLoadConfigFromPath_ConfigFileUnreadable

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

Source from the content-addressed store, hash-verified

130}
131
132func TestLoadConfigFromPath_ConfigFileUnreadable(t *testing.T) {
133 dir := testutil.TempDir(t)
134 configContent := `main:
135 ports: ["22"]
136 users: ["root"]
137 passwords: []
138 keys: []
139`
140 configPath := testutil.CreateTestConfigFile(t, dir, configContent)
141 knownHostsPath := filepath.Join(dir, "known_hosts")
142
143 // Remove read permission
144 err := os.Chmod(configPath, 0000)
145 assert.NoError(t, err)
146 defer os.Chmod(configPath, 0644)
147
148 conf, err := LoadConfigFromPath(configPath, knownHostsPath)
149 assert.Error(t, err)
150 assert.Nil(t, conf)
151 assert.Contains(t, err.Error(), "load failed")
152}
153
154func TestUpdateConfigAtPath(t *testing.T) {
155 dir := testutil.TempDir(t)

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
CreateTestConfigFileFunction · 0.92
LoadConfigFromPathFunction · 0.85

Tested by

no test coverage detected