From 9d1fc632575d9a0b60e4188e9e061a76412bcab9 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Mon, 2 Dec 2024 09:50:02 +0000 Subject: [PATCH] Remove search magic links endpoint --- .vscode/settings.json | 1 + models/magic_link.py | 12 ------------ openapi/api.yml | 17 ----------------- tests/test_magic_links.py | 25 ------------------------- 4 files changed, 1 insertion(+), 54 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3dded013..8839a330 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,4 +5,5 @@ ], "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, + "ruff.enable": false, } diff --git a/models/magic_link.py b/models/magic_link.py index d43cc683..6dda16a3 100644 --- a/models/magic_link.py +++ b/models/magic_link.py @@ -11,9 +11,7 @@ from urllib.parse import urljoin from config import Config -from flask import abort from flask import current_app -from flask import Response from flask_redis import FlaskRedis from security.utils import create_token @@ -45,16 +43,6 @@ def __init__(self, message="Sorry, there was a problem, please try later"): class MagicLinkMethods(object): - def search(self): - """ - GET /magic-links endpoint - :return: Json Response - """ - if not Config.FLASK_ENV == "production": - return Response(json.dumps(self.links), mimetype="application/json") - else: - return abort(403) - @property def redis_mlinks(self) -> FlaskRedis: """ diff --git a/openapi/api.yml b/openapi/api.yml index c6541425..455c0afa 100644 --- a/openapi/api.yml +++ b/openapi/api.yml @@ -11,23 +11,6 @@ tags: - name: sessions description: Session operations paths: - /magic-links: - get: - tags: - - magic links - summary: Search magic link - description: List all magic links - operationId: api.MagicLinksView.search - responses: - 200: - description: SUCCESS - A list of magic link keys - content: - application/json: - schema: - type: array - items: - type: string - '/magic-links/{link_id}': get: tags: diff --git a/tests/test_magic_links.py b/tests/test_magic_links.py index 48a6b6ad..b3c8794f 100644 --- a/tests/test_magic_links.py +++ b/tests/test_magic_links.py @@ -9,7 +9,6 @@ from api.session.auth_session import AuthSessionView from app import app from bs4 import BeautifulSoup -from config import Config from frontend.magic_links.forms import EmailForm from models.account import AccountMethods from security.utils import validate_token @@ -219,30 +218,6 @@ def test_invalid_magic_link_returns_link_expired(self, flask_test_client): assert b"Link expired" in response.data assert b"Request a new link" in response.data - @mock.patch.object(Config, "FLASK_ENV", "production") - def test_search_magic_link_forbidden_on_production(self, flask_test_client): - use_endpoint = "/magic-links" - response = flask_test_client.get(use_endpoint, follow_redirects=True) - assert response.status_code == 403 - - def test_search_magic_link_returns_magic_links(self, flask_test_client): - with mock.patch("models.fund.FundMethods.get_fund"), mock.patch("models.account.get_round_data"), mock.patch( - "frontend.magic_links.routes.get_round_data" - ): - payload = { - "email": "new_user@example.com", - "redirectUrl": "https://example.com/redirect-url", - } - endpoint = "/service/magic-links/new?fund=cof&round=r2w3" - - flask_test_client.post(endpoint, data=payload) - - endpoint = "/magic-links" - get_response = flask_test_client.get(endpoint) - assert get_response.status_code == 200 - assert "account:usernew" in get_response.get_json() - assert next(x for x in get_response.get_json() if x.startswith("link:")) is not None - def test_assessor_roles_is_empty_via_magic_link_auth(self): """ GIVEN we are on the production environment