Exemplo n.º 1
0
 async def x():
     async with subjectAsync.createSession(loop=loop) as session:
         client = subjectAsync.Auth(
             {
                 'rootUrl': base.REAL_ROOT_URL,
                 'credentials': {
                     'clientId': 'tester',
                     'accessToken': 'no-secret',
                 },
             },
             session=session)
         result = await client.testAuthenticate({
             'clientScopes': ['test:a'],
             'requiredScopes': ['test:a'],
         })
         assert result == {'scopes': ['test:a'], 'clientId': 'tester'}
Exemplo n.º 2
0
async def test_async_works_with_permanent_credentials():
    """we can call methods which require authentication with valid permacreds"""

    client = subjectAsync.Auth({
        'rootUrl': base.REAL_ROOT_URL,
        'credentials': {
            'clientId': 'tester',
            'accessToken': 'no-secret',
        },
    })
    result = await client.testAuthenticate({
        'clientScopes': ['test:a'],
        'requiredScopes': ['test:a'],
    })
    assert result == {
        'scopes': ['assume:anonymous', 'test:a'],
        'clientId': 'tester'
    }
Exemplo n.º 3
0
 async def x():
     async with subjectAsync.createSession(loop=loop) as session:
         client = subjectAsync.Auth(
             {
                 'credentials': {
                     'clientId': 'tester',
                     'accessToken': 'no-secret',
                 },
             },
             session=session)
         result = await client.testAuthenticate({
             'clientScopes': ['test:a'],
             'requiredScopes': ['test:a'],
         })
         self.assertEqual(result, {
             'scopes': ['test:a'],
             'clientId': 'tester'
         })
Exemplo n.º 4
0
    async def x():
        async with subjectAsync.createSession(loop=loop) as session:
            tempCred = subjectAsync.createTemporaryCredentials(
                'tester',
                'no-secret',
                datetime.datetime.utcnow(),
                datetime.datetime.utcnow() + datetime.timedelta(hours=1),
                ['test:xyz'],
            )
            client = subjectAsync.Auth(
                {
                    'rootUrl': base.REAL_ROOT_URL,
                    'credentials': tempCred,
                },
                session=session)

            result = await client.testAuthenticate({
                'clientScopes': ['test:*'],
                'requiredScopes': ['test:xyz'],
            })
            assert result == {'scopes': ['test:xyz'], 'clientId': 'tester'}
Exemplo n.º 5
0
        async def x():
            async with subjectAsync.createSession(loop=loop) as session:
                tempCred = subjectAsync.createTemporaryCredentials(
                    'tester',
                    'no-secret',
                    datetime.datetime.utcnow(),
                    datetime.datetime.utcnow() + datetime.timedelta(hours=1),
                    ['test:xyz'],
                )
                client = subjectAsync.Auth({
                    'credentials': tempCred,
                },
                                           session=session)

                result = client.testAuthenticate({
                    'clientScopes': ['test:*'],
                    'requiredScopes': ['test:xyz'],
                })
                self.assertEqual(result, {
                    'scopes': ['test:xyz'],
                    'clientId': 'tester'
                })
Exemplo n.º 6
0
async def test_async_works_with_temporary_credentials():
    """we can call methods which require authentication with temporary
    credentials generated by python client"""
    tempCred = subjectAsync.createTemporaryCredentials(
        'tester',
        'no-secret',
        datetime.datetime.utcnow(),
        datetime.datetime.utcnow() + datetime.timedelta(hours=1),
        ['test:xyz'],
    )
    client = subjectAsync.Auth({
        'rootUrl': base.REAL_ROOT_URL,
        'credentials': tempCred,
    })

    result = await client.testAuthenticate({
        'clientScopes': ['test:*'],
        'requiredScopes': ['test:xyz'],
    })
    assert result == {
        'scopes': ['assume:anonymous', 'test:xyz'],
        'clientId': 'tester'
    }