def testDetectingEncryptedValues():
    nt.eq_(True, isEncryptedValue('ENC~(value)~'))
    nt.eq_(False, isEncryptedValue('testValue'))
    nt.eq_(False, isEncryptedValue('ENC(value)'))

    props = EzProperties({'theKey': 'ENC~(theValue)~'})
    props.setTextCryptoImplementer(NoOpTextCryptoImplementation())
    nt.eq_('theValue', props.getProperty('theKey', None))
def testEncryptingAndDecryptingProperties():
    encryptionPassword = '******'
    props = EzProperties()

    #unencrypted
    props.setTextCryptoImplementer(SharedSecretTextCryptoImplementation(encryptionPassword))
    props['key_1'] = 'GaurdiansOfTheGalaxy'
    nt.eq_('GaurdiansOfTheGalaxy', props.getProperty('key_1', None))
    props.setTextCryptoImplementer(NoOpTextCryptoImplementation())
    nt.eq_('GaurdiansOfTheGalaxy', props.getProperty('key_1', None))

    #encrypted
    props.setTextCryptoImplementer(SharedSecretTextCryptoImplementation(encryptionPassword))
    props.setProperty('key_2', 'AmazingSpiderman', True)
    nt.eq_('AmazingSpiderman', props.getProperty('key_2', None))
    props.setTextCryptoImplementer(NoOpTextCryptoImplementation())
    nt.eq_('q/+M4peluGo4QdHKr40J0uS9MeI2fYrF', props.getProperty('key_2', None))
    props.setTextCryptoImplementer(SharedSecretTextCryptoImplementation(encryptionPassword))
    nt.eq_('AmazingSpiderman', props.getProperty('key_2', None))