MCPcopy
hub / github.com/openpubkey/opkssh / TestLoadSystemDefaultPolicy_ErrorFile

Function TestLoadSystemDefaultPolicy_ErrorFile

policy/policyloader_test.go:266–283  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

264}
265
266func TestLoadSystemDefaultPolicy_ErrorFile(t *testing.T) {
267 // Test that LoadSystemDefaultPolicy returns an error when the file is
268 // invalid
269 t.Parallel()
270
271 mockUserLookup := &MockUserLookup{User: ValidUser}
272 policyLoader := NewTestSystemPolicyLoader(afero.NewMemMapFs(), mockUserLookup)
273 mockFs := policyLoader.FileLoader.Fs
274 // Create policy file at default path with invalid file
275 err := afero.WriteFile(mockFs, policy.SystemDefaultPolicyPath, []byte("{"), 0640)
276 require.NoError(t, err)
277 policy, _, err := policyLoader.LoadSystemPolicy()
278 require.NoError(t, err)
279 require.False(t, files.ConfigProblems().NoProblems())
280 files.ConfigProblems().Clear()
281
282 require.NotNil(t, policy, "should return policy even if problems encountered")
283}
284
285func TestLoadSystemDefaultPolicy_Success(t *testing.T) {
286 // Test that LoadSystemDefaultPolicy returns the policy when there are no

Callers

nothing calls this directly

Calls 6

ConfigProblemsFunction · 0.92
LoadSystemPolicyMethod · 0.80
NoProblemsMethod · 0.80
ClearMethod · 0.80
WriteFileMethod · 0.65

Tested by

no test coverage detected