def test_update_distributor_same_url(self): config = PluginCallConfiguration( dict(http=True, https=False, relative_url='bar'), {}) repo = Mock(repo_id='foo', working_dir=self.work_dir) conduit = self._config_conduit(False) self.assertEquals((True, None), configuration.validate_config(repo, config, conduit))
def test_server_url_fully_qualified(self): config = PluginCallConfiguration( dict(http=True, https=False, relative_url=None), {}) repo = Mock(repo_id='foo', working_dir=self.work_dir) conduit = self._config_conduit() self.assertEquals((True, None), configuration.validate_config(repo, config, conduit))
def test_create_distributor_same_url(self): config = PluginCallConfiguration( dict(http=True, https=False, relative_url='bar'), {}) repo = Mock(repo_id='fool', working_dir=self.work_dir) conduit = self._config_conduit(False) self.assertEquals((False, 'Relative URL [bar] for repository [fool] ' + 'conflicts with existing relative URL [/bar] ' + 'for repository [foo]'), configuration.validate_config(repo, config, conduit))
def test__repocfg_gpg_cmd(self): config = PluginCallConfiguration( dict(http=True, https=False, relative_url='fool'), dict(gpg_cmd="/bin/true should fail")) repo = Mock(repo_id='fool', working_dir=self.work_dir) conduit = self._config_conduit() expected_reason = ('Configuration key [gpg_cmd] is not allowed ' 'in repository plugin configuration') self.assertEquals((False, expected_reason), configuration.validate_config(repo, config, conduit))
def validate_config(self, repo, config, config_conduit): """ Allows the distributor to check the contents of a potential configuration for the given repository. This call is made both for the addition of this distributor to a new repository as well as updating the configuration for this distributor on a previously configured repository. The implementation should use the given repository data to ensure that updating the configuration does not put the repository into an inconsistent state. The return is a tuple of the result of the validation (True for success, False for failure) and a message. The message may be None and is unused in the success case. For a failed validation, the message will be communicated to the caller so the plugin should take i18n into consideration when generating the message. The related_repos parameter contains a list of other repositories that have a configured distributor of this type. The distributor configurations is found in each repository in the "plugin_configs" field. :param repo: metadata describing the repository to which the configuration applies :type repo: pulp.plugins.model.Repository :param config: plugin configuration instance; the proposed repo configuration is found within :type config: pulp.plugins.config.PluginCallConfiguration :param config_conduit: Configuration Conduit; :type config_conduit: pulp.plugins.conduits.repo_config.RepoConfigConduit :return: tuple of (bool, str) to describe the result :rtype: tuple :raises: PulpCodedValidationException if any validations failed """ return configuration.validate_config(config)
def test_server_url_fully_qualified(self): config = PluginCallConfiguration({}, {}) self.assertEquals((True, None), configuration.validate_config(config))