示例#1
0
    def inputFiles(self):
        input_files = []
        if not self.testCases:
            return input_files

        for test_class, test_methods in self.testCases:
            if test_class.inputFile:
                key = test_class.inputFile[0]
                filename = test_class.localOptions[key]
                if not filename:
                    continue
                input_file = {'key': key, 'test_class': test_class}
                m = self.onionInputRegex.match(filename)
                if m:
                    input_file['url'] = filename
                    input_file['address'] = m.group(1)
                    input_file['hash'] = m.group(2)
                else:
                    input_file['filename'] = filename
                    try:
                        with open(filename) as f:
                            h = sha256()
                            for l in f:
                                h.update(l)
                    except:
                        raise e.InvalidInputFile(filename)
                    input_file['hash'] = h.hexdigest()
                input_files.append(input_file)

        return input_files
示例#2
0
    def _accumulateInputFiles(self, test_class):
        if not test_class.inputFile:
            return

        key = test_class.inputFile[0]
        filename = self.localOptions[key]
        if not filename:
            return

        input_file = {
            'key': key,
            'test_options': self.localOptions,
            'hash': None,
            'url': None,
            'address': None,
            'filename': None
        }
        m = ONION_INPUT_REGEXP.match(filename)
        if m:
            input_file['url'] = filename
            input_file['address'] = m.group(1)
            input_file['hash'] = m.group(2)
        else:
            input_file['filename'] = filename
            try:
                with open(filename) as f:
                    h = sha256()
                    for l in f:
                        h.update(l)
            except:
                raise e.InvalidInputFile(filename)
            input_file['hash'] = h.hexdigest()
        self.inputFiles.append(input_file)
示例#3
0
    def _accumulateInputFiles(self, test_class):
        if not test_class.inputFile:
            return

        key = test_class.inputFile[0]
        filename = self.localOptions[key]
        if not filename:
            return

        input_file = {
            'key': key,
            'test_options': self.localOptions,
            'filename': None
        }
        m = ONION_INPUT_REGEXP.match(filename)
        if m:
            raise e.InvalidInputFile("Input files hosted on hidden services "
                                     "are no longer supported")
        else:
            input_file['filename'] = filename
        self.inputFiles.append(input_file)