Commit 80b5bc36 authored by David Van Cleve's avatar David Van Cleve Committed by Commit Bot

Trust Tokens: add test coverage for maximum batchsize

This CL adds a test covering trust token issuance against an issuer
whose configured batch size (number of tokens to request) is greater
than the parameterized maximum batch size. It verifies that the number
of tokens requested gets clamped to the maximum.

R=csharrison

Fixed: 1065388
Change-Id: I212d5e6a0b9dae6c8c812ed2513b2a4a4ff8d145
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2150304
Auto-Submit: David Van Cleve <davidvc@chromium.org>
Commit-Queue: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: default avatarCharlie Harrison <csharrison@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760078}
parent 9a0e0369
......@@ -538,4 +538,39 @@ TEST_F(TrustTokenRequestIssuanceHelperTest,
mojom::TrustTokenOperationStatus::kInvalidArgument);
}
TEST_F(TrustTokenRequestIssuanceHelperTest, RespectsMaximumBatchsize) {
std::unique_ptr<TrustTokenStore> store = TrustTokenStore::CreateInMemory();
SuitableTrustTokenOrigin issuer =
*SuitableTrustTokenOrigin::Create(GURL("https://issuer.com/"));
auto key_commitment_result = mojom::TrustTokenKeyCommitmentResult::New();
key_commitment_result->keys.push_back(mojom::TrustTokenVerificationKey::New(
"key", /*expiry=*/base::Time(), /*label=*/0));
key_commitment_result->batch_size =
mojom::TrustTokenKeyCommitmentBatchSize::New(
static_cast<int>(kMaximumTrustTokenIssuanceBatchSize + 1));
auto getter = std::make_unique<FixedKeyCommitmentGetter>(
issuer, std::move(key_commitment_result));
auto cryptographer = std::make_unique<MockCryptographer>();
EXPECT_CALL(*cryptographer, AddKey(_)).WillOnce(Return(true));
// The batch size should be clamped to the configured maximum.
EXPECT_CALL(*cryptographer,
BeginIssuance(kMaximumTrustTokenIssuanceBatchSize))
.WillOnce(
Return(std::string("this string contains some blinded tokens")));
TrustTokenRequestIssuanceHelper helper(
*SuitableTrustTokenOrigin::Create(GURL("https://toplevel.com/")),
store.get(), std::move(getter), std::move(cryptographer));
auto request = MakeURLRequest("https://issuer.com/");
request->set_initiator(issuer);
ASSERT_EQ(ExecuteBeginOperationAndWaitForResult(&helper, request.get()),
mojom::TrustTokenOperationStatus::kOk);
}
} // namespace network
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment