Description
DiscoverProviders() in pkg/provider/discovery.go:35-59 unconditionally scans the hard-coded system directory (/usr/libexec/complytime/providers, defined as SystemProviderDir in internal/complytime/consts.go:72) after scanning the user-provided directory. There is no mechanism to disable or override the system directory path.
Tests that assume an empty or controlled provider set fail on machines with system-installed providers (e.g., from RPM packages).
Affected Tests
4 tests in pkg/provider/:
| Test |
File:Line |
Expected |
Actual |
TestDiscoverProviders_EmptyDir |
discovery_test.go:23 |
empty |
3 system providers |
TestDiscoverProviders_NonPrefixedExecutables |
discovery_test.go:33 |
empty |
3 system providers |
TestDiscoverProviders_ValidProvider |
discovery_test.go:43 |
1 mock provider |
1 mock + 3 system |
TestManager_EmptyProviderDir |
manager_test.go:75 |
empty |
2 loaded providers |
Reproduction
Install provider RPMs (or manually place executables at /usr/libexec/complytime/providers/), then run:
go test -race -v -run "TestDiscoverProviders_EmptyDir|TestDiscoverProviders_NonPrefixedExecutables|TestDiscoverProviders_ValidProvider|TestManager_EmptyProviderDir" ./pkg/provider/...
All four tests fail. CI does not reproduce this because CI runners have no system-installed providers.
Possible Fix
Add a mechanism to override or disable the system provider directory during tests, so discovery can be fully isolated from the host environment. The codebase already uses env var overrides for similar paths (XDG_CACHE_HOME, XDG_DATA_HOME, COMPLYTIME_WORKSPACE), which could serve as a pattern.
Description
DiscoverProviders()inpkg/provider/discovery.go:35-59unconditionally scans the hard-coded system directory (/usr/libexec/complytime/providers, defined asSystemProviderDirininternal/complytime/consts.go:72) after scanning the user-provided directory. There is no mechanism to disable or override the system directory path.Tests that assume an empty or controlled provider set fail on machines with system-installed providers (e.g., from RPM packages).
Affected Tests
4 tests in
pkg/provider/:TestDiscoverProviders_EmptyDirdiscovery_test.go:23TestDiscoverProviders_NonPrefixedExecutablesdiscovery_test.go:33TestDiscoverProviders_ValidProviderdiscovery_test.go:43TestManager_EmptyProviderDirmanager_test.go:75Reproduction
Install provider RPMs (or manually place executables at
/usr/libexec/complytime/providers/), then run:All four tests fail. CI does not reproduce this because CI runners have no system-installed providers.
Possible Fix
Add a mechanism to override or disable the system provider directory during tests, so discovery can be fully isolated from the host environment. The codebase already uses env var overrides for similar paths (
XDG_CACHE_HOME,XDG_DATA_HOME,COMPLYTIME_WORKSPACE), which could serve as a pattern.