def initialize(self):
     super(login_OwnershipTaken, self).initialize()
     policy.install_protobufs(self.autodir, self.job)
     ownership.restart_ui_to_clear_ownership_files()
     if (os.access(constants.OWNER_KEY_FILE, os.F_OK) or
             os.access(constants.SIGNED_POLICY_FILE, os.F_OK)):
         raise error.TestError('Ownership already taken!')
Beispiel #2
0
    def initialize(self):
        # Start with a clean slate wrt ownership
        ownership.restart_ui_to_clear_ownership_files()
        super(login_RemoteOwnership, self).initialize()
        policy.install_protobufs(self.autodir, self.job)

        bus_loop = DBusGMainLoop(set_as_default=True)
        self._cryptohome_proxy = cryptohome.CryptohomeProxy(
            bus_loop, self.autodir, self.job)
        self._sm = session_manager.connect(bus_loop)
Beispiel #3
0
    def initialize(self):
        super(login_GuestAndActualSession, self).initialize()
        policy.install_protobufs(self.autodir, self.job)
        # Ensure a clean beginning.
        ownership.restart_ui_to_clear_ownership_files()

        bus_loop = DBusGMainLoop(set_as_default=True)
        self._session_manager = session_manager.connect(bus_loop)
        self._listener = session_manager.OwnershipSignalListener(
            gobject.MainLoop())
        self._listener.listen_for_new_key_and_policy()
    def initialize(self):
        super(login_UserPolicyKeys, self).initialize()
        policy.install_protobufs(self.autodir, self.job)
        self._bus_loop = DBusGMainLoop(set_as_default=True)
        self._cryptohome_proxy = cryptohome.CryptohomeProxy(
            self._bus_loop, self.autodir, self.job)

        # Clear the user's vault, to make sure the test starts without any
        # policy or key lingering around. At this stage the session isn't
        # started and there's no user signed in.
        ownership.restart_ui_to_clear_ownership_files()
        self._cryptohome_proxy.remove(ownership.TESTUSER)
Beispiel #5
0
    def initialize(self):
        super(login_MultipleSessions, self).initialize()
        policy.install_protobufs(self.autodir, self.job)
        # Ensure a clean beginning.
        ownership.restart_ui_to_clear_ownership_files()

        self._bus_loop = DBusGMainLoop(set_as_default=True)
        self._session_manager = session_manager.connect(self._bus_loop)
        self._listener = session_manager.OwnershipSignalListener(
                gobject.MainLoop())
        self._listener.listen_for_new_key_and_policy()

        self._cryptohome_proxy = cryptohome.CryptohomeProxy(
            self._bus_loop, self.autodir, self.job)
    def initialize(self):
        super(login_OwnershipApi, self).initialize()
        policy.install_protobufs(self.autodir, self.job)
        self._bus_loop = DBusGMainLoop(set_as_default=True)

        # Clear existing ownership and inject known keys.
        cros_ui.stop()
        ownership.clear_ownership_files_no_restart()

        # Make device already owned by ownership.TESTUSER.
        cryptohome.mount_vault(ownership.TESTUSER,
                               ownership.TESTPASS,
                               create=True)
        ownership.use_known_ownerkeys(ownership.TESTUSER)

        self._tempdir = autotemp.tempdir(unique_id=self.__class__.__name__)
        cros_ui.start()
Beispiel #7
0
class EnterprisePolicyTest(arc.ArcTest, test.test):
    """Base class for Enterprise Policy Tests."""

    WEB_PORT = 8080
    WEB_HOST = 'http://localhost:%d' % WEB_PORT
    CHROME_POLICY_PAGE = 'chrome://policy'
    CHROME_VERSION_PAGE = 'chrome://version'

    def initialize(self, **kwargs):
        """
        Initialize test parameters.

        Consume the check_client_result parameter if this test was started
        from a server test.

        """
        self._initialize_enterprise_policy_test(**kwargs)

    def _initialize_enterprise_policy_test(self,
                                           case='',
                                           env='dm-fake',
                                           dms_name=None,
                                           username=USERNAME,
                                           password=PASSWORD,
                                           gaia_id=GAIA_ID,
                                           set_auto_logout=None,
                                           **kwargs):
        """
        Initialize test parameters and fake DM Server.

        This function exists so that ARC++ tests (which inherit from the
        ArcTest class) can also initialize a policy setup.

        @param case: String name of the test case to run.
        @param env: String environment of DMS and Gaia servers.
        @param username: String user name login credential.
        @param password: String password login credential.
        @param gaia_id: String gaia_id login credential.
        @param dms_name: String name of test DM Server.
        @param kwargs: Not used.

        """
        self.case = case
        self.env = env
        self.username = username
        self.password = password
        self.gaia_id = gaia_id
        self.set_auto_logout = set_auto_logout
        self.dms_name = dms_name
        self.dms_is_fake = (env == 'dm-fake')
        self.arc_enabled = False
        self.version = None
        self._enforce_variable_restrictions()

        # Install protobufs and add import path.
        policy.install_protobufs(self.autodir, self.job)

        # Initialize later variables to prevent error after an early failure.
        self._web_server = None
        self.cr = None

        # Start AutoTest DM Server if using local fake server.
        if self.dms_is_fake:
            self.fake_dm_server = enterprise_fake_dmserver.FakeDMServer()
            self.fake_dm_server.start(self.tmpdir, self.debugdir)

        # Get enterprise directory of shared resources.
        client_dir = os.path.dirname(os.path.dirname(self.bindir))
        self.enterprise_dir = os.path.join(client_dir, 'cros/enterprise')

        if self.set_auto_logout is not None:
            self._auto_logout = self.set_auto_logout

        # Log the test context parameters.
        logging.info('Test Context Parameters:')
        logging.info('  Case: %r', self.case)
        logging.info('  Environment: %r', self.env)
        logging.info('  Username: %r', self.username)
        logging.info('  Password: %r', self.password)
        logging.info('  Test DMS Name: %r', self.dms_name)