[Test Coverage] test: improve config-file.ts coverage from 55% to 99%#2108
[Test Coverage] test: improve config-file.ts coverage from 55% to 99%#2108
Conversation
Add comprehensive tests for all uncovered code paths in config-file.ts: - validateAwfFileConfig: non-object root, all invalid field types across every config section (network, apiProxy, security, container, environment, logging, rateLimiting), unknown key rejection, and valid combinations - loadAwfFileConfig: YAML file loading (.yml extension), stdin YAML fallback, extensionless file JSON/YAML fallback, parse error messages, validation error messages with path/stdin labels - mapAwfFileConfigToCliOptions: all fields (security, container, env, logging, rateLimiting), empty array handling, undefined passthrough - applyConfigOptionsInPlaceWithCliPrecedence: all-apply, undefined-skip, and overwrite-without-CLI-flag scenarios Coverage improvement: - config-file.ts: 55.44% → 99.48% statements, 47.75% → 99.59% branches - Overall: 83.45% → 85.65% statements, 74.72% → 79.91% branches Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (2 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
This PR significantly increases automated test coverage for the security-relevant AWF config loader/validator (src/config-file.ts) by adding many new unit tests covering validation, parsing, mapping, and precedence behavior.
Changes:
- Expand
validateAwfFileConfigtest coverage across all sections (network/apiProxy/security/container/environment/logging/rateLimiting), including unknown-key and type-validation paths. - Add
loadAwfFileConfigtests for.ymlsupport, stdin YAML fallback, extensionless JSON→YAML fallback, and parse/validation error messaging. - Add broader
mapAwfFileConfigToCliOptionsandapplyConfigOptionsInPlaceWithCliPrecedencetests to cover optional-field behavior and CLI precedence rules.
Show a summary per file
| File | Description |
|---|---|
| src/config-file.test.ts | Adds comprehensive unit tests to drive coverage of config validation, loading/parsing, CLI mapping, and precedence logic. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
🔥 Smoke Test Results
Overall: PASS PR by
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: PASS · PR by
|
Smoke Test Results ✅Last 2 merged PRs:
Test Results:
Overall: PASS
|
Chroot Version Comparison Results
Result: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
Smoke Test: GitHub Actions Services Connectivity ✅All checks passed:
|
🏗️ Build Test Suite Results
Overall: 7/8 ecosystems passed — ❌ FAIL ❌ Failure DetailsJava — gson & caffeine: Maven failed to download plugins from Maven Central. The network is unreachable from within this environment for Maven dependency resolution. Note: The
|
…#2108) * test: improve config-file.ts coverage from 55% to 99% Add comprehensive tests for all uncovered code paths in config-file.ts: - validateAwfFileConfig: non-object root, all invalid field types across every config section (network, apiProxy, security, container, environment, logging, rateLimiting), unknown key rejection, and valid combinations - loadAwfFileConfig: YAML file loading (.yml extension), stdin YAML fallback, extensionless file JSON/YAML fallback, parse error messages, validation error messages with path/stdin labels - mapAwfFileConfigToCliOptions: all fields (security, container, env, logging, rateLimiting), empty array handling, undefined passthrough - applyConfigOptionsInPlaceWithCliPrecedence: all-apply, undefined-skip, and overwrite-without-CLI-flag scenarios Coverage improvement: - config-file.ts: 55.44% → 99.48% statements, 47.75% → 99.59% branches - Overall: 83.45% → 85.65% statements, 74.72% → 79.91% branches Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update src/config-file.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…#2108) * test: improve config-file.ts coverage from 55% to 99% Add comprehensive tests for all uncovered code paths in config-file.ts: - validateAwfFileConfig: non-object root, all invalid field types across every config section (network, apiProxy, security, container, environment, logging, rateLimiting), unknown key rejection, and valid combinations - loadAwfFileConfig: YAML file loading (.yml extension), stdin YAML fallback, extensionless file JSON/YAML fallback, parse error messages, validation error messages with path/stdin labels - mapAwfFileConfigToCliOptions: all fields (security, container, env, logging, rateLimiting), empty array handling, undefined passthrough - applyConfigOptionsInPlaceWithCliPrecedence: all-apply, undefined-skip, and overwrite-without-CLI-flag scenarios Coverage improvement: - config-file.ts: 55.44% → 99.48% statements, 47.75% → 99.59% branches - Overall: 83.45% → 85.65% statements, 74.72% → 79.91% branches Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update src/config-file.test.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Landon Cox <landon.cox@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Summary
Comprehensive test coverage improvements for
src/config-file.ts, a security-relevant module that handles loading and validating AWF configuration files.Coverage Improvement
config-file.tsstatementsconfig-file.tsbranchesSecurity-Critical Paths Now Covered
Input Validation (
validateAwfFileConfig)upstreamProxy, non-arrayblockDomains/dnsServersenabled, non-objecttargets, non-object/non-string provider fieldsallowHostPorts/allowHostServicePortsstring-or-array validation,difcProxyobject validation — critical for DIFC proxy injection preventionagentTimeoutpositive-integer validation (0, negative, float, string all rejected)excludeEnvstring-array validationlogLevelvalues (onlydebug/info/warn/erroraccepted)Config Loading (
loadAwfFileConfig).ymlextension)CLI Option Mapping (
mapAwfFileConfigToCliOptions)undefined(prevents overriding defaults with empty string)allowHostPortsarray → comma-joined stringPrecedence Logic (
applyConfigOptionsInPlaceWithCliPrecedence)undefinedvalues in config are skipped (don't null out existing options)Tests Added
79 new test cases in
src/config-file.test.ts.No Existing Tests Modified
All 1611 previously passing tests continue to pass. The 2 pre-existing failures in
src/docker-manager.test.tsare unrelated network/permission issues in the test environment.