Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove first book auth API (PP-903) 🔥 #1642

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions api/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from flask_pydantic_spec import Response as SpecResponse

from api.admin.config import Configuration as AdminClientConfig
from api.admin.config import OperationalMode
from api.admin.controller.custom_lists import CustomListsController
from api.admin.dashboard_stats import generate_statistics
from api.admin.model.dashboard_statistics import StatisticsResponse
Expand All @@ -18,6 +19,7 @@
)
from api.admin.templates import admin_sign_in_again as sign_in_again_template
from api.app import api_spec, app
from api.controller.static_file import StaticFileController
from api.routes import allows_library, has_library, library_route
from core.app_server import ensure_pydantic_after_problem_detail, returns_problem_detail
from core.util.problem_detail import ProblemDetail, ProblemDetailModel, ProblemError
Expand Down Expand Up @@ -748,9 +750,11 @@


# This path is used only in debug mode to serve frontend assets.
@app.route("/admin/static/<filename>")
@returns_problem_detail
def admin_static_file(filename):
return app.manager.static_files.static_file(
AdminClientConfig.static_files_directory(), filename
)
if AdminClientConfig.operational_mode() == OperationalMode.development:

@app.route("/admin/static/<filename>")
@returns_problem_detail
def admin_static_file(filename):
return StaticFileController.static_file(

Check warning on line 758 in api/admin/routes.py

View check run for this annotation

Codecov / codecov/patch

api/admin/routes.py#L758

Added line #L758 was not covered by tests
AdminClientConfig.static_files_directory(), filename
)
3 changes: 0 additions & 3 deletions api/circulation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from api.controller.patron_auth_token import PatronAuthTokenController
from api.controller.playtime_entries import PlaytimeEntriesController
from api.controller.profile import ProfileController
from api.controller.static_file import StaticFileController
from api.controller.urn_lookup import URNLookupController
from api.controller.work import WorkController
from api.custom_index import CustomIndexView
Expand Down Expand Up @@ -87,7 +86,6 @@ class CirculationManager(LoggerMixin):
patron_devices: DeviceTokensController
version: ApplicationVersionController
odl_notification_controller: ODLNotificationController
static_files: StaticFileController
playtime_entries: PlaytimeEntriesController

# Admin controllers
Expand Down Expand Up @@ -289,7 +287,6 @@ def setup_one_time_controllers(self):
self.patron_devices = DeviceTokensController(self)
self.version = ApplicationVersionController()
self.odl_notification_controller = ODLNotificationController(self)
self.static_files = StaticFileController(self)
self.patron_auth_token = PatronAuthTokenController(self)
self.playtime_entries = PlaytimeEntriesController(self)

Expand Down
26 changes: 4 additions & 22 deletions api/controller/static_file.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
from __future__ import annotations

import os

import flask

from api.config import Configuration
from api.controller.circulation_manager import CirculationManagerController
from core.model import ConfigurationSetting


class StaticFileController(CirculationManagerController):
def static_file(self, directory, filename):
max_age = ConfigurationSetting.sitewide(
self._db, Configuration.STATIC_FILE_CACHE_TIME
).int_value
return flask.send_from_directory(directory, filename, max_age=max_age)

def image(self, filename):
directory = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
"..",
"..",
"resources",
"images",
)
return self.static_file(directory, filename)
class StaticFileController:
@staticmethod
def static_file(directory, filename):
return flask.send_from_directory(directory, filename)
175 changes: 0 additions & 175 deletions api/firstbook2.py

This file was deleted.

2 changes: 0 additions & 2 deletions api/integration/registry/patron_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
class PatronAuthRegistry(IntegrationRegistry["AuthenticationProviderType"]):
def __init__(self) -> None:
super().__init__(Goals.PATRON_AUTH_GOAL)
from api.firstbook2 import FirstBookAuthenticationAPI
from api.kansas_patron import KansasAuthenticationAPI
from api.millenium_patron import MilleniumPatronAPI
from api.saml.provider import SAMLWebSSOAuthenticationProvider
Expand All @@ -27,7 +26,6 @@ def __init__(self) -> None:
)
self.register(MilleniumPatronAPI, canonical="api.millenium_patron")
self.register(SIP2AuthenticationProvider, canonical="api.sip")
self.register(FirstBookAuthenticationAPI, canonical="api.firstbook2")
self.register(KansasAuthenticationAPI, canonical="api.kansas_patron")
self.register(SAMLWebSSOAuthenticationProvider, canonical="api.saml.provider")
self.register(
Expand Down
Binary file removed resources/OpenSans-Bold.ttf
Binary file not shown.
Binary file removed resources/OpenSans-Regular.ttf
Binary file not shown.
Binary file removed resources/images/FirstBookLoginButton280.png
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/api/admin/controller/test_patron_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_patron_auth_services_get_with_no_services(
assert response_data.get("patron_auth_services") == []
protocols = response_data.get("protocols")
assert isinstance(protocols, list)
assert 7 == len(protocols)
assert 6 == len(protocols)
assert "settings" in protocols[0]
assert "library_settings" in protocols[0]

Expand Down
32 changes: 0 additions & 32 deletions tests/api/admin/test_routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
from collections.abc import Generator
from pathlib import Path
from typing import Any
from unittest.mock import MagicMock

Expand Down Expand Up @@ -802,37 +801,6 @@ def test_admin_view(self, fixture: AdminRouteFixture):
fixture.assert_request_calls(url, fixture.controller, None, None, path="a/path")


class TestAdminStatic:
CONTROLLER_NAME = "static_files"

@pytest.fixture(scope="function")
def fixture(self, admin_route_fixture: AdminRouteFixture) -> AdminRouteFixture:
admin_route_fixture.set_controller_name(self.CONTROLLER_NAME)
return admin_route_fixture

def test_static_file(self, fixture: AdminRouteFixture):
# Go to the back to the root folder to get the right
# path for the static files.
root_path = Path(__file__).parent.parent.parent.parent
local_path = (
root_path
/ "api/admin/node_modules/@thepalaceproject/circulation-admin/dist"
)

url = "/admin/static/circulation-admin.js"
fixture.assert_request_calls(
url, fixture.controller.static_file, str(local_path), "circulation-admin.js" # type: ignore
)

url = "/admin/static/circulation-admin.css"
fixture.assert_request_calls(
url,
fixture.controller.static_file, # type: ignore
str(local_path),
"circulation-admin.css",
)


def test_returns_json_or_response_or_problem_detail():
@routes.returns_json_or_response_or_problem_detail
def mock_responses(response):
Expand Down
Loading