Esempio n. 1
0
def test_get_public_key(fx_app, fx_key_store, fx_authorized_identity,
                        fx_token_id):
    key = RSAKey.generate(1024)
    fx_key_store.register(fx_authorized_identity, key)
    with fx_app.test_request_context():
        found = get_public_key(fx_token_id, key.get_fingerprint())
        assert found == key
Esempio n. 2
0
def test_get_public_key(fx_app, fx_key_store,
                        fx_authorized_identity,
                        fx_token_id):
    key = RSAKey.generate(1024)
    fx_key_store.register(fx_authorized_identity, key)
    with fx_app.test_request_context():
        found = get_public_key(fx_token_id, key.get_fingerprint())
        assert found == key
Esempio n. 3
0
def test_get_public_key_404(fx_app, fx_key_store, fx_authorized_identity, fx_token_id):
    with fx_app.test_request_context():
        try:
            result = get_public_key(fx_token_id, os.urandom(16))
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 404
            assert response.mimetype == "application/json"
            error = json.loads(response.data.decode("utf-8"))
            assert error["error"] == "not-found"
        else:
            fail("get_public_key() does not raise HTTPException, " "but returns " + repr(result))
Esempio n. 4
0
def test_get_public_key_404(fx_app, fx_key_store, fx_authorized_identity,
                            fx_token_id):
    with fx_app.test_request_context():
        try:
            result = get_public_key(fx_token_id, os.urandom(16))
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 404
            assert response.mimetype == 'application/json'
            error = json.loads(response.get_data(as_text=True))
            assert error['error'] == 'not-found'
        else:
            fail('get_public_key() does not raise HTTPException, '
                 'but returns ' + repr(result))
Esempio n. 5
0
def test_get_public_key_404(fx_app, fx_key_store,
                            fx_authorized_identity,
                            fx_token_id):
    with fx_app.test_request_context():
        try:
            result = get_public_key(fx_token_id, os.urandom(16))
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 404
            assert response.mimetype == 'application/json'
            error = json.loads(response.get_data(as_text=True))
            assert error['error'] == 'not-found'
        else:
            fail('get_public_key() does not raise HTTPException, '
                 'but returns ' + repr(result))