Commit 85042b45 authored by Kyle Williams's avatar Kyle Williams Committed by Commit Bot

cfm: Add App ID for intended Packaged App

Creates a helper function to determine if the value passed by
extensions::Extension::id(), which returns extensions::ExtensionsID,
is a valid app id for a Packaged Application supported by the
Chromebox For Meeting platform.

BUG=chromium:1105567
TEST='autoninja -C out/Default chromeos:chromeos_unittests &&
./out/Default/chromeos_unittests --dbus-stub --single-process-tests
--gtest_filter=CfmAppIdUtilTest.*'

Change-Id: I84e85563119afcb564407f88c214aa649ad79626
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2304334
Commit-Queue: Kyle Williams <kdgwill@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791148}
parent f041d1a2
...@@ -6,6 +6,8 @@ assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos") ...@@ -6,6 +6,8 @@ assert(is_chromeos, "Non-ChromeOS builds cannot depend on //chromeos")
source_set("cpp") { source_set("cpp") {
sources = [ sources = [
"appid_util.cc",
"appid_util.h",
"service_connection.cc", "service_connection.cc",
"service_connection.h", "service_connection.h",
] ]
...@@ -33,7 +35,10 @@ source_set("test_support") { ...@@ -33,7 +35,10 @@ source_set("test_support") {
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [ "service_connection_unittest.cc" ] sources = [
"appid_util_unittest.cc",
"service_connection_unittest.cc",
]
deps = [ deps = [
":cpp", ":cpp",
":test_support", ":test_support",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/cfm/public/cpp/appid_util.h"
#include <base/stl_util.h>
namespace chromeos {
namespace cfm {
namespace {
// List of whitelisted internal App IDs for CfM.
constexpr char const* kInternalHotrodAppIds[] = {
"moklfjoegmpoolceggbebbmgbddlhdgp", // Stable
"ldmpofkllgeicjiihkimgeccbhghhmfj", // Beta
"denipklgekfpcdmbahmbpnmokgajnhma" // Alpha
"kjfhgcncjdebkoofmbjoiemiboifnpbo", // Dev
// Keep in sync with app_info.ts (go/googlehotrodappids).
};
// List of whitelisted external App IDs for CfM.
constexpr char const* kExternalHotrodAppIds[] = {
"ikfcpmgefdpheiiomgmhlmmkihchmdlj", // Stable
"jlgegmdnodfhciolbdjciihnlaljdbjo", // Beta
"lkbhffjfgpmpeppncnimiiikojibkhnm", // Alpha
"acdafoiapclbpdkhnighhilgampkglpc", // Dev
"hkamnlhnogggfddmjomgbdokdkgfelgg", // TestGaia
// Keep in sync with app_info.ts (go/hotrodappids).
};
// Returns true if the ID provided matches a valid internal hotrod appid.
bool IsInternalHotrodAppId(const std::string& app_id) {
return base::Contains(kInternalHotrodAppIds, app_id);
}
// Returns true if the ID provided matches a valid external hotrod appid.
bool IsExternalHotrodAppId(const std::string& app_id) {
return base::Contains(kExternalHotrodAppIds, app_id);
}
} // namespace
bool IsChromeboxForMeetingsAppId(const std::string& app_id) {
return IsExternalHotrodAppId(app_id) || IsInternalHotrodAppId(app_id);
}
} // namespace cfm
} // namespace chromeos
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_SERVICES_CFM_PUBLIC_CPP_APPID_UTIL_H_
#define CHROMEOS_SERVICES_CFM_PUBLIC_CPP_APPID_UTIL_H_
#include <string>
namespace chromeos {
namespace cfm {
// Returns true if the id provided matches a valid CfM PA/PWA appid.
bool IsChromeboxForMeetingsAppId(const std::string& app_id);
} // namespace cfm
} // namespace chromeos
#endif // CHROMEOS_SERVICES_CFM_PUBLIC_CPP_APPID_UTIL_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/cfm/public/cpp/appid_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace cfm {
namespace {
using CfmAppIdUtilTest = testing::Test;
TEST_F(CfmAppIdUtilTest, AppIdIsTrue) {
std::string app_id = "hkamnlhnogggfddmjomgbdokdkgfelgg";
ASSERT_TRUE(IsChromeboxForMeetingsAppId(app_id));
}
TEST_F(CfmAppIdUtilTest, AppIdIsFalse) {
std::string app_id = "FAKE_APP_ID";
ASSERT_FALSE(IsChromeboxForMeetingsAppId(app_id));
}
} // namespace
} // namespace cfm
} // namespace chromeos
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