Exemple #1
0
async def test_check_domain():
    auth = SimpleAuthenticator()
    auth.valid_signature_override = True
    ts = int(datetime.now().strftime('%s'))
    platform_token = await auth.authenticate_platform('testing.foobar.com', ts, 'anything')
    domain = await auth.valid_platform_token(platform_token)
    await auth.check_domain_platform('foobar.com', domain)
Exemple #2
0
async def test_check_domain_missing():
    auth = SimpleAuthenticator()
    auth.valid_signature_override = True
    ts = int(datetime.now().strftime('%s'))
    platform_token = await auth.authenticate_platform('testing.foobar.com', ts, 'anything')
    token = await auth.valid_platform_token(platform_token)
    with pytest.raises(DomainPlatformMismatch) as excinfo:
        await auth.check_domain_platform('bang.com', token)
    assert excinfo.value.args[0] == '"bang.com" does not use "testing.foobar.com"'
Exemple #3
0
async def test_key_does_exists():
    auth = SimpleAuthenticator()
    auth.valid_signature_override = True

    # note: strftime('%s') has to be used with now() to avoid double tz conversion
    n = int(datetime.now().strftime('%s'))

    platform_key = await auth.authenticate_platform('foobar.com', n, 'foobar')
    platform, exp, rand = platform_key.split(':', 2)
    assert platform == 'foobar.com'
    assert 86390 < (int(exp) - n) < 86410
    assert len(rand) == 64

    await auth.valid_platform_token(platform_key)