mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-08 03:28:35 +03:00
relocating security file
This commit is contained in:
@@ -4,7 +4,7 @@ from sqlalchemy import Column, or_, func
|
||||
from loguru import logger
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
from shared.settings import Settings
|
||||
from . import models, schemas
|
||||
import yaml
|
||||
|
||||
@@ -7,7 +7,7 @@ from sqlalchemy.orm import Session
|
||||
from core.config import VERSION, BREAKING_CHANGES
|
||||
from db import crud
|
||||
from db.database import get_db_dependency, get_db
|
||||
from security import get_user_auth, bearer_security
|
||||
from web.security import get_user_auth, bearer_security
|
||||
|
||||
default_router = APIRouter()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from auto_archiver import Metadata
|
||||
from loguru import logger
|
||||
import sqlalchemy
|
||||
|
||||
from security import token_api_key_auth
|
||||
from web.security import token_api_key_auth
|
||||
from db import models, schemas
|
||||
from worker import insert_result_into_db
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from fastapi.responses import JSONResponse
|
||||
|
||||
from loguru import logger
|
||||
|
||||
from security import ALLOW_ANY_EMAIL, get_token_or_user_auth
|
||||
from web.security import ALLOW_ANY_EMAIL, get_token_or_user_auth
|
||||
from db import schemas
|
||||
from worker import create_sheet_task
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
from loguru import logger
|
||||
from security import get_token_or_user_auth
|
||||
from web.security import get_token_or_user_auth
|
||||
|
||||
from db import schemas
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from fastapi.responses import JSONResponse
|
||||
from datetime import datetime
|
||||
|
||||
from loguru import logger
|
||||
from security import get_user_auth, get_token_or_user_auth
|
||||
from web.security import get_user_auth, get_token_or_user_auth
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from db import crud, schemas
|
||||
|
||||
@@ -71,7 +71,7 @@ def client(app):
|
||||
|
||||
@pytest.fixture()
|
||||
def app_with_auth(app):
|
||||
from security import get_token_or_user_auth, get_user_auth, token_api_key_auth
|
||||
from web.security import get_token_or_user_auth, get_user_auth, token_api_key_auth
|
||||
app.dependency_overrides[get_token_or_user_auth] = lambda: "rick@example.com"
|
||||
app.dependency_overrides[get_user_auth] = lambda: "morty@example.com"
|
||||
app.dependency_overrides[token_api_key_auth] = lambda: "jerry@example.com"
|
||||
|
||||
@@ -57,7 +57,7 @@ def test_data(db_session):
|
||||
|
||||
def test_get_archive(test_data, db_session):
|
||||
from db import crud
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
|
||||
print(db_session.query(models.Group).all())
|
||||
|
||||
@@ -88,7 +88,7 @@ def test_get_archive(test_data, db_session):
|
||||
|
||||
def test_search_archives_by_url(test_data, db_session):
|
||||
from db import crud
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
|
||||
# rick's archives are private
|
||||
assert len(crud.search_archives_by_url(db_session, "https://example-0.com", "rick@example.com")) == 34
|
||||
@@ -133,9 +133,9 @@ def test_search_archives_by_url(test_data, db_session):
|
||||
|
||||
|
||||
def test_search_archives_by_email(test_data, db_session):
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
from db import crud
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
|
||||
# lower/upper case
|
||||
assert len(crud.search_archives_by_email(db_session, "rick@example.com")) == 34
|
||||
@@ -158,7 +158,7 @@ def test_search_archives_by_email(test_data, db_session):
|
||||
@patch("db.crud.DATABASE_QUERY_LIMIT", new=25)
|
||||
def test_max_query_limit(test_data, db_session):
|
||||
from db import crud
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
|
||||
assert len(crud.search_archives_by_url(db_session, "https://example", ALLOW_ANY_EMAIL)) == 25
|
||||
assert len(crud.search_archives_by_url(db_session, "https://example", ALLOW_ANY_EMAIL, limit=1000)) == 25
|
||||
@@ -290,7 +290,7 @@ def test_create_tag(db_session):
|
||||
|
||||
def test_is_user_in_group(test_data, db_session):
|
||||
from db import crud
|
||||
from security import ALLOW_ANY_EMAIL
|
||||
from web.security import ALLOW_ANY_EMAIL
|
||||
|
||||
# see user-groups.test.yaml
|
||||
test_pairs = [
|
||||
|
||||
@@ -57,7 +57,7 @@ def test_endpoint_groups_rick_and_morty(client_with_auth):
|
||||
|
||||
@patch("endpoints.default.crud.get_user_groups", return_value=["group1", "group2"])
|
||||
def test_endpoint_groups(m1, app):
|
||||
from security import get_user_auth
|
||||
from web.security import get_user_auth
|
||||
app.dependency_overrides[get_user_auth] = lambda: True
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ from core.logging import logging_middleware
|
||||
from worker import create_archive_task, create_sheet_task, celery, insert_result_into_db
|
||||
|
||||
from db import crud, models, schemas
|
||||
from security import get_user_auth, token_api_key_auth, get_token_or_user_auth
|
||||
from web.security import get_user_auth, token_api_key_auth, get_token_or_user_auth
|
||||
from core.config import VERSION, API_DESCRIPTION
|
||||
from db.database import get_db_dependency
|
||||
from core.events import lifespan
|
||||
|
||||
Reference in New Issue
Block a user