Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: client/site_tests/security_BundledCRXs/security_BundledCRXs.py

Issue 6606023: Remove security_BundledCRXs test. Superceded by security_BundledCRXPermissions rewrite. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import logging
6 import os
7
8 from autotest_lib.client.bin import test, utils
9 from autotest_lib.client.common_lib import error
10
11 class security_BundledCRXs(test.test):
12 version = 1
13 _CRX_DIR = '/opt/google/chrome/extensions/'
14
15
16 def load_baseline(self):
17 """
18 Return a list of crx's we expect, e.g.
19 ['aciahcmjmecflokailenpkdchphgkefd.crx',
20 'blpcfgokakmgnkcojhhkbfbldkacnbeo.crx', ...]
21 """
22 # Figure out path to baseline file, by looking up our own path
23 bpath = os.path.abspath(__file__)
24 bpath = os.path.join(os.path.dirname(bpath), 'baseline')
25 bfile = open(bpath)
26 baseline_data = bfile.read()
27 baseline_set = set(baseline_data.splitlines())
28 bfile.close()
29 return baseline_set
30
31
32 def fetch_bundled_crxs(self):
33 """
34 Return a list of crx's found bundled on the system.
35 (The data returned is comparable to that of load_baseline().)
36 """
37 cmd = "find '%s' -xdev -name '*.crx' -printf '%%f\\n'"
38 return set(utils.system_output(cmd % self._CRX_DIR).splitlines())
39
40
41 def run_once(self):
42 """
43 Enumerate all the bundled CRXs.
44 Fail if it does not match the expected set.
45 """
46 observed_set = self.fetch_bundled_crxs()
47 baseline_set = self.load_baseline()
48
49 # If something in the observed set is not
50 # covered by the baseline...
51 diff = observed_set.difference(baseline_set)
52 if len(diff) > 0:
53 for crx in diff:
54 logging.error('New/unexpected bundled crx %s' % crx)
55
56 # Or, things in baseline are missing from the system:
57 diff2 = baseline_set.difference(observed_set)
58 if len(diff2) > 0:
59 for crx in diff2:
60 logging.error('Missing bundled crx %s' % crx)
61
62 if (len(diff) + len(diff2)) > 0:
63 raise error.TestFail('Baseline mismatch')
OLDNEW
« no previous file with comments | « client/site_tests/security_BundledCRXs/control ('k') | server/site_tests/suites/control.security » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698