chromium/services/network/trust_tokens/trust_token_key_commitment_controller_unittest.cc

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

#include "services/network/trust_tokens/trust_token_key_commitment_controller.h"

#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_test_util.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/mojom/trust_tokens.mojom-forward.h"
#include "services/network/public/mojom/trust_tokens.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_url_loader_factory.h"
#include "services/network/test/test_utils.h"
#include "services/network/trust_tokens/trust_token_key_commitment_controller.h"
#include "services/network/trust_tokens/trust_token_parameterization.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"

Optional;

namespace network {

CreateTrustTokenKeyCommitmentRequest;

namespace {

class FixedKeyCommitmentParser
    : public TrustTokenKeyCommitmentController::Parser {};

class FailingKeyCommitmentParser
    : public TrustTokenKeyCommitmentController::Parser {};

GURL IssuerDotComKeyCommitmentPath() {}

class CommitmentWaiter {};

}  // namespace

// Use a fixture just to reduce the amount of boilerplate it takes to create an
// empty URLRequest.
class TrustTokenKeyCommitmentControllerTest : public ::testing::Test {};

// Test that CreateTrustTokenKeyCommitmentRequest satisfies the contract
// provided by its function comment:
TEST_F(TrustTokenKeyCommitmentControllerTest, CreatedRequestsBypassCache) {}

TEST_F(TrustTokenKeyCommitmentControllerTest,
       CreatedRequestsAreUncredentialed) {}

TEST_F(TrustTokenKeyCommitmentControllerTest,
       CreatedRequestsCopyUnderlyingRequestsInitiators) {}

TEST_F(TrustTokenKeyCommitmentControllerTest,
       CreatedRequestsSetOriginToProvidedTopLevel) {}

// On network error, the key commitment controller should
// pass the underlying error code upstream.
TEST_F(TrustTokenKeyCommitmentControllerTest, NetworkError) {}

// On a failed parse (emulated by FailingKeyCommitmentParser) after a
// successful network request, the controller should return
// kCouldntParse.
TEST_F(TrustTokenKeyCommitmentControllerTest, NetworkSuccessParseFailure) {}

// On a redirect, the controller should fail with kGotRedirected.
TEST_F(TrustTokenKeyCommitmentControllerTest, Redirect) {}

// On successful response and successful parse of the result,
// we should see net::OK and a non-null TrustTokenKeyCommitmentResult.
TEST_F(TrustTokenKeyCommitmentControllerTest, Success) {}

}  // namespace network