@pytest.mark.parametrize('encrypt', [True, False])
def test_secret(db, config, encrypt):
 config['ENCRYPT_SECRETS'] = encrypt
 bytes_secret = '\xff\x00\xf1'
 unicode_secret = u'foo\xa0'
 secret = Secret()
 secret.type = 'password'
 secret.secret = bytes_secret
 db.session.add(secret)
 db.session.commit()
 secret = db.session.query(Secret).get(secret.id)
 if encrypt:
  assert (secret._secret != bytes_secret), 'secret is not encrypted'
 else:
  assert (secret._secret == bytes_secret)
 assert (secret.secret == bytes_secret), 'secret not decrypted correctly'
 with pytest.raises(TypeError) as e:
  secret.secret = unicode_secret
 assert (e.typename == 'TypeError'), 'secret cannot be unicode'

@ pytest . mark . parametrize ( 'encrypt' , [ True , False ] ) def test_secret ( db , config , encrypt ) : config [ 'ENCRYPT_SECRETS' ] = encrypt bytes_secret = '\xff\x00\xf1' unicode_secret = u'foo\xa0' secret = Secret ( ) secret . type = 'password' secret . secret = bytes_secret db . session . add ( secret ) db . session . commit ( ) secret = db . session . query ( Secret ) . get ( secret . id ) if encrypt : assert ( secret . _secret != bytes_secret ) , 'secret is not encrypted' else : assert ( secret . _secret == bytes_secret ) assert ( secret . secret == bytes_secret ) , 'secret not decrypted correctly' with pytest . raises ( TypeError ) as e : secret . secret = unicode_secret assert ( e . typename == 'TypeError' ) , 'secret cannot be unicode'
if encryption is enabled .