コード例 #1
0
def test_redact_everything():
    test_words = 'The quick brown fox jumped lazily over the fence.'
    test_string = 'The quick brown fox jumped lazily over the fence.'
    expected = 'XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX.'

    res = redactor.redact(test_words, test_string)

    assert res == expected
コード例 #2
0
def test_space_then_comma():
    test_words = 'fox ,lazily ,fence'  # Spaces and then commas between the words
    test_string = 'The quick brown fox jumped lazily over the fence.'
    expected = 'The quick brown XXXXXXXX jumped XXXXXXXX over the XXXXXXXX.'

    res = redactor.redact(test_words, test_string)

    assert res == expected
コード例 #3
0
def test_simple_redact():
    test_words = 'fox, lazily, fence'
    test_string = 'The quick brown fox jumped lazily over the fence.'
    expected = 'The quick brown XXXXXXXX jumped XXXXXXXX over the XXXXXXXX.'

    res = redactor.redact(test_words, test_string)

    assert res == expected
コード例 #4
0
def test_spaces_only():
    test_words = 'fox lazily fence'  # NO commas between the words
    test_string = 'The quick brown fox jumped lazily over the fence.'
    expected = 'The quick brown XXXXXXXX jumped XXXXXXXX over the XXXXXXXX.'

    res = redactor.redact(test_words, test_string)

    assert res == expected
コード例 #5
0
def test_no_redactions():
    test_words = 'python, apples, firefox'
    test_string = 'The quick brown fox jumped lazily over the fence.'
    expected = 'The quick brown fox jumped lazily over the fence.'

    res = redactor.redact(test_words, test_string)

    assert res == expected
コード例 #6
0
def index():
    if request.method == 'GET':
        return render_template("index.html")
    elif request.method == 'POST':
        inFile = request.files['secretFile']
        if inFile.filename == '':
            abort(404, 'No File provided')

        inFile = inFile.read().decode('UTF-8')

        words = request.form['sensitiveWords']
        if words == '':
            abort(404, 'No words provided to redact.')

        redactedText = redactor.redact(words, inFile)
        FileOps = FileOperations.FileOperations()
        FileOps.save_redacted(redactedText)

        return render_template("results.html",
                               original=inFile,
                               redacted=redactedText,
                               filename=FileOps.out_file)