Skip to content

Commit

Permalink
Update proto definitions for KidsManagementService
Browse files Browse the repository at this point in the history
This updates the client protos used in Chrome to match the format of
the messages on the wire.

Tested live, by checking that parent information is now correctly
displayed on the child device when the relevant flag is enabled.

Bug: 1402238
Change-Id: I4edb0957092d0207b6f0cc3670526107ab86e03b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4111859
Auto-Submit: James Lee <ljjlee@google.com>
Reviewed-by: Nohemi Fernandez <fernandex@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1085415}
  • Loading branch information
James Lee authored and Chromium LUCI CQ committed Dec 20, 2022
1 parent b0e3d9c commit 8998948
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ FamilyInfoFetcher::FamilyMember ConvertProtoFamilyMember(
const kids_chrome_management::FamilyMember& member) {
FamilyInfoFetcher::FamilyMember converted;
converted.display_name = member.profile().display_name();
converted.profile_image_url = member.profile().default_profile_image_url();
converted.profile_url = member.profile().profile_image_url();
converted.profile_image_url = member.profile().profile_image_url();
converted.profile_url = member.profile().profile_url();
converted.email = member.profile().email();
converted.obfuscated_gaia_id = member.profile().obfuscated_user_id();
converted.obfuscated_gaia_id = member.user_id();
converted.role = ConvertProtoRole(member.role());
return converted;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,18 @@ option optimize_for = LITE_RUNTIME;
package kids_chrome_management;

// Basic user profile information.
message UserProfile {
// Obfuscated Gaia ID of the member. Required.
optional string obfuscated_user_id = 1;

// Primary email address of the user. Required.
optional string email = 2;

message FamilyMemberProfile {
// The user's full name, synthesized with structured and unstructured name
// fields informed by the user. Optional.
optional string display_name = 3;
optional string display_name = 1;

// Portrait photo of the user. Optional.
optional string profile_image_url = 4;
optional string profile_url = 2;

// Default profile image to use if profile_image_url is not set. Required.
optional string default_profile_image_url = 5;
// Portrait photo of the user. Optional.
optional string profile_image_url = 3;

// Next id: 6
// Primary email address of the user. Will always not be set for ULP accounts.
optional string email = 4;
}

// The role a user has within a family.
Expand Down Expand Up @@ -51,9 +45,12 @@ enum FamilyRole {

// Data about a family member.
message FamilyMember {
// Obfuscated Gaia ID of the member. Required.
optional string user_id = 1;

// The user's role in the family. Required.
optional FamilyRole role = 1;
optional FamilyRole role = 3;

// Profile of the family member. Required.
optional UserProfile profile = 2;
// Profile of the family member.
optional FamilyMemberProfile profile = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ TEST_F(KidsExternalFetcherTest, AcceptsRequests) {
"bob@gmail.com", ConsentLevel::kSignin);
Receiver<ListFamilyMembersRequest, ListFamilyMembersResponse> receiver;
ListFamilyMembersResponse response;
response.set_self_obfuscated_gaia_id("gaia_id");

auto fetcher = FetchListFamilyMembers(
*identity_test_env_.identity_manager(),
Expand All @@ -88,7 +87,6 @@ TEST_F(KidsExternalFetcherTest, AcceptsRequests) {
pending_request->request.url.spec(), response.SerializeAsString());

ASSERT_TRUE(receiver.GetResult().has_value());
EXPECT_EQ(receiver.GetResult().value()->self_obfuscated_gaia_id(), "gaia_id");
}

TEST_F(KidsExternalFetcherTest, NoAccessToken) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ FamilyMember* AddFamilyMember(ListFamilyMembersResponse& response,
member->set_role(role);
*member->mutable_profile()->mutable_display_name() =
std::string(display_name);
*member->mutable_profile()->mutable_obfuscated_user_id() =
std::string(user_id);
*member->mutable_user_id() = std::string(user_id);
*member->mutable_profile()->mutable_email() = std::string(email);
return member;
}
Expand Down Expand Up @@ -136,7 +135,6 @@ class KidsManagementServiceTest : public ::testing::Test {
// Test if the data from endpoint is properly stored in the service.
TEST_F(KidsManagementServiceTest, FetchesData) {
ListFamilyMembersResponse response;
response.set_self_obfuscated_gaia_id("gaia_id");
FamilyMember* member = AddChildTo(response);

identity_test_environment->MakePrimaryAccountAvailable(
Expand All @@ -157,7 +155,6 @@ TEST_F(KidsManagementServiceTest, FetchesData) {
// Test if the parent and head of household are set.
TEST_F(KidsManagementServiceTest, SetsCustodians) {
ListFamilyMembersResponse response;
response.set_self_obfuscated_gaia_id("gaia_id");
FamilyMember* child = AddChildTo(response);
FamilyMember* parent = AddParentTo(response);
FamilyMember* head_of_household = AddHeadOfHouseholdTo(response);
Expand All @@ -183,7 +180,6 @@ TEST_F(KidsManagementServiceTest, SetsCustodians) {
// Test if the daily fetches are scheduled.
TEST_F(KidsManagementServiceTest, SchedulesNextFetch) {
ListFamilyMembersResponse response;
response.set_self_obfuscated_gaia_id("gaia_id");
FamilyMember* child = AddChildTo(response);

CreatePrimaryAccount(child->profile().email());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ void KidsProfileManager::Custodian::Clear() {
void KidsProfileManager::Custodian::Update(const FamilyMember& family_member) {
name_.Set(family_member.profile().display_name());
email_.Set(family_member.profile().email());
gaiaID_.Set(family_member.profile().obfuscated_user_id());
profileURL_.Set(family_member.profile().profile_image_url());
imageURL_.Set(family_member.profile().default_profile_image_url());
gaiaID_.Set(family_member.user_id());
profileURL_.Set(family_member.profile().profile_url());
imageURL_.Set(family_member.profile().profile_image_url());
}

KidsProfileManager::Property::Property(KidsProfileManager* manager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ class KidsProfileManagerTest : public ::testing::Test {
base::StringPiece email,
base::StringPiece user_id,
base::StringPiece profile_image_url,
base::StringPiece default_profile_image_url) {
base::StringPiece profile_url) {
FamilyMember member;
*member.mutable_profile()->mutable_display_name() =
std::string(display_name);
*member.mutable_profile()->mutable_email() = std::string(email);
*member.mutable_profile()->mutable_obfuscated_user_id() =
std::string(user_id);
*member.mutable_user_id() = std::string(user_id);
*member.mutable_profile()->mutable_profile_image_url() =
std::string(profile_image_url);
*member.mutable_profile()->mutable_default_profile_image_url() =
std::string(default_profile_image_url);
*member.mutable_profile()->mutable_profile_url() = std::string(profile_url);
return member;
}

Expand Down Expand Up @@ -142,9 +140,8 @@ TEST_F(KidsProfileManagerTest, SetPrimaryCustodian) {
profile_
.SetIsSupervisedProfile(); // Then it will be possible to clear values.

FamilyMember member =
CreateFamilyMember("display_name", "email", "user_id",
"profile_image_url", "default_profile_image_url");
FamilyMember member = CreateFamilyMember("display_name", "email", "user_id",
"profile_image_url", "profile_url");

under_test.SetFirstCustodian(member);

Expand All @@ -157,10 +154,10 @@ TEST_F(KidsProfileManagerTest, SetPrimaryCustodian) {
"user_id");
EXPECT_EQ(
pref_service()->GetString(prefs::kSupervisedUserCustodianProfileURL),
"profile_image_url");
"profile_url");
EXPECT_EQ(
pref_service()->GetString(prefs::kSupervisedUserCustodianProfileImageURL),
"default_profile_image_url");
"profile_image_url");

under_test.UpdateChildAccountStatus(false);

Expand All @@ -187,9 +184,8 @@ TEST_F(KidsProfileManagerTest, SetSecondaryCustodian) {
profile_
.SetIsSupervisedProfile(); // Then it will be possible to clear values.

FamilyMember member =
CreateFamilyMember("display_name", "email", "user_id",
"profile_image_url", "default_profile_image_url");
FamilyMember member = CreateFamilyMember("display_name", "email", "user_id",
"profile_image_url", "profile_url");

under_test.SetSecondCustodian(member);

Expand All @@ -204,10 +200,10 @@ TEST_F(KidsProfileManagerTest, SetSecondaryCustodian) {
"user_id");
EXPECT_EQ(pref_service()->GetString(
prefs::kSupervisedUserSecondCustodianProfileURL),
"profile_image_url");
"profile_url");
EXPECT_EQ(pref_service()->GetString(
prefs::kSupervisedUserSecondCustodianProfileImageURL),
"default_profile_image_url");
"profile_image_url");

under_test.UpdateChildAccountStatus(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ message ListFamilyMembersRequest {
// Next id: 2
}

// See go/chrome-list-family-members-response (Googlers only).
message ListFamilyMembersResponse {
// Obfuscated Gaia ID of the calling user. Required.
optional string self_obfuscated_gaia_id = 1;

// List of family members from the family requested. Required.
// Contains at least the Head of Household.
// Throws an exception and fails if the user is not in any family.
repeated FamilyMember members = 2;

// Next id: 3
repeated FamilyMember members = 1;
}

message RequestRestrictedUrlAccessRequest {
Expand Down Expand Up @@ -67,4 +63,4 @@ message ClassifyUrlResponse {
optional DisplayClassification display_classification = 1;

// Next id: 2
}
}

0 comments on commit 8998948

Please sign in to comment.