#include "services/network/trust_tokens/trust_token_request_redemption_helper.h"
#include <memory>
#include "base/functional/callback.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/task_environment.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/trust_token_http_headers.h"
#include "services/network/public/cpp/trust_token_parameterization.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/proto/public.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 "services/network/trust_tokens/types.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace network {
namespace {
_;
Optional;
Property;
Return;
class TrustTokenRequestRedemptionHelperTest
: public TrustTokenRequestHelperTest { … };
class FixedKeyCommitmentGetter : public TrustTokenKeyCommitmentGetter { … };
base::NoDestructor<FixedKeyCommitmentGetter> g_fixed_key_commitment_getter{ … };
class MockCryptographer
: public TrustTokenRequestRedemptionHelper::Cryptographer { … };
}
TEST_F(TrustTokenRequestRedemptionHelperTest, RejectsIfTooManyIssuers) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RejectsIfKeyCommitmentFails) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RejectsIfNoTokensToRedeem) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest,
RejectsIfInitializingCryptographerFails) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest,
RejectsIfAddingRequestHeaderFails) { … }
namespace {
class TrustTokenBeginRedemptionPostconditionsTest
: public TrustTokenRequestRedemptionHelperTest { … };
}
TEST_F(TrustTokenBeginRedemptionPostconditionsTest, SetsHeaders) { … }
class TrustTokenBeginRedemptionPostconditionsTestWithMetrics
: public TrustTokenBeginRedemptionPostconditionsTest { … };
TEST_F(TrustTokenBeginRedemptionPostconditionsTestWithMetrics,
RecordsNonemptyRequestHistogram) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RecordsEmptyRequestHistogram) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RejectsIfResponseOmitsHeader) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RejectsIfResponseIsUnusable) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, Success) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, AssociatesIssuerWithToplevel) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, NegativeLifetime) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, NonnumericLifetime) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, StoresObtainedRedemptionRecord) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RedemptionRecordCacheHit) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest,
SuccessUsingRefreshRrOverwritesStoredRr) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, RejectsUnsuitableInsecureIssuer) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest,
RejectsUnsuitableNonHttpNonHttpsIssuer) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, BadCustomKeys) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, CustomKeysSuccess) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, BadCustomIssuer) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, CustomIssuerSuccess) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest, LimitThirdRedemptionAllowFourth) { … }
TEST_F(TrustTokenRequestRedemptionHelperTest,
AllowFirstThreeRedemptionsLimitFourth) { … }
}