예제 #1
0
def test_get_identity_404(fx_app, fx_token_id):
    with fx_app.test_request_context():
        try:
            result = get_identity(fx_token_id)
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 404
            data = json.loads(response.data)
            assert data["error"] == "token-not-found"
        else:
            fail("get_identity() does not raise HTTPException, but returns " + repr(result))
예제 #2
0
def test_get_identity_404(fx_app, fx_token_id):
    with fx_app.test_request_context():
        try:
            result = get_identity(fx_token_id)
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 404
            data = json.loads(response.get_data())
            assert data['error'] == 'token-not-found'
        else:
            fail('get_identity() does not raise HTTPException, but returns ' +
                 repr(result))
예제 #3
0
def test_get_identity_412(fx_app, fx_token_store, fx_token_id):
    fx_token_store.set(fx_token_id, "nonce")
    with fx_app.test_request_context():
        try:
            result = get_identity(fx_token_id)
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 412
            data = json.loads(response.data)
            assert data["error"] == "unfinished-authentication"
        else:
            fail("get_identity() does not raise HTTPException, but returns " + repr(result))
예제 #4
0
def test_get_identity_412(fx_app, fx_token_store, fx_token_id):
    fx_token_store.set(fx_token_id, 'nonce')
    with fx_app.test_request_context():
        try:
            result = get_identity(fx_token_id)
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 412
            data = json.loads(response.get_data())
            assert data['error'] == 'unfinished-authentication'
        else:
            fail('get_identity() does not raise HTTPException, but returns ' +
                 repr(result))
예제 #5
0
def test_get_identity_403(fx_app, fx_token_store, fx_token_id):
    expires_at = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(hours=1)
    fx_token_store.set(fx_token_id, Token(Identity(DummyTeam, 1, False), expires_at))
    with fx_app.test_request_context():
        try:
            result = get_identity(fx_token_id)
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 403
            data = json.loads(response.data)
            assert data["error"] == "not-authorized"
        else:
            fail("get_identity() does not raise HTTPException, but returns " + repr(result))
예제 #6
0
def test_get_identity_403(fx_app, fx_token_store, fx_token_id):
    expires_at = (datetime.datetime.now(datetime.timezone.utc) +
                  datetime.timedelta(hours=1))
    fx_token_store.set(fx_token_id,
                       Token(Identity(DummyTeam, 1, False), expires_at))
    with fx_app.test_request_context():
        try:
            result = get_identity(fx_token_id)
        except HTTPException as e:
            response = e.get_response(request.environ)
            assert response.status_code == 403
            data = json.loads(response.get_data())
            assert data['error'] == 'not-authorized'
        else:
            fail('get_identity() does not raise HTTPException, but returns ' +
                 repr(result))
예제 #7
0
def test_get_identity(fx_app, fx_authorized_identity, fx_token_id):
    with fx_app.test_request_context():
        identity = get_identity(fx_token_id)
        assert identity == fx_authorized_identity
예제 #8
0
def test_get_identity(fx_app, fx_authorized_identity, fx_token_id):
    with fx_app.test_request_context():
        identity = get_identity(fx_token_id)
        assert identity == fx_authorized_identity