Commit 3220de6b authored by David Van Cleve's avatar David Van Cleve Committed by Chromium LUCI CQ

Trust Tokens: Correct a local issuance key commitment argument's name

Our docs say that this new field should be called
"unavailable_local_operation_fallback", but we implemented it as
"unavailable_local_issuance_fallback".

To fix the inconsistency, this mechanical change swaps out
"UnavailableLocalIssuanceFallback" for
"UnavailableLocalOperationFallback" and
"unavailable_local_issuance_fallback" for
"unavailable_local_operation_fallback" in the following directories:
- services/network/public/mojom
- services/network/trust_tokens

R=svaldez
CC=ykevin@google.com

Fixed: 1154057
Change-Id: I09eda98d0487435e5bf7797c93ecfb3b47073b93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2566476
Commit-Queue: David Van Cleve <davidvc@chromium.org>
Reviewed-by: default avatarMatthew Denton <mpdenton@chromium.org>
Reviewed-by: default avatarSteven Valdez <svaldez@chromium.org>
Auto-Submit: David Van Cleve <davidvc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832652}
parent aecdf1b5
......@@ -205,19 +205,19 @@ struct TrustTokenKeyCommitmentResult {
// one operating system, issuers could benefit from a couple different
// fallback behaviors depending on their particular requirements.
//
// |unavailable_local_issuance_fallback|'s value specifies what action to take
// when both of the following hold simultaneously:
// |unavailable_local_operation_fallback|'s value specifies what action to
// take when both of the following hold simultaneously:
// (1) local issuance is specified on at least one OS (i.e.
// |request_issuance_locally_on| is nonempty) and
// (2) we're not on any of the specified OSes.
enum UnavailableLocalIssuanceFallback {
enum UnavailableLocalOperationFallback {
// If we're not on a matching OS, instead attempt a standard web
// issuance request against the issuance request's destination URL.
kWebIssuance,
// If we're not on a matching OS, just fail the issuance request.
kReturnWithError,
};
UnavailableLocalIssuanceFallback unavailable_local_issuance_fallback;
UnavailableLocalOperationFallback unavailable_local_operation_fallback;
};
// Struct FulfillTrustTokenIssuanceRequest represents a Trust Tokens issuance
......
......@@ -38,5 +38,5 @@
"https"
"protocol_version"
"id"
"unavailable_local_issuance_fallback"
"unavailable_local_operation_fallback"
"request_issuance_locally_on"
......@@ -23,11 +23,11 @@ const char kTrustTokenKeyCommitmentExpiryField[] = "expiry";
const char kTrustTokenKeyCommitmentKeyField[] = "Y";
const char kTrustTokenKeyCommitmentRequestIssuanceLocallyOnField[] =
"request_issuance_locally_on";
const char kTrustTokenLocalIssuanceOsAndroid[] = "android";
const char kTrustTokenKeyCommitmentUnavailableLocalIssuanceFallbackField[] =
"unavailable_local_issuance_fallback";
const char kTrustTokenLocalIssuanceFallbackWebIssuance[] = "web_issuance";
const char kTrustTokenLocalIssuanceFallbackReturnWithError[] =
const char kTrustTokenLocalOperationOsAndroid[] = "android";
const char kTrustTokenKeyCommitmentUnavailableLocalOperationFallbackField[] =
"unavailable_local_operation_fallback";
const char kTrustTokenLocalOperationFallbackWebIssuance[] = "web_issuance";
const char kTrustTokenLocalOperationFallbackReturnWithError[] =
"return_with_error";
namespace {
......@@ -87,26 +87,26 @@ ParseKeyResult ParseSingleKeyExceptLabel(
base::Optional<mojom::TrustTokenKeyCommitmentResult::Os> ParseOs(
base::StringPiece os_string) {
if (os_string == kTrustTokenLocalIssuanceOsAndroid)
if (os_string == kTrustTokenLocalOperationOsAndroid)
return mojom::TrustTokenKeyCommitmentResult::Os::kAndroid;
return base::nullopt;
}
// Attempts to parse a string representation of a member of the
// UnavailableLocalIssuanceFallback enum, returning true on success and false on
// failure.
bool ParseUnavailableLocalIssuanceFallback(
// UnavailableLocalOperationFallback enum, returning true on success and false
// on failure.
bool ParseUnavailableLocalOperationFallback(
base::StringPiece fallback_string,
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalIssuanceFallback*
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalOperationFallback*
fallback_out) {
if (fallback_string == kTrustTokenLocalIssuanceFallbackWebIssuance) {
if (fallback_string == kTrustTokenLocalOperationFallbackWebIssuance) {
*fallback_out = mojom::TrustTokenKeyCommitmentResult::
UnavailableLocalIssuanceFallback::kWebIssuance;
UnavailableLocalOperationFallback::kWebIssuance;
return true;
}
if (fallback_string == kTrustTokenLocalIssuanceFallbackReturnWithError) {
if (fallback_string == kTrustTokenLocalOperationFallbackReturnWithError) {
*fallback_out = mojom::TrustTokenKeyCommitmentResult::
UnavailableLocalIssuanceFallback::kReturnWithError;
UnavailableLocalOperationFallback::kReturnWithError;
return true;
}
return false;
......@@ -114,12 +114,12 @@ bool ParseUnavailableLocalIssuanceFallback(
// Given a per-issuer key commitment dictionary, looks for the local Trust
// Tokens issuance-related fields request_issuance_locally_on and
// unavailable_local_issuance_fallback.
// unavailable_local_operation_fallback.
//
// Returns true if both are absent, or if both are present and well-formed; in
// the latter case, updates |result| to with their parsed values. Otherwise,
// returns false.
bool ParseLocalIssuanceFieldsIfPresent(
bool ParseLocalOperationFieldsIfPresent(
const base::Value& value,
mojom::TrustTokenKeyCommitmentResult* result) {
const base::Value* maybe_request_issuance_locally_on =
......@@ -151,10 +151,10 @@ bool ParseLocalIssuanceFieldsIfPresent(
oses.erase(to_remove, oses.end());
const std::string* maybe_fallback = value.FindStringKey(
kTrustTokenKeyCommitmentUnavailableLocalIssuanceFallbackField);
kTrustTokenKeyCommitmentUnavailableLocalOperationFallbackField);
if (!maybe_fallback ||
!ParseUnavailableLocalIssuanceFallback(
*maybe_fallback, &result->unavailable_local_issuance_fallback)) {
!ParseUnavailableLocalOperationFallback(
*maybe_fallback, &result->unavailable_local_operation_fallback)) {
return false;
}
......@@ -197,7 +197,7 @@ mojom::TrustTokenKeyCommitmentResultPtr ParseSingleIssuer(
return nullptr;
result->batch_size = *maybe_batch_size;
if (!ParseLocalIssuanceFieldsIfPresent(value, result.get()))
if (!ParseLocalOperationFieldsIfPresent(value, result.get()))
return nullptr;
// Parse the key commitments in the result (these are exactly the
......
......@@ -37,9 +37,9 @@ extern const char kTrustTokenKeyCommitmentOsAndroid[];
// The desired fallback behavior when local issuance isn't available on the
// requested operating system:
extern const char
kTrustTokenKeyCommitmentUnavailableLocalIssuanceFallbackField[];
extern const char kTrustTokenLocalIssuanceFallbackWebIssuance[];
extern const char kTrustTokenLocalIssuanceFallbackReturnWithError[];
kTrustTokenKeyCommitmentUnavailableLocalOperationFallbackField[];
extern const char kTrustTokenLocalOperationFallbackWebIssuance[];
extern const char kTrustTokenLocalOperationFallbackReturnWithError[];
// WARNING WARNING WARNING: When updating the parser implementation, please make
// sure the normative source(s) of the key commitment result data structure's
......
......@@ -438,7 +438,7 @@ TEST(TrustTokenKeyCommitmentParser, RequestIssuanceLocallyOn) {
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android"],
"unavailable_local_issuance_fallback": "web_issuance"
"unavailable_local_operation_fallback": "web_issuance"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -458,7 +458,7 @@ TEST(TrustTokenKeyCommitmentParser, DeduplicatesRequestIssuanceLocallyOn) {
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android", "android", "android"],
"unavailable_local_issuance_fallback": "web_issuance"
"unavailable_local_operation_fallback": "web_issuance"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -495,7 +495,7 @@ TEST(TrustTokenKeyCommitmentParser, RejectsTypeUnsafeRequestIssuanceLocallyOn) {
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": "not an array",
"unavailable_local_issuance_fallback": "web_issuance"
"unavailable_local_operation_fallback": "web_issuance"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -514,7 +514,7 @@ TEST(TrustTokenKeyCommitmentParser,
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android", 47],
"unavailable_local_issuance_fallback": "web_issuance"
"unavailable_local_operation_fallback": "web_issuance"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -533,7 +533,7 @@ TEST(TrustTokenKeyCommitmentParser,
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android", "imaginaryOS"],
"unavailable_local_issuance_fallback": "web_issuance"
"unavailable_local_operation_fallback": "web_issuance"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -544,7 +544,7 @@ TEST(TrustTokenKeyCommitmentParser,
}
TEST(TrustTokenKeyCommitmentParser,
ProvidingLocalIssuanceOsRequiresSpecifyingIssuanceFallback) {
ProvidingLocalOperationOsRequiresSpecifyingIssuanceFallback) {
std::string input =
R"({
"srrkey": "aaaa",
......@@ -562,7 +562,7 @@ TEST(TrustTokenKeyCommitmentParser,
}
TEST(TrustTokenKeyCommitmentParser,
RejectsTypeUnsafeUnavailableLocalIssuanceFallback) {
RejectsTypeUnsafeUnavailableLocalOperationFallback) {
std::string input =
R"({
"srrkey": "aaaa",
......@@ -570,7 +570,7 @@ TEST(TrustTokenKeyCommitmentParser,
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android"],
"unavailable_local_issuance_fallback": 57
"unavailable_local_operation_fallback": 57
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -581,7 +581,7 @@ TEST(TrustTokenKeyCommitmentParser,
}
TEST(TrustTokenKeyCommitmentParser,
RejectsUnrecognizedUnavailableLocalIssuanceFallback) {
RejectsUnrecognizedUnavailableLocalOperationFallback) {
std::string input =
R"({
"srrkey": "aaaa",
......@@ -589,7 +589,7 @@ TEST(TrustTokenKeyCommitmentParser,
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android"],
"unavailable_local_issuance_fallback": "not a valid enum value"
"unavailable_local_operation_fallback": "not a valid enum value"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -599,7 +599,7 @@ TEST(TrustTokenKeyCommitmentParser,
EXPECT_FALSE(result);
}
TEST(TrustTokenKeyCommitmentParser, ParsesLocalIssuanceFallbackWebIssuance) {
TEST(TrustTokenKeyCommitmentParser, ParsesLocalOperationFallbackWebIssuance) {
std::string input =
R"({
"srrkey": "aaaa",
......@@ -607,7 +607,7 @@ TEST(TrustTokenKeyCommitmentParser, ParsesLocalIssuanceFallbackWebIssuance) {
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android"],
"unavailable_local_issuance_fallback": "web_issuance"
"unavailable_local_operation_fallback": "web_issuance"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -615,13 +615,13 @@ TEST(TrustTokenKeyCommitmentParser, ParsesLocalIssuanceFallbackWebIssuance) {
mojom::TrustTokenKeyCommitmentResultPtr result =
TrustTokenKeyCommitmentParser().Parse(input);
ASSERT_TRUE(result);
EXPECT_EQ(result->unavailable_local_issuance_fallback,
EXPECT_EQ(result->unavailable_local_operation_fallback,
mojom::TrustTokenKeyCommitmentResult::
UnavailableLocalIssuanceFallback::kWebIssuance);
UnavailableLocalOperationFallback::kWebIssuance);
}
TEST(TrustTokenKeyCommitmentParser,
ParsesLocalIssuanceFallbackReturnWithError) {
ParsesLocalOperationFallbackReturnWithError) {
std::string input =
R"({
"srrkey": "aaaa",
......@@ -629,7 +629,7 @@ TEST(TrustTokenKeyCommitmentParser,
"protocol_version": "TrustTokenV2PMB",
"id": 1,
"request_issuance_locally_on": ["android"],
"unavailable_local_issuance_fallback": "return_with_error"
"unavailable_local_operation_fallback": "return_with_error"
})";
// Double-check that the input is actually valid JSON.
ASSERT_TRUE(base::JSONReader::Read(input));
......@@ -637,9 +637,9 @@ TEST(TrustTokenKeyCommitmentParser,
mojom::TrustTokenKeyCommitmentResultPtr result =
TrustTokenKeyCommitmentParser().Parse(input);
ASSERT_TRUE(result);
EXPECT_EQ(result->unavailable_local_issuance_fallback,
EXPECT_EQ(result->unavailable_local_operation_fallback,
mojom::TrustTokenKeyCommitmentResult::
UnavailableLocalIssuanceFallback::kReturnWithError);
UnavailableLocalOperationFallback::kReturnWithError);
}
TEST(TrustTokenKeyCommitmentParser, ParsesProtocolVersion) {
......
......@@ -167,9 +167,9 @@ void TrustTokenRequestIssuanceHelper::OnGotKeyCommitment(
return is_current_os_callback_.Run(os);
});
if (!should_divert_issuance_request_to_os_ &&
commitment_result->unavailable_local_issuance_fallback ==
commitment_result->unavailable_local_operation_fallback ==
mojom::TrustTokenKeyCommitmentResult::
UnavailableLocalIssuanceFallback::kReturnWithError) {
UnavailableLocalOperationFallback::kReturnWithError) {
// If the issuer requests that issuance be mediated by the OS on at least
// one platform, and we aren't on that platform, and the issuer has
// configured that we should return with an error in this case, do so.
......
......@@ -704,8 +704,8 @@ TEST_F(TrustTokenRequestIssuanceHelperTestWithPlatformIssuance,
auto key_commitment_result = ReasonableKeyCommitmentResult();
key_commitment_result->request_issuance_locally_on.push_back(
mojom::TrustTokenKeyCommitmentResult::Os::kAndroid);
key_commitment_result->unavailable_local_issuance_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalIssuanceFallback::
key_commitment_result->unavailable_local_operation_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalOperationFallback::
kReturnWithError;
auto getter = std::make_unique<FixedKeyCommitmentGetter>(
issuer, std::move(key_commitment_result));
......@@ -777,8 +777,8 @@ TEST_F(TrustTokenRequestIssuanceHelperTestWithPlatformIssuance,
auto key_commitment_result = ReasonableKeyCommitmentResult();
key_commitment_result->request_issuance_locally_on.push_back(
mojom::TrustTokenKeyCommitmentResult::Os::kAndroid);
key_commitment_result->unavailable_local_issuance_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalIssuanceFallback::
key_commitment_result->unavailable_local_operation_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalOperationFallback::
kWebIssuance;
auto getter = std::make_unique<FixedKeyCommitmentGetter>(
issuer, std::move(key_commitment_result));
......@@ -832,8 +832,8 @@ TEST_F(TrustTokenRequestIssuanceHelperTestWithPlatformIssuance,
auto key_commitment_result = ReasonableKeyCommitmentResult();
key_commitment_result->request_issuance_locally_on.push_back(
mojom::TrustTokenKeyCommitmentResult::Os::kAndroid);
key_commitment_result->unavailable_local_issuance_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalIssuanceFallback::
key_commitment_result->unavailable_local_operation_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalOperationFallback::
kReturnWithError;
auto getter = std::make_unique<FixedKeyCommitmentGetter>(
issuer, std::move(key_commitment_result));
......@@ -868,8 +868,8 @@ TEST_F(TrustTokenRequestIssuanceHelperTestWithPlatformIssuance,
auto key_commitment_result = ReasonableKeyCommitmentResult();
key_commitment_result->request_issuance_locally_on.push_back(
mojom::TrustTokenKeyCommitmentResult::Os::kAndroid);
key_commitment_result->unavailable_local_issuance_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalIssuanceFallback::
key_commitment_result->unavailable_local_operation_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalOperationFallback::
kWebIssuance;
auto getter = std::make_unique<FixedKeyCommitmentGetter>(
issuer, std::move(key_commitment_result));
......@@ -911,8 +911,8 @@ TEST_F(TrustTokenRequestIssuanceHelperTestWithPlatformIssuance,
// Specify that we should request issuance locally on Android...
key_commitment_result->request_issuance_locally_on.push_back(
mojom::TrustTokenKeyCommitmentResult::Os::kAndroid);
key_commitment_result->unavailable_local_issuance_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalIssuanceFallback::
key_commitment_result->unavailable_local_operation_fallback =
mojom::TrustTokenKeyCommitmentResult::UnavailableLocalOperationFallback::
kReturnWithError;
auto getter = std::make_unique<FixedKeyCommitmentGetter>(
......
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