Exemplo n.º 1
0
def test_get_kmsauth_token(mocker, null_bless_cache):
    tokenmock = mocker.MagicMock()
    tokenmock.get_token.return_value = b'KMSTOKEN'
    genermock = mocker.patch('kmsauth.KMSTokenGenerator')
    genermock.return_value = tokenmock
    kmsconfig = {'awsregion': 'us-east-1', 'context': {}, 'kmskey': None}
    token = client.get_kmsauth_token(None, kmsconfig, 'foouser',
                                     null_bless_cache)
    assert token == 'KMSTOKEN'
Exemplo n.º 2
0
def test_get_kmsauth_token_cached():
    kmsconfig = {'awsregion': 'us-east-1', 'context': {}, 'kmskey': None}
    expiration = datetime.datetime.utcnow() + datetime.timedelta(minutes=60)
    kmsauth_cache = {
        'token': 'KMSTOKEN',
        'Expiration': expiration.strftime('%Y%m%dT%H%M%SZ')
    }
    bless_cache = BlessCache(None, None, BlessCache.CACHEMODE_ENABLED)
    bless_cache.cache = {}
    bless_cache.set('kmsauth-us-east-1', kmsauth_cache)
    token = client.get_kmsauth_token(None, kmsconfig, 'foouser', bless_cache)
    assert token == 'KMSTOKEN'