New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 630614 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Linux , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

Policies loaded from disk can fail unit tests

Project Member Reported by ljusten@chromium.org, Jul 22 2016

Issue description

For instance, setting
{
  "ForceSafeSearch": true
}
in /etc/chromium/policy/managed/testpolicy.json will fail SupervisedUserServiceTest.LocalPolicies in browser_tests.

Tests should not load policy files.
 

Comment 1 by tnagel@chromium.org, Jul 22 2016

Labels: OS-Chrome OS-Mac
Status: Assigned (was: Untriaged)
In my opinion, this should be fixed by specifying a non-existing directory as a parameter to CreateBrowserPolicyConnector() which then is wired through to ConfigDirPolicyLoader().

https://cs.chromium.org/chromium/src/chrome/test/base/testing_browser_process.cc?sq=package:chromium&dr&rcl=1469171820&l=151
Owner: pmarko@chromium.org
Status: Started (was: Assigned)
@Thiemo: I've looked into the idea of solving it by passing a different parameter in TestingBrowserProcess, but TestingBrowserProcess is not used in browser tests, so it would not solve the issue Lutz originally had.

My current proposal is to use PathService::Override to change directory, both for unit tests and browser tests / see https://codereview.chromium.org/2612733003/ .
Project Member

Comment 5 by bugdroid1@chromium.org, Jan 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6edddec42dae4c5797b642f59580a8c7024c1b6a

commit 6edddec42dae4c5797b642f59580a8c7024c1b6a
Author: pmarko <pmarko@chromium.org>
Date: Wed Jan 11 10:25:18 2017

Machine-local policy files should not affect tests

Override location of machine-local policy directory for both unit tests
and browser tests. This makes sure that any policy data the machine has
does not affect the test results.

BUG= 630614 

Review-Url: https://codereview.chromium.org/2612733003
Cr-Commit-Position: refs/heads/master@{#442852}

[modify] https://crrev.com/6edddec42dae4c5797b642f59580a8c7024c1b6a/chrome/test/base/test_launcher_utils.cc
[modify] https://crrev.com/6edddec42dae4c5797b642f59580a8c7024c1b6a/chrome/test/base/testing_browser_process.cc

Comment 6 by pmarko@chromium.org, Jan 11 2017

Incidentally, I've found the method policy::PolicyServiceIsEmpty in policy_test_utils.cc, which is used in three places like this:

ASSERT_TRUE(PolicyServiceIsEmpty(g_browser_process->policy_service()))
    << "Pre-existing policies in this machine will make this test fail.";

Pro leaving these in:
- there could still be pre-existing policies e.g. on Windows through Registry

Con leaving these in:
- to be consistent, that precondition should probably be in many tests
- we now ignore the usual machine-local policy directories on POSIX (-Mac) systems at least.

What do you think?

Comment 7 by pmarko@chromium.org, Jan 12 2017

Status: Fixed (was: Started)
Actually, there's probably no point in removing these - they don't hurt and effectively, the probability that these would be triggered has been reduced by implementing this, so I'd say let's leave those as they are.

If you disagree, please re-open the bug.

Sign in to add a comment