def test_compile_asks_for_password_if_none_given(ruleset_name, mocker, tempdir: tempfile.TemporaryDirectory):
    mocker.patch('deterministicpasswordgenerator.compile.getpass', side_effect=RequestedPasswordInput())

    mocker.patch('builtins.input', side_effect=Forbidden('Should use password-input mode for password'))

    with pytest.raises(RequestedPasswordInput):
        compile_ruleset(rulset_path(ruleset_name), output_path=tempdir.name)
Ejemplo n.º 2
0
def compile_folder_and_install_as_ruleset(rulebank_base_directory,
                                          ruleset_name):
    path_to_ruleset = os.path.abspath(
        os.path.join(os.path.dirname(__file__), ruleset_name))
    compile_ruleset(ruleset_path=path_to_ruleset,
                    ruleset_encryption_password='******',
                    output_path=rulebank_base_directory)
Ejemplo n.º 3
0
def test_compiled_ruleset_is_not_readable(
        ruleset_name, tempdir: tempfile.TemporaryDirectory):
    path_to_ruleset = rulset_path(ruleset_name)
    compile_ruleset(path_to_ruleset,
                    output_path=tempdir.name,
                    ruleset_encryption_password='******')
    with pytest.raises(zipfile.BadZipfile):
        zipfile.ZipFile(path.join(tempdir.name, ruleset_name + '.dpgr'))
Ejemplo n.º 4
0
def test_compiled_ruleset_can_be_read_by_parser(
        ruleset_name: str, tempdir: tempfile.TemporaryDirectory):
    path_to_ruleset = rulset_path(ruleset_name)
    assert path.isdir(path_to_ruleset)
    compile_ruleset(path_to_ruleset,
                    output_path=tempdir.name,
                    ruleset_encryption_password='******')
    rule_bank = load_rule_bank(directory=tempdir.name,
                               encryption_key='encryption-key')
    assert rule_bank.get_strategy(ruleset_name) is not None
Ejemplo n.º 5
0
def test_compile_asks_for_password_if_none_given(
        ruleset_name, mocker, tempdir: tempfile.TemporaryDirectory):
    mocker.patch('deterministicpasswordgenerator.compile.getpass',
                 side_effect=RequestedPasswordInput())

    mocker.patch(
        'builtins.input',
        side_effect=Forbidden('Should use password-input mode for password'))

    with pytest.raises(RequestedPasswordInput):
        compile_ruleset(rulset_path(ruleset_name), output_path=tempdir.name)
def test_compiled_rulesets_are_readonly(ruleset_name, tempdir: tempfile.TemporaryDirectory):
    path_to_ruleset = rulset_path(ruleset_name)
    compile_ruleset(path_to_ruleset, output_path=tempdir.name, ruleset_encryption_password='******')
    compiled_path = path.join(tempdir.name, ruleset_name + '.dpgr')
    stat_result = os.stat(compiled_path)
    assert stat.S_IRUSR == stat.S_IRUSR & stat_result.st_mode
    assert stat.S_IWUSR != stat.S_IWUSR & stat_result.st_mode
    assert stat.S_IRGRP != stat.S_IRGRP & stat_result.st_mode
    assert stat.S_IWGRP != stat.S_IWGRP & stat_result.st_mode
    assert stat.S_IWOTH != stat.S_IWOTH & stat_result.st_mode
    assert stat.S_IROTH != stat.S_IROTH & stat_result.st_mode
Ejemplo n.º 7
0
def test_compiled_rulesets_are_readonly(ruleset_name,
                                        tempdir: tempfile.TemporaryDirectory):
    path_to_ruleset = rulset_path(ruleset_name)
    compile_ruleset(path_to_ruleset,
                    output_path=tempdir.name,
                    ruleset_encryption_password='******')
    compiled_path = path.join(tempdir.name, ruleset_name + '.dpgr')
    stat_result = os.stat(compiled_path)
    assert stat.S_IRUSR == stat.S_IRUSR & stat_result.st_mode
    assert stat.S_IWUSR != stat.S_IWUSR & stat_result.st_mode
    assert stat.S_IRGRP != stat.S_IRGRP & stat_result.st_mode
    assert stat.S_IWGRP != stat.S_IWGRP & stat_result.st_mode
    assert stat.S_IWOTH != stat.S_IWOTH & stat_result.st_mode
    assert stat.S_IROTH != stat.S_IROTH & stat_result.st_mode
def compile_folder_and_install_as_ruleset(rulebank_base_directory, ruleset_name):
    path_to_ruleset = os.path.abspath(os.path.join(os.path.dirname(__file__), ruleset_name))
    compile_ruleset(
            ruleset_path=path_to_ruleset,
            ruleset_encryption_password='******',
            output_path=rulebank_base_directory)
def test_compiled_ruleset_is_not_readable(ruleset_name, tempdir: tempfile.TemporaryDirectory):
    path_to_ruleset = rulset_path(ruleset_name)
    compile_ruleset(path_to_ruleset, output_path=tempdir.name, ruleset_encryption_password='******')
    with pytest.raises(zipfile.BadZipfile):
        zipfile.ZipFile(path.join(tempdir.name, ruleset_name + '.dpgr'))
def test_compiled_ruleset_can_be_read_by_parser(ruleset_name: str, tempdir: tempfile.TemporaryDirectory):
    path_to_ruleset = rulset_path(ruleset_name)
    assert path.isdir(path_to_ruleset)
    compile_ruleset(path_to_ruleset, output_path=tempdir.name, ruleset_encryption_password='******')
    rule_bank = load_rule_bank(directory=tempdir.name, encryption_key='encryption-key')
    assert rule_bank.get_strategy(ruleset_name) is not None