Example #1
0
async def test_invalid_public_key():
    auth = SimpleAuthenticator()
    auth.public_key_value = 'whatever'
    auth._now_unix = lambda: TS

    with pytest.raises(FailedInboundAuthentication) as excinfo:
        await auth.authenticate_platform(PLATFORM, TIMESTAMP, VALID_SIGNATURE)
    assert excinfo.value.args[0] == 'RSA key format is not supported'
Example #2
0
async def test_key_verification_old_ts():
    auth = SimpleAuthenticator()
    auth._now_unix = lambda: TS
    with pytest.raises(FailedInboundAuthentication) as excinfo:
        await auth.authenticate_platform('foobar.com', 2461449100, VALID_SIGNATURE)
    assert excinfo.value.args[0] == '2461449100 was not between 2461449590 and 2461449601'
Example #3
0
async def test_key_verification():
    auth = SimpleAuthenticator()
    auth._now_unix = lambda: TS

    platform_key = await auth.authenticate_platform(PLATFORM, TIMESTAMP, VALID_SIGNATURE)
    await auth.valid_platform_token(platform_key)
Example #4
0
async def test_key_verification_bad_signature():
    auth = SimpleAuthenticator()
    auth._now_unix = lambda: TS
    with pytest.raises(FailedInboundAuthentication) as excinfo:
        await auth.authenticate_platform(PLATFORM, TIMESTAMP, VALID_SIGNATURE.replace('2', '3'))
    assert excinfo.value.args[0] == 'invalid signature'
Example #5
0
File: conftest.py Project: em-2/em2
def _create_app(loop):
    ds = SimpleDataStore()
    ctrl = Controller(ds)
    auth = SimpleAuthenticator()
    auth._now_unix = lambda: 2461449600
    return create_app(ctrl, auth, loop=loop)