Пример #1
0
 def test_invalid_default_valid_override_repo_registry_id(self):
     config = PluginCallConfiguration(
         {constants.CONFIG_KEY_REPO_REGISTRY_ID: 'valid'}, {})
     repo = Mock(id='ValidRepoInvalidRegistry')
     try:
         configuration.validate_config(config, repo)
     except Exception, e:
         self.fail(
             'validate_config unexpectedly raised: {exception}'.format(
                 exception=type(e)))
Пример #2
0
 def test_invalid_default_valid_override_repo_registry_id(self):
     config = PluginCallConfiguration({
         constants.CONFIG_KEY_REPO_REGISTRY_ID: 'valid'
     }, {})
     repo = Mock(id='ValidRepoInvalidRegistry')
     try:
         configuration.validate_config(config, repo)
     except Exception, e:
         self.fail(
             'validate_config unexpectedly raised: {exception}'.format(exception=type(e))
         )
Пример #3
0
    def test_server_url_empty(self):
        config = {
            constants.CONFIG_KEY_REDIRECT_URL: ''
        }
        # This is valid as the default server should be used

        self.assertEquals((True, None), configuration.validate_config(config))
Пример #4
0
 def test_server_url_empty(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL: ''
     }
     repo = Mock(id='mylifegotflipturned')
     # This is valid as the default server should be used
     self.assertEquals((True, None), configuration.validate_config(config, repo))
Пример #5
0
    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
        """
        return configuration.validate_config(config)
Пример #6
0
 def test_server_url_fully_qualified(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL: 'http://www.pulpproject.org/foo'
     }
     repo = Mock(id='nowthisisastory')
     self.assertEquals((True, None),
                       configuration.validate_config(config, repo))
Пример #7
0
    def validate_config(self, repo_transfer, 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_transfer: metadata describing the repository to which the
                     configuration applies
        :type  repo_transfer: 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
        """
        repo = model.Repository.objects.get_repo_or_missing_resource(repo_id=repo_transfer.id)
        return configuration.validate_config(config, repo)
Пример #8
0
 def test_server_url_fully_qualified_with_port(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL:
         'http://www.pulpproject.org:440/foo'
     }
     repo = Mock(id='allabouthow')
     self.assertEquals((True, None),
                       configuration.validate_config(config, repo))
Пример #9
0
 def test_repo_regisrty_id_with_slash(self):
     """
     We need to allow a single slash in this field to allow namespacing.
     """
     config = PluginCallConfiguration(
         {constants.CONFIG_KEY_REPO_REGISTRY_ID: 'slashes/ok'}, {})
     repo = Mock(id='repoid')
     self.assertEquals((True, None),
                       configuration.validate_config(config, repo))
Пример #10
0
 def test_repo_regisrty_id_with_slash(self):
     """
     We need to allow a single slash in this field to allow namespacing.
     """
     config = PluginCallConfiguration({
         constants.CONFIG_KEY_REPO_REGISTRY_ID: 'slashes/ok'
     }, {})
     repo = Mock(id='repoid')
     self.assertEquals((True, None), configuration.validate_config(config, repo))
Пример #11
0
 def test_configuration_protected_false_str(self):
     config = PluginCallConfiguration(
         {constants.CONFIG_KEY_PROTECTED: 'false'}, {})
     repo = Mock(id='illtellyouhowibecametheprince')
     self.assertEquals((True, None),
                       configuration.validate_config(config, repo))
Пример #12
0
 def test_configuration_protected_true(self):
     config = PluginCallConfiguration(
         {constants.CONFIG_KEY_PROTECTED: True}, {})
     repo = Mock(id='justsitrightthere')
     self.assertEquals((True, None),
                       configuration.validate_config(config, repo))
Пример #13
0
    def test_configuration_protected_false_str(self):
        config = PluginCallConfiguration(
            {constants.CONFIG_KEY_PROTECTED: 'false'}, {})

        self.assertEquals((True, None), configuration.validate_config(config))
Пример #14
0
 def test_configuration_protected_false_str(self):
     config = PluginCallConfiguration({
         constants.CONFIG_KEY_PROTECTED: 'false'
     }, {})
     repo = Mock(id='illtellyouhowibecametheprince')
     self.assertEquals((True, None), configuration.validate_config(config, repo))
Пример #15
0
    def test_server_url_empty(self):
        config = {constants.CONFIG_KEY_REDIRECT_URL: ''}
        # This is valid as the default server should be used

        self.assertEquals((True, None), configuration.validate_config(config))
Пример #16
0
 def test_server_url_fully_qualified_with_port(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL: 'http://www.pulpproject.org:440/foo'
     }
     repo = Mock(id='allabouthow')
     self.assertEquals((True, None), configuration.validate_config(config, repo))
Пример #17
0
 def test_server_url_fully_qualified(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL: 'http://www.pulpproject.org/foo'
     }
     repo = Mock(id='nowthisisastory')
     self.assertEquals((True, None), configuration.validate_config(config, repo))
Пример #18
0
 def test_server_url_fully_qualified(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL: 'http://www.pulpproject.org/foo'
     }
     self.assertEquals((True, None), configuration.validate_config(config))
Пример #19
0
    def test_configuration_protected_false_str(self):
        config = PluginCallConfiguration({
            constants.CONFIG_KEY_PROTECTED: 'false'
        }, {})

        self.assertEquals((True, None), configuration.validate_config(config))
Пример #20
0
 def test_configuration_protected_true(self):
     config = PluginCallConfiguration({
         constants.CONFIG_KEY_PROTECTED: True
     }, {})
     repo = Mock(id='justsitrightthere')
     self.assertEquals((True, None), configuration.validate_config(config, repo))
Пример #21
0
 def test_server_url_fully_qualified(self):
     config = {
         constants.CONFIG_KEY_REDIRECT_URL: 'http://www.pulpproject.org/foo'
     }
     self.assertEquals((True, None), configuration.validate_config(config))