(t *testing.T)
| 115 | } |
| 116 | |
| 117 | func TestLoadUserPolicy_ErrorFile(t *testing.T) { |
| 118 | // Test that LoadUserPolicy returns an error when the file is invalid |
| 119 | t.Parallel() |
| 120 | |
| 121 | mockUserLookup := &MockUserLookup{User: ValidUser} |
| 122 | policyLoader := NewTestHomePolicyLoader(afero.NewMemMapFs(), mockUserLookup) |
| 123 | mockFs := policyLoader.FileLoader.Fs |
| 124 | // Create policy file at user policy path with invalid data |
| 125 | err := afero.WriteFile(mockFs, filepath.Join(ValidUser.HomeDir, ".opk", "auth_id"), []byte("{"), 0600) |
| 126 | require.NoError(t, err) |
| 127 | |
| 128 | policy, path, err := policyLoader.LoadHomePolicy(ValidUser.Username, false) |
| 129 | require.NoError(t, err) |
| 130 | require.False(t, files.ConfigProblems().NoProblems()) |
| 131 | files.ConfigProblems().Clear() |
| 132 | |
| 133 | require.NotNil(t, policy, "should return policy even if error") |
| 134 | require.NotEmpty(t, path, "should return path even if error") |
| 135 | } |
| 136 | |
| 137 | func TestLoadUserPolicy_Success(t *testing.T) { |
| 138 | // Test that LoadUserPolicy returns the policy when there are no errors |
nothing calls this directly
no test coverage detected