示例#1
0
def test_create_existing_id():
    redisclient.set_id('test_id', json.dumps(test_id))
    response = client.post('/ids/test_id' + password_slug +
                           '&login={}'.format(test_id['login']) +
                           '&password={}'.format(test_id['password']))
    assert response.status_code == 500
    redisclient.delete_id('test_id')
示例#2
0
def test_create_absent_id():
    response = client.post('/ids/test_id' + password_slug +
                           '&login={}'.format(test_id['login']) +
                           '&password={}'.format(test_id['password']))
    assert response.status_code == 200
    assert (redisclient.get_id('test_id'))
    assert response.json() == {'created': 'test_id'}
    redisclient.delete_id('test_id')
示例#3
0
def delete_id(p: http.QueryParam, name: str) -> dict:
    _auth(p)
    response = redisclient.get_id(name)
    if response is None:
        raise exceptions.NotFound()
    if not redisclient.delete_id(name):
        raise exceptions.HTTPException(
            'Internal error while deleting ' + 'identity {}'.format(name), 500)
    return {'deleted': name}
示例#4
0
def test_update_existing_id():
    redisclient.set_id('test_id', json.dumps(test_id))
    response = client.put('/ids/test_id' + password_slug +
                          '&login={}'.format('updated'))
    assert response.status_code == 200
    assert response.json() == {'login': '******', 'password': '******'}
    response = client.put('/ids/test_id' + password_slug +
                          '&password={}'.format('updated'))
    assert response.status_code == 200
    assert response.json() == {'login': '******', 'password': '******'}
    response = client.put('/ids/test_id' + password_slug +
                          '&login={}'.format('again') +
                          '&password={}'.format('again'))
    assert response.status_code == 200
    assert response.json() == {'login': '******', 'password': '******'}
    response = client.put('/ids/test_id' + password_slug)
    assert response.status_code == 400
    redisclient.delete_id('test_id')
示例#5
0
def test_update_absent_id():
    response = client.put('/ids/test_id' + password_slug +
                          '&password={}'.format('updated'))
    assert response.status_code == 404
    redisclient.delete_id('test_id')
示例#6
0
def test_get_absent_id():
    redisclient.delete_id('test_id')
    response = client.get('/ids/test_id' + password_slug)
    assert response.status_code == 404
示例#7
0
def test_get_existing_id():
    redisclient.set_id('test_id', json.dumps(test_id))
    response = client.get('/ids/test_id' + password_slug)
    assert response.status_code == 200
    assert response.json() == json.loads(json.dumps(test_id))
    redisclient.delete_id('test_id')
示例#8
0
def test_get_ids_list():
    redisclient.set_id('test_id', json.dumps(test_id))
    response = client.get('/ids/' + password_slug)
    assert response.status_code == 200
    assert 'test_id' in response.json()['identities']
    redisclient.delete_id('test_id')