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

Function TestLoadSystemDefaultPolicy_Success

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

Source from the content-addressed store, hash-verified

283}
284
285func TestLoadSystemDefaultPolicy_Success(t *testing.T) {
286 // Test that LoadSystemDefaultPolicy returns the policy when there are no
287 // errors
288 t.Parallel()
289
290 mockUserLookup := &MockUserLookup{User: ValidUser}
291 policyLoader := NewTestSystemPolicyLoader(afero.NewMemMapFs(), mockUserLookup)
292 mockFs := policyLoader.FileLoader.Fs
293 // Create policy file at default path with valid file
294 testPolicy := &policy.Policy{
295 Users: []policy.User{
296 {
297 IdentityAttribute: "alice@example.com",
298 Principals: []string{"test"},
299 Issuer: "https://example.com",
300 },
301 },
302 }
303 testPolicyFile, err := testPolicy.ToTable()
304 require.NoError(t, err)
305 err = afero.WriteFile(mockFs, policy.SystemDefaultPolicyPath, testPolicyFile, 0640)
306 require.NoError(t, err)
307 gotPolicy, _, err := policyLoader.LoadSystemPolicy()
308
309 require.NoError(t, err)
310 require.Equal(t, testPolicy, gotPolicy)
311}
312
313func TestDump_Success(t *testing.T) {
314 // Test that Dump writes the policy to the mock filesystem when there are no

Callers

nothing calls this directly

Calls 4

ToTableMethod · 0.95
LoadSystemPolicyMethod · 0.80
WriteFileMethod · 0.65

Tested by

no test coverage detected