コード例 #1
0
ファイル: test_async.py プロジェクト: walac/taskcluster
 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'}
コード例 #2
0
ファイル: test_client.py プロジェクト: vnzongzna/taskcluster
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'
    }
コード例 #3
0
ファイル: test_async.py プロジェクト: gsnedders/gecko
 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'
         })
コード例 #4
0
ファイル: test_async.py プロジェクト: walac/taskcluster
    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'}
コード例 #5
0
ファイル: test_async.py プロジェクト: gsnedders/gecko
        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'
                })
コード例 #6
0
ファイル: test_client.py プロジェクト: vnzongzna/taskcluster
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'
    }