Ejemplo n.º 1
0
def test__cryptoggle():
    poofConf = _config(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)
    cloneConf = _cconfig(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)

    assert _cryptoggle(poofConf, cloneConf, confFiles = TEST_POOF_CONF_FILES) == PoofStatus.ENCRYPTION_DISABLED

    cloneConf['poof-crypt'] = { 'type': 'crypt', 'remote': 'poof-backup', }
    assert _cryptoggle(poofConf, cloneConf, confFiles = TEST_POOF_CONF_FILES) == PoofStatus.ENCRYPTION_ENABLED
    assert _cryptoggle(poofConf, cloneConf, confFiles = TEST_POOF_CONF_FILES) == PoofStatus.ENCRYPTION_DISABLED
Ejemplo n.º 2
0
def test__verify():
    bogusCloningProgram = 'bogusxxxxx1213'
    _nukeTestConfigDir()

    assert _verify(component = bogusCloningProgram, confFiles = TEST_POOF_CONF_FILES) == (bogusCloningProgram, PoofStatus.MISSING_CLONING_PROGRAM)
    assert _verify(component = RCLONE_PROG_TEST, confFiles = TEST_POOF_CONF_FILES, allComponents = False) == (None, PoofStatus.OK)
    assert _verify(component = RCLONE_PROG_TEST, confFiles = TEST_POOF_CONF_FILES) == ('poof.conf', PoofStatus.MISSING_CONFIG_FILE)
    poofConf = _config(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR) 
    assert _verify(component = RCLONE_PROG_TEST, confFiles = TEST_POOF_CONF_FILES) == ('rclone-poof.conf', PoofStatus.MISSING_CONFIG_FILE)
    _cconfig(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)

    assert len(poofConf['paths']) == 1 # Only for testing - one entry, itself

    poofConf['paths']['/tmp'] = 'tmp'
    with open(TEST_POOF_CONF_FILES['poof.conf'], 'w') as outputFile:
        json.dump(poofConf, outputFile)

    assert _verify(component = RCLONE_PROG_TEST, confFiles = TEST_POOF_CONF_FILES) == (TEST_POOF_CONF_FILES['rclone-poof.conf'], PoofStatus.WARN_MISCONFIGURED)
Ejemplo n.º 3
0
def test__cconfig():
    conf = _cconfig(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)

    assert conf.get('poof-backup', 'type') == TEST_CLOUD_TYPE

    confStrSource = open(TEST_POOF_CONF_FILES['rclone-poof.conf'], 'r').read()

    try:
        confStrTarget = pyperclip.paste()
        assert confStrSource == confStrTarget
    except PyperclipException:
        pass # Linux
Ejemplo n.º 4
0
def test__verifyBogusValuesIn():
    component    = RCLONE_PROG_TEST
    conf         = _cconfig(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)
    section      = 'poof-backup'
    bogusSecrets = copy.deepcopy(_S3_BOGUS_SECRETS)
    assert _verifyBogusValuesIn(component, conf, section, bogusSecrets) == PoofStatus.WARN_MISCONFIGURED

    bogusSecrets['secret_access_key'] = 'bogus-access-key-not-default'
    assert _verifyBogusValuesIn(component, conf, section, bogusSecrets) == PoofStatus.OK

    bogusSecrets = copy.deepcopy(_CRYPT_BOGUS_SECRETS)
    section      = 'poof-backup'
    assert _verifyBogusValuesIn(component, conf, section, bogusSecrets) == PoofStatus.ERROR_MISSING_KEY
Ejemplo n.º 5
0
def test__encryptionIsEnabled():
    poofConf = _config(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)
    cloneConf = _cconfig(TEST_POOF_CONF_FILES, TEST_POOF_CONF_DIR)

    assert not _encryptionIsEnabled(poofConf, cloneConf)

    cloneConf['poof-crypt'] = {
        'type': 'crypt',
        'remote': 'bogus-remote',
        'password': '******',
        'password2': 'bogus-password2-not-default',
    }

    poofConf['remote'] = 'poof-crypt'

    assert _encryptionIsEnabled(poofConf, cloneConf)