Skip to content

mrrubinos/h2spec-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

h2spec Nix Flake

NixOS License: MIT

A Nix flake for h2spec, the HTTP/2 conformance testing tool.

h2spec is compliant with RFC 7540 (HTTP/2) and RFC 7541 (HPACK).

Installation

Run without installing

nix run github:mrrubinos/h2spec -- -h 127.0.0.1 -p 8080

Install to profile

nix profile install github:mrrubinos/h2spec

NixOS Configuration (Flake)

Add to your flake.nix inputs:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    h2spec = {
      url = "github:mrrubinos/h2spec";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, h2spec, ... }: {
    nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      specialArgs = { inherit h2spec; };
      modules = [ ./configuration.nix ];
    };
  };
}

Then in configuration.nix:

{ pkgs, h2spec, ... }:

{
  environment.systemPackages = [
    h2spec.packages.${pkgs.system}.default
  ];
}

As an overlay

If you prefer pkgs.h2spec to be available throughout your configuration:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    h2spec = {
      url = "github:mrrubinos/h2spec";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { self, nixpkgs, h2spec, ... }: {
    nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        {
          nixpkgs.overlays = [
            (final: prev: {
              h2spec = h2spec.packages.${prev.system}.default;
            })
          ];
        }
        ./configuration.nix
      ];
    };
  };
}

Then use it anywhere:

{ pkgs, ... }:

{
  environment.systemPackages = [ pkgs.h2spec ];
}

Home Manager

{ pkgs, h2spec, ... }:

{
  home.packages = [
    h2spec.packages.${pkgs.system}.default
  ];
}

Development shell

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    h2spec.url = "github:mrrubinos/h2spec";
  };

  outputs = { self, nixpkgs, h2spec, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
    in {
      devShells.${system}.default = pkgs.mkShell {
        buildInputs = [
          h2spec.packages.${system}.default
        ];
      };
    };
}

Usage

# Basic conformance test
h2spec -h 127.0.0.1 -p 8080

# TLS mode (skip certificate verification)
h2spec -h 127.0.0.1 -p 8443 -t -k

# Verbose output
h2spec -h 127.0.0.1 -p 8080 -v

# Strict mode (includes SHOULD requirements from RFC)
h2spec -h 127.0.0.1 -p 8080 -S

# Run specific test sections
h2spec -h 127.0.0.1 -p 8080 http2         # All HTTP/2 tests
h2spec -h 127.0.0.1 -p 8080 http2/6.1     # HEADERS frame
h2spec -h 127.0.0.1 -p 8080 http2/6.9     # WINDOW_UPDATE
h2spec -h 127.0.0.1 -p 8080 hpack         # HPACK compression

# Generate JUnit report (useful for CI)
h2spec -h 127.0.0.1 -p 8080 -j report.xml

# List all tests without running
h2spec --dryrun

Test Specifications

Spec ID Description
generic Generic HTTP/2 server test cases
http2 RFC 7540 (HTTP/2) compliance tests
hpack RFC 7541 (HPACK compression) tests

Available Packages

Package Description
h2spec Built from source (default)

Supported Platforms

  • x86_64-linux
  • aarch64-linux
  • x86_64-darwin
  • aarch64-darwin

Server Requirements

Your HTTP/2 server must:

  • Respond to GET / and POST / requests
  • Return status 200
  • Return a non-empty response body

Example: Testing with Bandit (Elixir)

defmodule TestPlug do
  import Plug.Conn

  def init(opts), do: opts

  def call(conn, _opts) do
    conn
    |> put_resp_content_type("text/plain")
    |> send_resp(200, "OK")
  end
end

# Start server
Bandit.start_link(plug: TestPlug, port: 8080)

Then run:

h2spec -h 127.0.0.1 -p 8080

Building from source

If you clone this repository and want to build locally:

nix build .#h2spec

./result/bin/h2spec --version

License

This flake is licensed under the MIT License.

h2spec itself is also MIT licensed.

Related Projects

  • h2spec - The upstream project

About

A Nix flake for h2spec https://github.com/summerwind/h2spec

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages