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))
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))
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))
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))
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))
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))
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