tree: 9b465345f9163d9f0f843e815020c4de18e26abe [search]
  1. bin/
  2. lib/
  3. reports/
  4. test/
  5. tool/
  6. LICENSE
  7. mono_pkg.yaml
  8. pubspec.yaml
  9. README.md
  10. shelf_summary.md
pkgs/_shelf_compliance/README.md

This package contains HTTP/1.1 compliance and hardening tests for package:shelf and future implementations.

Adapter conformance tests

package:_shelf_compliance/adapter_conformance.dart exposes testAll, a shared suite of behavior tests for shelf server adapters. An adapter's tests call it with a callback that starts the adapter:

import 'package:_shelf_compliance/adapter_conformance.dart';
import 'package:test/test.dart';

void main() {
  testAll(myServe, defaultPoweredByHeader: 'Dart with package:my_adapter');
}

pkgs/shelf/test/shelf_io_test.dart runs it against shelf_io. Adapters depend on this package with a path dev dependency.

Http11Probe compliance tests

The Http11Probe tests use the Http11Probe tool (vendored as a git submodule) to validate the server's behavior against RFC requirements and common edge cases.

Current Baseline

You can view the current compliance report for package:shelf here:

How it Works

The tests are defined in test/compliance_test.dart. For each test category (e.g., Compliance, Smuggling, MalformedInput):

  1. It starts an echo server (e.g., bin/shelf_echo.dart) on a dynamic port.
  2. It runs the .NET Http11Probe CLI tool against that port.
  3. It saves the raw JSON report to reports/[name]/[category].json.
  4. It compares the result with the established “golden” file in the same location.
  5. After all categories are run, it generates a combined summary file in the root (e.g., shelf_summary.md).

Running the Tests

You need the .NET 10 SDK installed to run these tests.

To run the full suite:

dart test

Updating Goldens

If you intentionally change behavior and need to update the baseline:

  1. Set const _updateGoldens = true; in test/compliance_test.dart.
  2. Run dart test. It will update the JSON and Markdown files and fail the test at the end to remind you to turn it off.
  3. Set _updateGoldens = false and commit the new goldens.

Project Structure

  • bin/: Echo server implementations (the “dut” or device under test).
  • reports/: Golden JSON reports per category.
  • test/: The test runner harness.
  • tool/: Scripts to post-process JSON reports into Markdown.