chromium/services/network/oblivious_http_request_handler_unittest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <cstddef>
#include <cstdint>

#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "mojo/public/cpp/test_support/fake_message_dispatch_context.h"
#include "mojo/public/cpp/test_support/test_utils.h"
#include "net/http/http_status_code.h"
#include "net/log/test_net_log.h"
#include "net/log/test_net_log_util.h"
#include "net/third_party/quiche/src/quiche/binary_http/binary_http_message.h"
#include "net/third_party/quiche/src/quiche/common/quiche_data_writer.h"
#include "net/third_party/quiche/src/quiche/oblivious_http/oblivious_http_gateway.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/network_context.h"
#include "services/network/network_service.h"
#include "services/network/oblivious_http_request_handler.h"
#include "services/network/public/mojom/fetch_api.mojom-shared.h"
#include "services/network/public/mojom/oblivious_http_request.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/fake_test_cert_verifier_params_factory.h"
#include "services/network/test/test_network_context.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/boringssl/src/include/openssl/hpke.h"

namespace {

const char kRelayURL[] =;
const char kResourceURL[] =;

// These keys were randomly generated as follows:
// EVP_HPKE_KEY keys;
// EVP_HPKE_KEY_generate(&keys, EVP_hpke_x25519_hkdf_sha256());
// and then EVP_HPKE_KEY_public_key and EVP_HPKE_KEY_private_key were used to
// extract the keys.
const uint8_t kTestPrivateKey[] =;

const uint8_t kTestPublicKey[] =;

testing::Matcher<net::HttpRequestHeaders::HeaderVector> UnorderedHeadersAre(
    const net::HttpRequestHeaders::HeaderVector& expected) {}

class TestOhttpClient : public network::mojom::ObliviousHttpClient {};

}  // namespace

class TestObliviousHttpRequestHandler : public testing::Test {};

TEST_F(TestObliviousHttpRequestHandler, TestDisconnect) {}

TEST_F(TestObliviousHttpRequestHandler, TestInvalidArguments) {}

TEST_F(TestObliviousHttpRequestHandler, TestRequestFormat) {}

TEST_F(TestObliviousHttpRequestHandler, TestTimeout) {}

TEST_F(TestObliviousHttpRequestHandler, HandlesOuterHttpError) {}

TEST_F(TestObliviousHttpRequestHandler, HandlesInnerHttpError) {}

TEST_F(TestObliviousHttpRequestHandler, HandlesMultipleRequests) {}

TEST_F(TestObliviousHttpRequestHandler, PadsUpToNextPowerOfTwo) {}

TEST_F(TestObliviousHttpRequestHandler, DoesntPadsIfAlreadyPowerOfTwo) {}

TEST_F(TestObliviousHttpRequestHandler, PadsExponentiallyRandomly) {}

TEST_F(TestObliviousHttpRequestHandler,
       PadsBothExponentiallyRandomlyAndPowerOfTwo) {}