(t *testing.T)
| 283 | } |
| 284 | |
| 285 | func 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 | |
| 313 | func TestDump_Success(t *testing.T) { |
| 314 | // Test that Dump writes the policy to the mock filesystem when there are no |
nothing calls this directly
no test coverage detected