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
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)
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
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
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)