Skip to content

Commit

Permalink
Fix issues EnterpriseAuthenticationAppLink policy
Browse files Browse the repository at this point in the history
* Handle invalid policy
* Add category default to the intent

Bug: b/201408457
Change-Id: I14cac9fb7b6f9039d7b11b870017bf35f9041571
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3757810
Reviewed-by: Richard Coles <torne@chromium.org>
Commit-Queue: Ayush Sharma <ayushsha@google.com>
Cr-Commit-Position: refs/heads/main@{#1024307}
  • Loading branch information
Ayush Sharma authored and Chromium LUCI CQ committed Jul 14, 2022
1 parent f66553a commit fd88034
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ bool EnterpriseAuthenticationAppLinkPolicyHandler::CheckPolicySettings(

std::vector<std::string> invalid_policies;
for (const auto& entry : value->GetList()) {
if (!ValidatePolicyEntry(entry.FindStringKey("url")))
invalid_policies.push_back(entry.GetString());
const std::string* url = entry.FindStringKey("url");
if (!url) {
invalid_policies.push_back(
"Invalid policy: Required key 'url' does not exists");
} else if (!ValidatePolicyEntry(url)) {
invalid_policies.push_back("Invalid url: " + *url);
}
}

if (!invalid_policies.empty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,23 @@ TEST_F(EnterpriseAuthenticationAppLinkPolicyHandlerTest, ValidPolicy) {
ASSERT_TRUE(pref_value);
EXPECT_EQ(expected, *pref_value);
}

TEST_F(EnterpriseAuthenticationAppLinkPolicyHandlerTest, InvalidPolicy) {
PolicyMap policy;
policy.Set(policy::key::kEnterpriseAuthenticationAppLinkPolicy,
POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, POLICY_SOURCE_PLATFORM,
base::JSONReader::Read(
"["
" {"
" \"abc\": \"https://www.testserver1.com/login\""
" },"
"]"),
nullptr);
this->UpdateProviderPolicy(policy);
const base::Value* pref_value = nullptr;

EXPECT_FALSE(store_->GetValue(
android_webview::prefs::kEnterpriseAuthAppLinkPolicy, &pref_value));
ASSERT_FALSE(pref_value);
}
} // namespace policy
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ private boolean sendBrowseIntent(String url) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
intent.setFlags(Intent.FLAG_ACTIVITY_REQUIRE_NON_BROWSER
| Intent.FLAG_ACTIVITY_REQUIRE_DEFAULT);
Expand Down

0 comments on commit fd88034

Please sign in to comment.