コード例 #1
0
def test_setauth():
    cinp = CInP('http://localhost:8080', '/api/v1/', None)
    cinp.setAuth('user', 'token')
    cinp.setAuth()
コード例 #2
0
ファイル: run_demo.py プロジェクト: cinp/python
print(client.list('/api/v1/Car/Car'))

print(
    'but we can not look at it, checkAuth in that model saies that only owners can do that'
)
try:
    print(client.get('/api/v1/Car/Car:gremlin:'))
except NotAuthorized:
    pass

print('let us login...')
auth_token = client.call('/api/v1/User/Session(login)', {
    'username': '******',
    'password': '******'
})
client.setAuth('ford', auth_token)
print('Now we can see it')
print(client.get('/api/v1/Car/Car:gremlin:'))

print('login as a super user...')
auth_token = client.call('/api/v1/User/Session(login)', {
    'username': '******',
    'password': '******'
})
client.setAuth('admin', auth_token)
print('can still see it, superusers are subjext to checkAuth')
print(client.get('/api/v1/Car/Car:gremlin:'))

print('let us login again...')
auth_token = client.call('/api/v1/User/Session(login)', {
    'username': '******',