Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Commit

Permalink
Remove search magic links endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Dec 2, 2024
1 parent 5b9cec2 commit ec68569
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 54 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"ruff.enable": false,
}
12 changes: 0 additions & 12 deletions models/magic_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
"""
Expand Down
17 changes: 0 additions & 17 deletions openapi/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
25 changes: 0 additions & 25 deletions tests/test_magic_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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": "[email protected]",
"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
Expand Down

0 comments on commit ec68569

Please sign in to comment.