Esempio n. 1
0
    def setUp(self):
        super(TestSSOClaims, self).setUp()

        config_folder = sgtk.util.ShotgunPath.from_current_os_path(
            os.path.join(self.tank_temp, str(uuid.uuid4())))

        self._configuration = CachedConfiguration(
            config_folder, self.mockgun,
            sgtk.descriptor.create_descriptor(
                self.mockgun, sgtk.descriptor.Descriptor.CONFIG,
                "sgtk:descriptor:path?path={0}".format(self.fixtures_root)),
            self.project["id"], "basic.dcc", None, [])

        self._mock_return_value(
            "tank.pipelineconfig_utils.get_core_python_path_for_config",
            return_value=os.path.join(REPO_ROOT, "python"))

        # Do not waste time copying files around or core swapping. Also, deactivate
        # thread startup and shutdown, we only want to ensure they are invoked.
        for mocked_method in [
                "tank.bootstrap.import_handler.CoreImportHandler.swap_core",
                "tank.bootstrap.configuration_writer.ConfigurationWriter.install_core",
                "tank.bootstrap.configuration_writer.ConfigurationWriter.create_tank_command",
        ]:
            self._mock_return_value(mocked_method, return_value=None)

        self._start_claims_mock = self._mock_return_value(
            "tank.authentication.user.ShotgunSamlUser.start_claims_renewal",
            return_value=None)
        self._stop_claims_mock = self._mock_return_value(
            "tank.authentication.user.ShotgunSamlUser.stop_claims_renewal",
            return_value=None)
Esempio n. 2
0
    def test_verifies_tank_name(self):
        """
        Ensures that missing tank name on project is detected when using roots.
        """

        # Reset the tank_name and create a storage named after the one in the config.
        self.mockgun.update("Project", self.project["id"], {"tank_name": None})
        self.mockgun.create("LocalStorage", {"code": "primary"})

        # Initialize a cached configuration pointing to the config.
        config_root = os.path.join(self.fixtures_root, "bootstrap_tests", "config")
        cached_config = CachedConfiguration(
            self.tank_temp,
            self.mockgun,
            sgtk.descriptor.create_descriptor(
                self.mockgun,
                sgtk.descriptor.Descriptor.CONFIG,
                "sgtk:descriptor:path?path={0}".format(config_root)
            ),
            self.project["id"],
            "basic.*",
            None,
            []
        )

        # Make sure that the missing tank name is detected.
        with self.assertRaises(sgtk.bootstrap.TankMissingTankNameError):
            cached_config.verify_required_shotgun_fields()

        # Ensure our change is backwards compatible.
        with self.assertRaises(sgtk.bootstrap.TankBootstrapError):
            cached_config.verify_required_shotgun_fields()
Esempio n. 3
0
    def setUp(self):
        super(TestCachedConfiguration, self).setUp()

        # Reset the tank_name and create a storage named after the one in the config.
        self.mockgun.update("Project", self.project["id"], {"tank_name": None})
        self.mockgun.create("LocalStorage", {"code": "primary"})

        # Initialize a cached configuration pointing to the config.
        config_root = os.path.join(self.fixtures_root, "bootstrap_tests", "config")

        self._temp_config_root = os.path.join(self.tank_temp, self.short_test_name)
        self._cached_config = CachedConfiguration(
            sgtk.util.ShotgunPath.from_current_os_path(self._temp_config_root),
            self.mockgun,
            sgtk.descriptor.create_descriptor(
                self.mockgun,
                sgtk.descriptor.Descriptor.CONFIG,
                "sgtk:descriptor:path?path={0}".format(config_root)
            ),
            self.project["id"],
            "basic.*",
            None,
            []
        )

        # Due to this being a test that runs offline, we can't use anything other than a
        # path descriptor, which means that it is mutable. Because LOCAL_CFG_DIFFERENT
        # is actually returned by three different code paths, the only way to ensure that
        # we are indeed in the up to date state, which means everything is ready to do, is
        # to cheat and make the descriptor immutable by monkey-patching it.
        self._cached_config._descriptor.is_immutable = lambda: True
        # Seems up the test tremendously since installing core becomes a noop.
        self._cached_config._config_writer.install_core = lambda _: None
        self._cached_config._config_writer.create_tank_command = lambda: None