Exemple #1
0
 def test_no_username(self):
     username = get_audit_username({
         'proxied_hostname': 'my host',
         'hostname': 'localhost',
         'ip': '123.456',
         'proxied_ip': '987'
     })
     self.assertIsNone(username)
Exemple #2
0
    def _get_paths(self, execution_id, predicate):
        config = self.config
        if is_empty(config.output_files):
            return []

        paths = [_extract_path(f) for f in config.output_files if predicate(f)]
        paths = [p for p in paths if p]

        parameter_values = self.execution_service.get_user_parameter_values(
            execution_id)
        all_audit_names = self.execution_service.get_all_audit_names(
            execution_id)

        audit_name = audit_utils.get_audit_name(all_audit_names)
        username = audit_utils.get_audit_username(all_audit_names)

        return substitute_variable_values(config.parameters, paths,
                                          parameter_values, audit_name,
                                          username)
Exemple #3
0
    def create_filename(self, execution_id, all_audit_names, script_name,
                        start_time):
        audit_name = get_audit_name(all_audit_names)
        audit_name = file_utils.to_filename(audit_name)

        date_string = ms_to_datetime(start_time).strftime(self._date_format)

        username = audit_utils.get_audit_username(all_audit_names)

        mapping = {
            'ID':
            execution_id,
            'USERNAME':
            username,
            'HOSTNAME':
            get_first_existing(all_audit_names,
                               audit_utils.PROXIED_HOSTNAME,
                               audit_utils.HOSTNAME,
                               default='unknown-host'),
            'IP':
            get_first_existing(all_audit_names, audit_utils.PROXIED_IP,
                               audit_utils.IP),
            'DATE':
            date_string,
            'AUDIT_NAME':
            audit_name,
            'SCRIPT':
            script_name
        }

        filename = self._filename_template.safe_substitute(mapping)
        if not filename.lower().endswith('.log'):
            filename += '.log'

        filename = filename.replace(" ", "_").replace("/", "_")

        return filename
Exemple #4
0
 def test_auth_username_and_proxied_username(self):
     username = get_audit_username({
         'proxied_username': '******',
         'auth_username': '******'
     })
     self.assertEqual('user_X', username)
Exemple #5
0
 def test_proxied_username(self):
     username = get_audit_username({
         'proxied_username': '******',
         'hostname': '123'
     })
     self.assertEqual('Its me', username)
Exemple #6
0
 def test_auth_username(self):
     username = get_audit_username({'auth_username': '******', 'ip': '123'})
     self.assertEqual('user_X', username)