Skip to content

Commit 91764a0

Browse files
Add forward header tests for all instances. Add links to additional documentation in readme
1 parent 4956f43 commit 91764a0

File tree

46 files changed

+3165
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3165
-1
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ It's also possible to [locally test containers built from PRs in GitHub Containe
3131
### Infrastructure setup
3232

3333
If the instance is executed for the first time, it must set up the required infrastructure. To do so, once the instance is configured to use the selected transport and persister, run it in setup mode. This can be done by using the `Setup {instance name}` launch profile that is defined in
34-
the `launchSettings.json` file of each instance. When started in setup mode, the instance will start as usual, execute the setup process, and exit. At this point the instance can be run normally by using the non-setup launch profile.
34+
the `launchSettings.json` file of each instance. When started in setup mode, the instance will start as usual, execute the setup process, and exit. At this point the instance can be run normally by using the non-setup launch profile.
3535

3636
## Secrets
3737

@@ -56,6 +56,21 @@ Running all tests all the times takes a lot of resources. Tests are filtered bas
5656

5757
NOTE: If no variable is defined all tests will be executed.
5858

59+
## Security Configuration
60+
61+
Documentation for configuring security features:
62+
63+
- [HTTPS Configuration](docs/https-configuration.md) - Configure HTTPS/TLS for secure connections
64+
- [Forwarded Headers](docs/forwarded-headers.md) - Configure X-Forwarded-* header handling for reverse proxy scenarios
65+
- [Authentication](docs/authentication.md) - Configure authentication for the HTTP API
66+
67+
Local testing guides:
68+
69+
- [Local HTTPS Testing](docs/local-https-testing.md)
70+
- [Local Reverse Proxy Testing](docs/local-reverseproxy-testing.md)
71+
- [Local Forward Headers Testing](docs/local-forward-headers-testing.md)
72+
- [Local Authentication Testing](docs/local-authentication-testing.md)
73+
5974
## How to developer test the PowerShell Module
6075

6176
Steps:

docs/local-forward-headers-testing.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,82 @@ dotnet run
759759
curl -H "X-Forwarded-Proto: https" http://localhost:33633/debug/request-info | json
760760
```
761761

762+
## Unit Tests
763+
764+
Unit tests for the `ForwardedHeadersSettings` configuration class are located at:
765+
766+
```text
767+
src/ServiceControl.UnitTests/Infrastructure/Settings/ForwardedHeadersSettingsTests.cs
768+
```
769+
770+
### Running the Tests
771+
772+
```bash
773+
dotnet test src/ServiceControl.UnitTests/ServiceControl.UnitTests.csproj --filter "FullyQualifiedName~ForwardedHeadersSettingsTests"
774+
```
775+
776+
### What the Tests Cover
777+
778+
| Test | Purpose |
779+
|------|---------|
780+
| `Should_parse_known_proxies_from_comma_separated_list` | Verifies parsing of multiple proxy IPs |
781+
| `Should_parse_known_proxies_to_ip_addresses` | Verifies `KnownProxies` property returns valid `IPAddress` objects |
782+
| `Should_ignore_invalid_ip_addresses` | Verifies invalid IPs are filtered out gracefully |
783+
| `Should_parse_known_networks_from_comma_separated_cidr` | Verifies CIDR notation parsing |
784+
| `Should_ignore_invalid_network_cidr` | Verifies invalid CIDR entries are filtered |
785+
| `Should_disable_trust_all_proxies_when_known_proxies_configured` | Verifies auto-disable behavior |
786+
| `Should_disable_trust_all_proxies_when_known_networks_configured` | Verifies auto-disable behavior |
787+
| `Should_default_to_enabled` | Verifies default value |
788+
| `Should_default_to_trust_all_proxies` | Verifies default value |
789+
| `Should_respect_explicit_disabled_setting` | Verifies explicit configuration |
790+
| `Should_handle_semicolon_separator_in_proxies` | Tests alternate separator |
791+
| `Should_trim_whitespace_from_proxy_entries` | Tests whitespace handling |
792+
793+
## Acceptance Tests
794+
795+
Acceptance tests for end-to-end forwarded headers behavior are located at:
796+
797+
```text
798+
src/ServiceControl.AcceptanceTests/Security/ForwardedHeaders/
799+
src/ServiceControl.Audit.AcceptanceTests/Security/ForwardedHeaders/
800+
src/ServiceControl.Monitoring.AcceptanceTests/Security/ForwardedHeaders/
801+
```
802+
803+
Each instance type has identical tests covering all scenarios.
804+
805+
### Running the Tests
806+
807+
```bash
808+
# ServiceControl (Primary)
809+
dotnet test src/ServiceControl.AcceptanceTests.RavenDB/ServiceControl.AcceptanceTests.RavenDB.csproj --filter "FullyQualifiedName~ForwardedHeaders"
810+
811+
# ServiceControl.Audit
812+
dotnet test src/ServiceControl.Audit.AcceptanceTests/ServiceControl.Audit.AcceptanceTests.csproj --filter "FullyQualifiedName~ForwardedHeaders"
813+
814+
# ServiceControl.Monitoring
815+
dotnet test src/ServiceControl.Monitoring.AcceptanceTests/ServiceControl.Monitoring.AcceptanceTests.csproj --filter "FullyQualifiedName~ForwardedHeaders"
816+
```
817+
818+
### Scenarios Covered
819+
820+
| Scenario | Test |
821+
|----------|------|
822+
| 0 | `When_request_has_no_forwarded_headers` |
823+
| 1/2 | `When_forwarded_headers_are_sent` |
824+
| 3 | `When_known_proxies_are_configured` |
825+
| 4 | `When_known_networks_are_configured` |
826+
| 5 | `When_unknown_proxy_sends_headers` |
827+
| 6 | `When_unknown_network_sends_headers` |
828+
| 7 | `When_forwarded_headers_are_disabled` |
829+
| 8 | `When_proxy_chain_headers_are_sent` |
830+
| 9 | `When_proxy_chain_headers_are_sent_with_known_proxies` |
831+
| 10 | `When_combined_proxies_and_networks_are_configured` |
832+
| 11 | `When_only_proto_header_is_sent` |
833+
834+
> **Note:** Scenario 12 (IPv4/IPv6 Mismatch) is not covered by acceptance tests because the test server's IP address (IPv4 vs IPv6) cannot be controlled reliably. The "untrusted proxy" behavior is already validated by Scenarios 5 and 6.
835+
762836
## See Also
763837

764838
- [Hosting Guide](hosting-guide.md) - Configuration reference for forwarded headers
765839
- [Local Reverse Proxy Testing](local-reverseproxy-testing.md) - Testing with a real reverse proxy (NGINX)
840+
- [Testing Architecture](testing-architecture.md) - Overview of testing patterns in this repository

0 commit comments

Comments
 (0)