Example #1
0
    def test_create_consumer_payload(self):
        local_distributor = YumHTTPDistributor()
        repo = Mock()
        repo.display_name = 'foo'
        repo.id = 'bar'
        config = {'https_ca': 'pear',
                  'gpgkey': 'kiwi',
                  'auth_cert': 'durian',
                  'auth_ca': True,
                  'http': True,
                  'https': True}
        binding_config = {}
        pulp_server_config.set('server', 'server_name', 'apple')
        cert_file = os.path.join(self.working_dir, "orange_file")
        with open(cert_file, 'w') as filewriter:
            filewriter.write("orange")

        pulp_server_config.set('security', 'ssl_ca_certificate', cert_file)

        result = local_distributor.create_consumer_payload(repo, config, binding_config)

        target = {
            'server_name': 'apple',
            'ca_cert': 'orange',
            'relative_path': '/pulp/repos/bar',
            'gpg_keys': {'pulp.key': 'kiwi'},
            'client_cert': 'durian',
            'protocols': ['http', 'https'],
            'repo_name': 'foo'
        }
        compare_dict(result, target)
Example #2
0
    def test_create_consumer_payload_global_auth(self, mock_load_config):
        test_distributor = YumHTTPDistributor()
        repo = Mock()
        repo.display_name = 'foo'
        repo.id = 'bar'
        config = {
            'https_ca': 'pear',
            'gpgkey': 'kiwi',
            'http': True,
            'https': True
        }
        binding_config = {}
        pulp_server_config.set('server', 'server_name', 'apple')
        pulp_server_config.set('security', 'ssl_ca_certificate', 'orange')

        repo_auth_config = ConfigParser.SafeConfigParser()
        repo_auth_config.add_section('repos')
        repo_auth_config.set('repos', 'global_cert_location', self.working_dir)
        mock_load_config.return_value = repo_auth_config

        with open(os.path.join(self.working_dir, 'pulp-global-repo.cert'),
                  'w+') as cert_file:
            cert_file.write('cert')
        with open(os.path.join(self.working_dir, 'pulp-global-repo.key'),
                  'w+') as cert_file:
            cert_file.write('key')
        with open(os.path.join(self.working_dir, 'pulp-global-repo.ca'),
                  'w+') as cert_file:
            cert_file.write('ca')

        result = test_distributor.create_consumer_payload(
            repo, config, binding_config)

        target = {
            'server_name': 'apple',
            'ca_cert': 'pear',
            'relative_path': '/pulp/repos/bar',
            'gpg_keys': {
                'pulp.key': 'kiwi'
            },
            'protocols': ['http', 'https'],
            'repo_name': 'foo',
            'client_cert': None,
            'global_auth_cert': 'cert',
            'global_auth_key': 'key',
            'global_auth_ca': 'ca'
        }
        compare_dict(result, target)
Example #3
0
    def test_create_consumer_payload_global_auth(self, mock_load_config):
        test_distributor = YumHTTPDistributor()
        repo = Mock()
        repo.display_name = 'foo'
        repo.id = 'bar'
        config = {'https_ca': 'pear',
                  'gpgkey': 'kiwi',
                  'http': True,
                  'https': True}
        binding_config = {}
        pulp_server_config.set('server', 'server_name', 'apple')
        pulp_server_config.set('security', 'ssl_ca_certificate', 'orange')

        repo_auth_config = ConfigParser.SafeConfigParser()
        repo_auth_config.add_section('repos')
        repo_auth_config.set('repos', 'global_cert_location', self.working_dir)
        mock_load_config.return_value = repo_auth_config

        with open(os.path.join(self.working_dir, 'pulp-global-repo.cert'), 'w+') as cert_file:
            cert_file.write('cert')
        with open(os.path.join(self.working_dir, 'pulp-global-repo.key'), 'w+') as cert_file:
            cert_file.write('key')
        with open(os.path.join(self.working_dir, 'pulp-global-repo.ca'), 'w+') as cert_file:
            cert_file.write('ca')

        result = test_distributor.create_consumer_payload(repo, config, binding_config)

        target = {
            'server_name': 'apple',
            'ca_cert': 'pear',
            'relative_path': '/pulp/repos/bar',
            'gpg_keys': {'pulp.key': 'kiwi'},
            'protocols': ['http', 'https'],
            'repo_name': 'foo',
            'client_cert': None,
            'global_auth_cert': 'cert',
            'global_auth_key': 'key',
            'global_auth_ca': 'ca'
        }
        compare_dict(result, target)
Example #4
0
    def test_create_consumer_payload(self):
        local_distributor = YumHTTPDistributor()
        repo = Mock()
        repo.display_name = 'foo'
        repo.id = 'bar'
        config = {
            'https_ca': 'pear',
            'gpgkey': 'kiwi',
            'auth_cert': 'durian',
            'auth_ca': True,
            'http': True,
            'https': True
        }
        binding_config = {}
        pulp_server_config.set('server', 'server_name', 'apple')
        cert_file = os.path.join(self.working_dir, "orange_file")
        with open(cert_file, 'w') as filewriter:
            filewriter.write("orange")

        pulp_server_config.set('security', 'ssl_ca_certificate', cert_file)

        result = local_distributor.create_consumer_payload(
            repo, config, binding_config)

        target = {
            'server_name': 'apple',
            'ca_cert': 'orange',
            'relative_path': '/pulp/repos/bar',
            'gpg_keys': {
                'pulp.key': 'kiwi'
            },
            'client_cert': 'durian',
            'protocols': ['http', 'https'],
            'repo_name': 'foo'
        }
        compare_dict(result, target)