#include "services/network/trust_tokens/trust_token_request_issuance_helper.h"
#include <memory>
#include "base/functional/callback.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "net/base/load_flags.h"
#include "net/base/request_priority.h"
#include "net/http/http_response_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_test_util.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/trust_token_http_headers.h"
#include "services/network/public/cpp/trust_token_parameterization.h"
#include "services/network/public/mojom/trust_tokens.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/trust_token_test_util.h"
#include "services/network/trust_tokens/operating_system_matching.h"
#include "services/network/trust_tokens/proto/public.pb.h"
#include "services/network/trust_tokens/proto/storage.pb.h"
#include "services/network/trust_tokens/trust_token_key_commitment_getter.h"
#include "services/network/trust_tokens/trust_token_parameterization.h"
#include "services/network/trust_tokens/trust_token_store.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/origin.h"
namespace network {
namespace {
_;
ByMove;
ElementsAre;
Invoke;
IsEmpty;
Optional;
Property;
Return;
ReturnNull;
StrEq;
StrictMock;
WithArgs;
UnblindedTokens;
class TrustTokenRequestIssuanceHelperTest : public TrustTokenRequestHelperTest { … };
class FixedKeyCommitmentGetter : public TrustTokenKeyCommitmentGetter { … };
base::NoDestructor<FixedKeyCommitmentGetter> g_fixed_key_commitment_getter{ … };
class MockCryptographer
: public TrustTokenRequestIssuanceHelper::Cryptographer { … };
class MockExpiryDelegate : public TrustTokenStore::RecordExpiryDelegate { … };
class MockTrustTokenPersister : public TrustTokenPersister { … };
class MockTrustTokenStore : public TrustTokenStore { … };
mojom::TrustTokenKeyCommitmentResultPtr ReasonableKeyCommitmentResult() { … }
FixedKeyCommitmentGetter* ReasonableKeyCommitmentGetter() { … }
}
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsIfTooManyIssuers) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsIfAtCapacity) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsIfKeyCommitmentFails) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest,
RejectsIfInitializingCryptographerFails) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsIfAddingKeyFails) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest,
RejectsIfGettingBlindedTokensFails) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, SetsRequestHeaders) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsIfResponseOmitsHeader) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, TreatsEmptyHeaderAsSuccess) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsIfResponseIsUnusable) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, Success) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, AssociatesIssuerWithToplevel) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, StoresObtainedTokens) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, ClearDataHeaderIgnored) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RejectsUnsuitableInsecureIssuer) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest,
RejectsUnsuitableNonHttpNonHttpsIssuer) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RespectsMaximumBatchsize) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, BadCustomKeys) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, CustomKeysStoresObtainedTokens) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, BadCustomIssuer) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, CustomIssuerStoresObtainedTokens) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, RecordsIssuanceTime) { … }
TEST_F(TrustTokenRequestIssuanceHelperTest, UpdatesIssuanceTime) { … }
}