def test_validate_calls_correct_helpers(self, _validate_required_bool,
                                            _validate_ssl_cert):
        """
        Test that validate() uses all the right helpers.
        """
        config = get_basic_config(**{
            constants.CONFIG_SERVE_HTTP: True,
            constants.CONFIG_SERVE_HTTPS: False
        })

        valid, msg = configuration.validate(config)

        # Assert the return values
        self.assertEqual(valid, True)
        self.assertEqual(msg, None)

        # Assert that _validate_required_bool was called twice with the correct parameters
        self.assertEqual(_validate_required_bool.call_count, 2)
        self.assertEqual(_validate_required_bool.mock_calls[0][1][0], config)
        self.assertEqual(_validate_required_bool.mock_calls[0][1][1],
                         constants.CONFIG_SERVE_HTTP)
        self.assertEqual(_validate_required_bool.mock_calls[1][1][0], config)
        self.assertEqual(_validate_required_bool.mock_calls[1][1][1],
                         constants.CONFIG_SERVE_HTTPS)

        # Assert that _validate_ssl_cert was called once with the right parameters
        _validate_ssl_cert.assert_called_once_with(
            config, constants.CONFIG_SSL_AUTH_CA_CERT)
    def test_validate_passes(self):
        """
        Test that validate() handles a good config correctly.
        """
        config = get_basic_config(**{constants.CONFIG_SERVE_HTTP: True, constants.CONFIG_SERVE_HTTPS: False})

        valid, msg = configuration.validate(config)

        # We passed a valid config, so validate() should have indicated that everything was cool
        self.assertTrue(valid)
        self.assertEqual(msg, None)
    def test_validate_fails(self):
        """
        Test that validate() handles a bad config correctly.
        """
        config = get_basic_config(**{constants.CONFIG_SERVE_HTTP: True, constants.CONFIG_SERVE_HTTPS: False,
                                     constants.CONFIG_SSL_AUTH_CA_CERT: 'Invalid cert.'})

        valid, msg = configuration.validate(config)

        # We passed a valid config, so validate() should have indicated that everything was cool
        self.assertFalse(valid)
        self.assertEqual(msg, 'The SSL certificate <ssl_auth_ca_cert> is not a valid certificate.')
    def test_validate_passes(self):
        """
        Test that validate() handles a good config correctly.
        """
        config = get_basic_config(**{
            constants.CONFIG_SERVE_HTTP: True,
            constants.CONFIG_SERVE_HTTPS: False
        })

        valid, msg = configuration.validate(config)

        # We passed a valid config, so validate() should have indicated that everything was cool
        self.assertTrue(valid)
        self.assertEqual(msg, None)
    def test_validate_fails(self):
        """
        Test that validate() handles a bad config correctly.
        """
        config = get_basic_config(
            **{
                constants.CONFIG_SERVE_HTTP: True,
                constants.CONFIG_SERVE_HTTPS: False,
                constants.CONFIG_SSL_AUTH_CA_CERT: 'Invalid cert.'
            })

        valid, msg = configuration.validate(config)

        # We passed a valid config, so validate() should have indicated that everything was cool
        self.assertFalse(valid)
        self.assertEqual(
            msg,
            'The SSL certificate <ssl_auth_ca_cert> is not a valid certificate.'
        )
    def test_validate_calls_correct_helpers(self, _validate_required_bool, _validate_ssl_cert):
        """
        Test that validate() uses all the right helpers.
        """
        config = get_basic_config(**{constants.CONFIG_SERVE_HTTP: True, constants.CONFIG_SERVE_HTTPS: False})

        valid, msg = configuration.validate(config)

        # Assert the return values
        self.assertEqual(valid, True)
        self.assertEqual(msg, None)

        # Assert that _validate_required_bool was called twice with the correct parameters
        self.assertEqual(_validate_required_bool.call_count, 2)
        self.assertEqual(_validate_required_bool.mock_calls[0][1][0], config)
        self.assertEqual(_validate_required_bool.mock_calls[0][1][1], constants.CONFIG_SERVE_HTTP)
        self.assertEqual(_validate_required_bool.mock_calls[1][1][0], config)
        self.assertEqual(_validate_required_bool.mock_calls[1][1][1], constants.CONFIG_SERVE_HTTPS)

        # Assert that _validate_ssl_cert was called once with the right parameters
        _validate_ssl_cert.assert_called_once_with(config, constants.CONFIG_SSL_AUTH_CA_CERT)
Пример #7
0
 def validate_config(self, repo, config, config_conduit):
     return configuration.validate(config, repo.repo_obj, config_conduit)
Пример #8
0
 def validate_config(self, repo, config, config_conduit):
     return configuration.validate(config)
Пример #9
0
 def validate_config(self, repo, config, related_repos):
     return configuration.validate(config)