コード例 #1
0
def test_https_h2_sni(sni_test_server_fixture):
    """
  Tests SNI indication works on https/h1
  """
    # Verify success when we set the right host
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient([
        sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
        "--duration", "100", "--termination-predicate", "benchmark.http_2xx:2",
        "--request-header", ":authority: sni.com", "--h2"
    ])
    counters = sni_test_server_fixture.getNighthawkCounterMapFromJson(
        parsed_json)
    assertCounterGreaterEqual(counters, "benchmark.http_2xx", 1)
    assertCounterGreaterEqual(counters, "upstream_cx_http2_total", 1)
    assertCounterEqual(counters, "ssl.handshake", 1)

    # Verify success when we set the right host
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient([
        sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
        "--duration", "100", "--termination-predicate", "benchmark.http_2xx:2",
        "--request-header", "host: sni.com", "--h2"
    ])
    counters = sni_test_server_fixture.getNighthawkCounterMapFromJson(
        parsed_json)
    assertCounterGreaterEqual(counters, "benchmark.http_2xx", 1)
    assertCounterGreaterEqual(counters, "upstream_cx_http2_total", 1)
    assertCounterEqual(counters, "ssl.handshake", 1)

    # Verify failure when we set no host (will get plain http)
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient(
        [
            sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
            "--duration", "100", "--h2"
        ],
        expect_failure=True)

    # Verify failure when we provide both host and :authority: (will get plain http)
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient(
        [
            sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
            "--duration", "100", "--h2", "--request-header", "host: sni.com",
            "--request-header", ":authority: sni.com"
        ],
        expect_failure=True)
コード例 #2
0
def test_https_h1_sni(sni_test_server_fixture):
    """
  Tests SNI indication works on https/h1
  """
    # Verify success when we set the right host
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient([
        sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
        "--duration", "100", "--termination-predicate", "benchmark.http_2xx:2",
        "--request-header", "host: sni.com"
    ])
    counters = sni_test_server_fixture.getNighthawkCounterMapFromJson(
        parsed_json)
    assertCounterGreaterEqual(counters, "benchmark.http_2xx", 1)
    assertCounterGreaterEqual(counters, "upstream_cx_http1_total", 1)
    assertCounterGreaterEqual(counters, "ssl.handshake", 1)

    # Verify failure when we set no host (will get plain http)
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient(
        [
            sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
            "--duration", "100"
        ],
        expect_failure=True)

    # Verify success when we use plain http and don't request the sni host
    parsed_json, _ = sni_test_server_fixture.runNighthawkClient(
        [
            sni_test_server_fixture.getTestServerRootUri(), "--rps", "100",
            "--duration", "100"
        ],
        expect_failure=True)

    parsed_json, _ = sni_test_server_fixture.runNighthawkClient(
        [
            sni_test_server_fixture.getTestServerRootUri().replace(
                "https://", "http://"), "--rps", "100", "--duration", "100",
            "--termination-predicate", "benchmark.http_2xx:2"
        ],
        expect_failure=False)
    counters = sni_test_server_fixture.getNighthawkCounterMapFromJson(
        parsed_json)
    assertCounterGreaterEqual(counters, "benchmark.http_2xx", 1)
    assertCounterGreaterEqual(counters, "upstream_cx_http1_total", 1)
    assertNotIn("ssl.handshake", counters)