def test_prepare_host_s61(self): """Test the prepare host method for satellite 6.1.""" url1 = \ 'https://{sat_host}:{port}/katello/api' \ '/v2/organizations/{org_id}/systems/{host_id}' url2 = \ 'https://{sat_host}:{port}/katello/api' \ '/v2/organizations/{org_id}/systems/{host_id}/subscriptions' expected = [(self.scan_task, { 'job_id': self.scan_job.id, 'task_sequence_number': self.scan_task.sequence_number, 'scan_type': self.scan_task.scan_type, 'source_type': self.scan_task.source.source_type, 'source_name': self.scan_task.source.name }, 1, 'sys', url1, url2, { 'host': { 'id': 1, 'name': 'sys' }, 'port': '443', 'user': self.cred.username, 'password': self.cred.password, 'ssl_cert_verify': True })] host = {'id': 1, 'name': 'sys'} chunk = [host] port = '443' user = self.cred.username password = self.cred.password connect_data_return_value = host, port, user, password with patch('scanner.satellite.utils.get_connect_data', return_value=connect_data_return_value) as mock_connect: host_params = SatelliteSixV1.prepare_host(self.api, chunk) self.assertEqual(expected, host_params) mock_connect.assert_called_once_with(ANY)
def setUp(self): """Create test case setup.""" self.cred = Credential(name='cred1', cred_type=Credential.SATELLITE_CRED_TYPE, username='******', password='******', become_password=None, become_method=None, become_user=None, ssh_keyfile=None) self.cred.save() self.source = Source(name='source1', port=443, hosts='["1.2.3.4"]') self.source.save() self.source.credentials.add(self.cred) self.scan_job, self.scan_task = create_scan_job( self.source, ScanTask.SCAN_TYPE_INSPECT) self.api = SatelliteSixV1(self.scan_job, self.scan_task) connection_results = TaskConnectionResult() connection_results.save() self.api.connect_scan_task.connection_result = connection_results self.api.connect_scan_task.connection_result.save() sys_result = SystemConnectionResult( name='sys1_1', status=SystemInspectionResult.SUCCESS) sys_result.save() self.api.connect_scan_task.connection_result.systems.add(sys_result) self.api.connect_scan_task.connection_result.save() self.api.connect_scan_task.save()
def setUp(self): """Create test case setup.""" self.cred = Credential( name='cred1', cred_type=Credential.SATELLITE_CRED_TYPE, username='******', password='******', become_password=None, become_method=None, become_user=None, ssh_keyfile=None) self.cred.save() self.source = Source( name='source1', port=443, hosts='["1.2.3.4"]') self.source.save() self.source.credentials.add(self.cred) self.scan_job, self.scan_task = create_scan_job( self.source, ScanTask.SCAN_TYPE_INSPECT) self.api = SatelliteSixV1(self.scan_job, self.scan_task)
def create(satellite_version, api_version, scan_task): """Create the appropriate SatelliteInterface.""" if satellite_version is None: return None if satellite_version == SATELLITE_VERSION_5: return SatelliteFive(scan_task) if api_version == 1: return SatelliteSixV1(scan_task) if api_version == 2: return SatelliteSixV2(scan_task) return None
def create(satellite_version, api_version, scan_task, conn_result, inspect_result=None): """Create the appropriate SatelliteInterface.""" if satellite_version is None: return None if satellite_version == SourceOptions.SATELLITE_VERSION_5: return SatelliteFive(scan_task, conn_result, inspect_result) if api_version == 1: return SatelliteSixV1(scan_task, conn_result, inspect_result) if api_version == 2: return SatelliteSixV2(scan_task, conn_result, inspect_result) return None
def setUp(self): """Create test case setup.""" self.cred = Credential(name='cred1', cred_type=Credential.SATELLITE_CRED_TYPE, username='******', password='******', become_password=None, become_method=None, become_user=None, ssh_keyfile=None) self.cred.save() self.source = Source(name='source1', port=443, hosts='["1.2.3.4"]') self.source.save() self.source.credentials.add(self.cred) self.scan_task = ScanTask(scan_type=ScanTask.SCAN_TYPE_CONNECT, source=self.source, sequence_number=1, start_time=datetime.utcnow()) self.scan_task.save() self.scan_job = ScanJob(scan_type=ScanTask.SCAN_TYPE_CONNECT) self.scan_job.save() self.scan_job.tasks.add(self.scan_task) self.conn_results = JobConnectionResult() self.conn_results.save() self.scan_job.connection_results = self.conn_results self.scan_job.save() self.conn_result = TaskConnectionResult(scan_task=self.scan_task, source=self.source) self.conn_result.save() self.inspect_result = TaskInspectionResult(scan_task=self.scan_task, source=self.source) self.inspect_result.save() self.api = SatelliteSixV1(self.scan_task, self.conn_result, self.inspect_result)