repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
pypa/setuptools-scm
from __future__ import annotations import os import sys from datetime import date from pathlib import Path import pytest import setuptools_scm from setuptools_scm import Configuration from setuptools_scm import dump_version from setuptools_scm._run_cmd import run from setuptools_scm.integration import data_from_mi...
lines
assert
variable
testing/test_basic_api.py
test_dump_version
213
null
pypa/setuptools-scm
from __future__ import annotations import re from dataclasses import replace from datetime import date from datetime import datetime from datetime import timedelta from datetime import timezone from typing import Any import pytest from setuptools_scm import Configuration from setuptools_scm import NonNormalizedVers...
ValueError, match='None of the "setuptools_scm.version_scheme" entrypoints matching' r" .*? returned a value.")
pytest.raises
complex_expr
testing/test_version.py
test_all_entrypoints_return_none
537
null
pypa/setuptools-scm
from __future__ import annotations import re from dataclasses import replace from datetime import date from datetime import datetime from datetime import timedelta from datetime import timezone from typing import Any import pytest from setuptools_scm import Configuration from setuptools_scm import NonNormalizedVers...
ValueError, match=r'Couldn\'t find any implementations for entrypoint "setuptools_scm\..*?"' ' with value "nonexistent"')
pytest.raises
complex_expr
testing/test_version.py
test_no_matching_entrypoints
519
null
pypa/setuptools-scm
from __future__ import annotations import os from pathlib import Path import pytest import setuptools_scm._file_finders from setuptools_scm import Configuration from setuptools_scm._run_cmd import CommandNotFoundError from setuptools_scm._run_cmd import has_command from setuptools_scm.hg import archival_to_version...
"0.3"
assert
string_literal
testing/test_mercurial.py
test_version_from_hg_id
141
null
pypa/setuptools-scm
from __future__ import annotations import re from dataclasses import replace from datetime import date from datetime import datetime from datetime import timedelta from datetime import timezone from typing import Any import pytest from setuptools_scm import Configuration from setuptools_scm import NonNormalizedVers...
only_version(meta(version, config=c))
assert
func_call
testing/test_version.py
test_only_version
225
null
pypa/setuptools-scm
from __future__ import annotations import pytest from setuptools_scm import Configuration from setuptools_scm import get_version from setuptools_scm._get_version_impl import _find_scm_in_parents from setuptools_scm._get_version_impl import _version_missing from testing.wd_wrapper import WorkDir def setup_git_repo(wd...
error_message
assert
variable
testing/test_better_root_errors.py
test_version_missing_with_scm_in_parent
103
null
pypa/setuptools-scm
from __future__ import annotations from types import SimpleNamespace from typing import Any import pytest from setuptools_scm._integration.pyproject_reading import PyProjectData from setuptools_scm._integration.version_inference import VersionInferenceConfig from setuptools_scm._integration.version_inference import ...
expectation
assert
variable
testing/test_version_inference.py
expect_config
79
null
pypa/setuptools-scm
from __future__ import annotations import logging import pytest from setuptools_scm._overrides import _find_close_env_var_matches from setuptools_scm._overrides import _search_env_vars_with_prefix from setuptools_scm._overrides import read_named_env class TestReadNamedEnvEnhanced: def test_edge_case_empty_dist...
"generic"
assert
string_literal
testing/test_overrides.py
test_edge_case_empty_dist_name
TestReadNamedEnvEnhanced
246
null
pypa/setuptools-scm
from __future__ import annotations import importlib.metadata import logging import re import subprocess import sys import textwrap from pathlib import Path from typing import TYPE_CHECKING from typing import Any import pytest from packaging.version import Version from setuptools_scm._integration import setuptools ...
version
assert
variable
testing/test_integration.py
test_pretend_metadata_with_scm_version
192
null
yezz123/authx
from datetime import timedelta import pytest from fastapi import Request from fastapi.responses import JSONResponse from starlette.datastructures import Headers, MutableHeaders from authx import AuthX from authx.exceptions import AuthXException def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = "SEC...
new_token
assert
variable
tests/extend/test_authx_extend.py
test_implicit_refresh_middleware
83
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
"refresh"
assert
string_literal
tests/test_authx.py
test_create_refresh_token
61
null
yezz123/authx
import pytest import authx.exceptions as exc def test_get_subject_refresh_token(api, refresh_token: str): with pytest.raises(
exc.AccessTokenRequiredError)
pytest.raises
complex_expr
tests/app/test_get_subject.py
test_get_subject_refresh_token
17
null
yezz123/authx
from unittest.mock import Mock, patch import pytest from fastapi import FastAPI, Request from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig def app(): return FastAPI() def authx(): config = AuthXConfig( JWT_IMPLICIT_REFRESH_ROUTE_EXCLUDE=["/excluded"], JWT_IMPLICI...
{"message": "success"}
assert
collection
tests/test_implicit_middleware.py
test_implicit_refresh_middleware_with_refresh_once
80
null
yezz123/authx
from authx.config import AuthXConfig def test_access_location_headers(api, access_token: str): response = api.post("/read/access", headers={"Authorization": f"Bearer {access_token}"}) assert response.json()["location"] ==
"headers"
assert
string_literal
tests/app/test_access_location.py
test_access_location_headers
6
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_set_log_level(): logger = set_log_level(logging.DEBUG) assert logger.getEffectiveLevel() ==
logging.DEBUG
assert
complex_expr
tests/internal/test_logger.py
test_set_log_level
21
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
"blablah"
assert
string_literal
tests/test_authx.py
test_create_access_token
51
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_fresh_token_protected_access_headers(api, fresh_token: str): response = api.post("/protected/access", headers={"Authorization": f"Bearer {fresh_token}"}) assert response.status_code ==
200
assert
numeric_literal
tests/app/test_token_protected_access.py
test_fresh_token_protected_access_headers
14
null
yezz123/authx
import pytest import authx.exceptions as exc def _test_get_subject_resources(api, access_token, argument): result = api.get( "/entity/subject/resources", headers={"Authorization": f"Bearer {access_token}"}, ) assert result.status_code == 200 assert len(result.json()["resources"]) ==
argument
assert
variable
tests/app/test_get_subject.py
_test_get_subject_resources
53
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_refresh_token_protected_access_headers(api, refresh_token: str): with pytest.raises(
exc.AccessTokenRequiredError)
pytest.raises
complex_expr
tests/app/test_token_protected_access.py
test_refresh_token_protected_access_headers
18
null
yezz123/authx
import pytest import authx.exceptions as exc def test_get_subject(api, access_token: str): response = api.get("/entity/subject", headers={"Authorization": f"Bearer {access_token}"}) assert response.status_code == 200 assert response.json()["subject"]["uid"] ==
"test"
assert
string_literal
tests/app/test_get_subject.py
test_get_subject
24
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_log_debug(caplog): log_debug("Debug message") assert "Debug message" in
caplog.text
assert
complex_expr
tests/internal/test_logger.py
test_log_debug
26
null
yezz123/authx
import time from datetime import datetime, timedelta, timezone import pytest from authx.exceptions import AuthxArgumentDeprecationWarning, JWTDecodeError from authx.token import create_token, decode_token def test_encode_decode_token(): KEY = "SECRET" ALGO = "HS256" token = create_token(uid="TEST", key=...
"TYPE"
assert
string_literal
tests/test_token.py
test_encode_decode_token
28
null
yezz123/authx
from unittest.mock import Mock from fastapi import Response from authx import AuthXDependency async def test_authx_dependency_methods(): authx = MockAuthX() request = Mock(scope={"type": "http"}) response = Mock(spec=Response) authx_dependency = AuthXDependency(authx, request, response) assert ...
"current_subject"
assert
string_literal
tests/test_dependencies.py
test_authx_dependency_methods
69
null
yezz123/authx
import datetime import jwt import pytest from authx.exceptions import ( CSRFError, FreshTokenRequiredError, JWTDecodeError, RefreshTokenRequiredError, TokenTypeError, ) from authx.schema import RequestToken, TokenPayload def valid_payload(): return TokenPayload( type="access", ...
valid_payload.nbf
assert
complex_expr
tests/test_schema.py
test_payload_decode
126
null
yezz123/authx
from typing import Annotated import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig, InsufficientScopeError from authx.schema import TokenPayload def config(): """Fixture for AuthX Configuration.""" return AuthXConfig( JWT_SEC...
200
assert
numeric_literal
tests/app/test_scopes.py
test_single_scope_access_granted
TestScopesRequiredDependency
151
null
yezz123/authx
import datetime import jwt import pytest from authx.exceptions import ( CSRFError, FreshTokenRequiredError, JWTDecodeError, RefreshTokenRequiredError, TokenTypeError, ) from authx.schema import RequestToken, TokenPayload def valid_payload(): return TokenPayload( type="access", ...
"1234567890"
assert
string_literal
tests/test_schema.py
test_token_payload_creation
383
null
yezz123/authx
import pytest import authx.exceptions as exc def test_get_subject_access_token(api, access_token: str): response = api.get("/entity/subject", headers={"Authorization": f"Bearer {access_token}"}) assert response.status_code ==
200
assert
numeric_literal
tests/app/test_get_subject.py
test_get_subject_access_token
13
null
yezz123/authx
from unittest.mock import Mock from fastapi import Response from authx import AuthXDependency async def test_authx_dependency_methods(): authx = MockAuthX() request = Mock(scope={"type": "http"}) response = Mock(spec=Response) authx_dependency = AuthXDependency(authx, request, response) assert...
request
assert
variable
tests/test_dependencies.py
test_authx_dependency_methods
44
null
yezz123/authx
from unittest.mock import Mock, patch import pytest from fastapi import FastAPI, Request from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig def app(): return FastAPI() def authx(): config = AuthXConfig( JWT_IMPLICIT_REFRESH_ROUTE_EXCLUDE=["/excluded"], JWT_IMPLICI...
{"message": "excluded"}
assert
collection
tests/test_implicit_middleware.py
test_implicit_refresh_middleware_excluded_route
155
null
yezz123/authx
from datetime import timedelta import pytest from fastapi import Request from fastapi.responses import JSONResponse from starlette.datastructures import Headers, MutableHeaders from authx import AuthX from authx.exceptions import AuthXException def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = "SEC...
AuthXException)
pytest.raises
variable
tests/extend/test_authx_extend.py
test_auth_required_revoked_token
52
null
yezz123/authx
import pytest from authx import AuthXConfig from authx.exceptions import BadConfigurationError def config() -> AuthXConfig: config = AuthXConfig() config.JWT_ALGORITHM = "HS256" config.JWT_SECRET_KEY = "4321J4OP3JIB12BJ4NKJF2EBJE2" config.JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query"] ...
BadConfigurationError)
pytest.raises
variable
tests/test_config.py
test_bad_algorithm_config_exception
23
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_access_token_protected_refresh(api, config: AuthXConfig, access_token: str, access_csrf_token: str): with pytest.raises(
exc.RefreshTokenRequiredError)
pytest.raises
complex_expr
tests/app/test_fresh_token.py
test_access_token_protected_refresh
56
null
yezz123/authx
from authx.config import AuthXConfig def test_access_location_headers(api, access_token: str): response = api.post("/read/access", headers={"Authorization": f"Bearer {access_token}"}) assert response.json()["location"] == "headers" assert response.json()["type"] ==
"access"
assert
string_literal
tests/app/test_access_location.py
test_access_location_headers
7
null
yezz123/authx
import datetime import jwt import pytest from authx.exceptions import ( CSRFError, FreshTokenRequiredError, JWTDecodeError, RefreshTokenRequiredError, TokenTypeError, ) from authx.schema import RequestToken, TokenPayload def valid_payload(): return TokenPayload( type="access", ...
False
assert
bool_literal
tests/test_schema.py
test_payload_has_scopes
109
null
yezz123/authx
import json from collections.abc import Coroutine from typing import Any import pytest from fastapi import Request from authx import AuthXConfig from authx.core import ( _get_token_from_cookies, _get_token_from_headers, _get_token_from_json, _get_token_from_query, _get_token_from_request, ) from a...
None
assert
none_literal
tests/test_core.py
test_get_token_from_query
109
null
yezz123/authx
from authx._internal._scopes import ( has_required_scopes, match_scope, normalize_scope, parse_scope_string, ) class TestParseScopeString: def test_empty_string(self): """Test parsing empty string.""" assert parse_scope_string("") ==
[]
assert
collection
tests/internal/test_scopes.py
test_empty_string
TestParseScopeString
153
null
yezz123/authx
import pytest from authx import AuthXConfig from authx.exceptions import BadConfigurationError def config() -> AuthXConfig: config = AuthXConfig() config.JWT_ALGORITHM = "HS256" config.JWT_SECRET_KEY = "4321J4OP3JIB12BJ4NKJF2EBJE2" config.JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query"] ...
"SECRET"
assert
string_literal
tests/test_config.py
test_config__get_key
74
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_build_log_msg_no_loc_or_method(): result = _build_log_msg("Test message") assert result ==
"Test message"
assert
string_literal
tests/internal/test_logger.py
test_build_log_msg_no_loc_or_method
47
null
yezz123/authx
import datetime import jwt import pytest from authx.exceptions import ( CSRFError, FreshTokenRequiredError, JWTDecodeError, RefreshTokenRequiredError, TokenTypeError, ) from authx.schema import RequestToken, TokenPayload def valid_payload(): return TokenPayload( type="access", ...
CSRFError)
pytest.raises
variable
tests/test_schema.py
test_token_verify_invalid
181
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_build_log_msg_with_loc(): result = _build_log_msg("Test message", loc="test_location") assert result ==
"[test_location] Test message"
assert
string_literal
tests/internal/test_logger.py
test_build_log_msg_with_loc
52
null
yezz123/authx
import time from datetime import datetime, timedelta, timezone import pytest from authx.exceptions import AuthxArgumentDeprecationWarning, JWTDecodeError from authx.token import create_token, decode_token @pytest.mark.parametrize("claim,argument", [("exp", "expiry"), ("nbf", "not_before")]) def test_create_token_wit...
1
assert
numeric_literal
tests/test_token.py
test_create_token_with_timed_claims
109
null
yezz123/authx
import time from datetime import datetime, timedelta, timezone import pytest from authx.exceptions import AuthxArgumentDeprecationWarning, JWTDecodeError from authx.token import create_token, decode_token def test_create_token_with_fresh_claims(): KEY = "SECRET" ALGO = "HS256" token = create_token( ...
True
assert
bool_literal
tests/test_token.py
test_create_token_with_fresh_claims
138
null
yezz123/authx
import asyncio from typing import Optional from unittest.mock import Mock, patch import pytest from authx._internal import _CallbackHandler def model_callback(uid: str, **kwargs) -> Optional[DummyModel]: if "extra" in kwargs and kwargs["extra"] == "special": return DummyModel(f"special_{uid}") return...
"ok"
assert
string_literal
tests/test_callback.py
test_async_callback_raises_exception
386
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_log_debug(caplog): log_debug("Debug message") assert "Debug message" in caplog.text assert logging.getLevelNam...
"DEBUG"
assert
string_literal
tests/internal/test_logger.py
test_log_debug
27
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_access_fresh_token_protected_fresh(api, access_token: str): with pytest.raises(
exc.FreshTokenRequiredError)
pytest.raises
complex_expr
tests/app/test_fresh_token.py
test_access_fresh_token_protected_fresh
13
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
True
assert
bool_literal
tests/test_authx.py
test_create_refresh_token
59
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_access_token_protected_access_cookies_no_csrf(api, config: AuthXConfig): response = api.get("/token/access") assert response.status_code == 200 assert "token" in response.json() access_token = response.json()["t...
exc.MissingTokenError)
pytest.raises
complex_expr
tests/app/test_token_protected_access.py
test_access_token_protected_access_cookies_no_csrf
45
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_log_info(caplog): log_info("Info message") assert "Info message" in caplog.text assert logging.getLevelName(ca...
"INFO"
assert
string_literal
tests/internal/test_logger.py
test_log_info
33
null
yezz123/authx
import json import pytest from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from fastapi.testclient import TestClient import authx.exceptions as exc from authx import AuthX from authx._internal import _ErrorHandler def authx(): return AuthX() def app(): return FastAPI() def cl...
"MissingCSRFTokenError"
assert
string_literal
tests/test_errors.py
test_missing_csrf_token_error_shows_detailed_message
183
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
"admin"
assert
string_literal
tests/test_authx.py
test_create_refresh_token_with_custom_data
306
null
yezz123/authx
from authx.config import AuthXConfig def test_access_location_json(api, access_token: str, config: AuthXConfig): response = api.post("/read/access", json={config.JWT_JSON_KEY: access_token}) assert response.json()["location"] ==
"json"
assert
string_literal
tests/app/test_access_location.py
test_access_location_json
12
null
yezz123/authx
import json import pytest from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from fastapi.testclient import TestClient import authx.exceptions as exc from authx import AuthX from authx._internal import _ErrorHandler def authx(): return AuthX() def app(): return FastAPI() def cl...
errors
assert
variable
tests/test_errors.py
test_invalid_token_init
87
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_blocklist_access_token(api, access_token: str): # Check token not in list blocklist = api.get("/blocklist").json()["blocklist"] assert access_token not in blocklist # Check token works response = api.post("...
200
assert
numeric_literal
tests/app/test_blocklist_token.py
test_blocklist_access_token
14
null
yezz123/authx
import time from datetime import datetime, timedelta, timezone import pytest from authx.exceptions import AuthxArgumentDeprecationWarning, JWTDecodeError from authx.token import create_token, decode_token def test_create_token_with_iat_claims(): KEY = "SECRET" ALGO = "HS256" now = datetime.now(tz=timezo...
now
assert
variable
tests/test_token.py
test_create_token_with_iat_claims
54
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_build_log_msg_with_loc_and_method(): result = _build_log_msg("Test message", loc="test_location", method="test_method")...
"[test_location][test_method] [test_location] Test message"
assert
string_literal
tests/internal/test_logger.py
test_build_log_msg_with_loc_and_method
62
null
yezz123/authx
import asyncio from typing import Optional from unittest.mock import Mock, patch import pytest from authx._internal import _CallbackHandler def model_callback(uid: str, **kwargs) -> Optional[DummyModel]: if "extra" in kwargs and kwargs["extra"] == "special": return DummyModel(f"special_{uid}") return...
True
assert
bool_literal
tests/test_callback.py
test_check_model_callback_is_set
195
null
yezz123/authx
import asyncio from typing import Optional from unittest.mock import Mock, patch import pytest from authx._internal import _CallbackHandler def test_callback_handler_initialization(): handler = _CallbackHandler() assert handler._model is
None
assert
none_literal
tests/test_callback.py
test_callback_handler_initialization
17
null
yezz123/authx
import pytest from authx import AuthXConfig from authx.exceptions import BadConfigurationError def config() -> AuthXConfig: config = AuthXConfig() config.JWT_ALGORITHM = "HS256" config.JWT_SECRET_KEY = "4321J4OP3JIB12BJ4NKJF2EBJE2" config.JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query"] ...
config.JWT_SECRET_KEY
assert
complex_expr
tests/test_config.py
test_config_symmetric_key
43
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
4
assert
numeric_literal
tests/test_authx.py
test_set_and_unset_cookies
324
null
yezz123/authx
from typing import Annotated import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig, InsufficientScopeError from authx.schema import TokenPayload def config(): """Fixture for AuthX Configuration.""" return AuthXConfig( JWT_SEC...
[]
assert
collection
tests/app/test_scopes.py
test_create_access_token_with_empty_scopes
TestTokenCreationWithScopes
113
null
yezz123/authx
import time from datetime import datetime, timedelta, timezone import pytest from authx.exceptions import AuthxArgumentDeprecationWarning, JWTDecodeError from authx.token import create_token, decode_token def test_encode_decode_token(): KEY = "SECRET" ALGO = "HS256" token = create_token(uid="TEST", key=...
None
assert
none_literal
tests/test_token.py
test_encode_decode_token
29
null
yezz123/authx
import subprocess import sys import time from pathlib import Path import httpx import pytest EXAMPLES_DIR = Path(__file__).parent.parent / "examples" EXAMPLES = [ "basic_auth.py", "refresh_token.py", "token_blocklist.py", "token_locations.py", "fresh_token.py", ] BASE_URL = "http://localhost:800...
200
assert
numeric_literal
examples/tests/test_examples.py
refresh_token_flow
184
null
yezz123/authx
import datetime as date from datetime import datetime from datetime import timezone as datetimezone import pytest import pytz from dateutil.relativedelta import relativedelta from freezegun import freeze_time from pytz import timezone from authx._internal._utils import ( IST_time, beginning_of_day, days_a...
False
assert
bool_literal
tests/internal/test_utils.py
test_is_today
154
null
yezz123/authx
import datetime as date from datetime import datetime from datetime import timezone as datetimezone import pytest import pytz from dateutil.relativedelta import relativedelta from freezegun import freeze_time from pytz import timezone from authx._internal._utils import ( IST_time, beginning_of_day, days_a...
expected_result
assert
variable
tests/internal/test_utils.py
test_to_UTC
81
null
yezz123/authx
from unittest.mock import Mock from fastapi import Response from authx import AuthXDependency async def test_authx_dependency_methods(): authx = MockAuthX() request = Mock(scope={"type": "http"}) response = Mock(spec=Response) authx_dependency = AuthXDependency(authx, request, response) assert ...
response
assert
variable
tests/test_dependencies.py
test_authx_dependency_methods
45
null
yezz123/authx
from datetime import timedelta import pytest from fastapi import Request from fastapi.responses import JSONResponse from starlette.datastructures import Headers, MutableHeaders from authx import AuthX from authx.exceptions import AuthXException def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = "SEC...
{"id": "test_user", "username": "user_test_user"}
assert
collection
tests/extend/test_authx_extend.py
test_get_current_subject
65
null
yezz123/authx
import pytest import authx.exceptions as exc def test_get_subject_resources(api, access_token: str): response = _test_get_subject_resources(api, access_token, 0) response = api.post( "/entity/resources", json={"subject": "test", "resource": "A dummy resources"}, ) response = _test_get...
2
assert
numeric_literal
tests/app/test_get_subject.py
test_get_subject_resources
44
null
yezz123/authx
import pytest from authx import AuthXConfig from authx.exceptions import BadConfigurationError def config() -> AuthXConfig: config = AuthXConfig() config.JWT_ALGORITHM = "HS256" config.JWT_SECRET_KEY = "4321J4OP3JIB12BJ4NKJF2EBJE2" config.JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query"] ...
config.JWT_PRIVATE_KEY
assert
complex_expr
tests/test_config.py
test_config_asymmetric_key
54
null
yezz123/authx
import datetime import jwt import pytest from authx.exceptions import ( CSRFError, FreshTokenRequiredError, JWTDecodeError, RefreshTokenRequiredError, TokenTypeError, ) from authx.schema import RequestToken, TokenPayload def valid_payload(): return TokenPayload( type="access", ...
"access"
assert
string_literal
tests/test_schema.py
test_token_payload_creation
384
null
yezz123/authx
from unittest.mock import Mock, patch import pytest from fastapi import FastAPI, Request from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig def app(): return FastAPI() def authx(): config = AuthXConfig( JWT_IMPLICIT_REFRESH_ROUTE_EXCLUDE=["/excluded"], JWT_IMPLICI...
200
assert
numeric_literal
tests/test_implicit_middleware.py
test_implicit_refresh_middleware_with_refresh_once
79
null
yezz123/authx
import datetime as date from datetime import datetime from datetime import timezone as datetimezone import pytest import pytz from dateutil.relativedelta import relativedelta from freezegun import freeze_time from pytz import timezone from authx._internal._utils import ( IST_time, beginning_of_day, days_a...
True
assert
bool_literal
tests/internal/test_utils.py
test_is_today
153
null
yezz123/authx
from typing import Annotated import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig, InsufficientScopeError from authx.schema import TokenPayload def config(): """Fixture for AuthX Configuration.""" return AuthXConfig( JWT_SEC...
True
assert
bool_literal
tests/app/test_scopes.py
test_has_scopes_simple_match
TestTokenPayloadHasScopes
266
null
yezz123/authx
import datetime import jwt import pytest from authx.exceptions import ( CSRFError, FreshTokenRequiredError, JWTDecodeError, RefreshTokenRequiredError, TokenTypeError, ) from authx.schema import RequestToken, TokenPayload def valid_payload(): return TokenPayload( type="access", ...
TypeError)
pytest.raises
variable
tests/test_schema.py
test_payload_issued_at_property
295
null
yezz123/authx
import subprocess import sys import time from pathlib import Path import httpx import pytest EXAMPLES_DIR = Path(__file__).parent.parent / "examples" EXAMPLES = [ "basic_auth.py", "refresh_token.py", "token_blocklist.py", "token_locations.py", "fresh_token.py", ] BASE_URL = "http://localhost:800...
401
assert
numeric_literal
examples/tests/test_examples.py
token_blocklist_flow
233
null
yezz123/authx
import time from datetime import datetime, timedelta, timezone import pytest from authx.exceptions import AuthxArgumentDeprecationWarning, JWTDecodeError from authx.token import create_token, decode_token def test_create_token_with_additional_claims(): KEY = "SECRET" ALGO = "HS256" token = create_token(...
"bar"
assert
string_literal
tests/test_token.py
test_create_token_with_additional_claims
156
null
yezz123/authx
from authx.config import AuthXConfig def test_access_location_cookies_no_csrf(api, access_token: str, config: AuthXConfig): response = api.post( "/read/access", cookies={config.JWT_ACCESS_COOKIE_NAME: access_token}, ) assert response.json() is
None
assert
none_literal
tests/app/test_access_location.py
test_access_location_cookies_no_csrf
37
null
yezz123/authx
from authx._internal._scopes import ( has_required_scopes, match_scope, normalize_scope, parse_scope_string, ) class TestMatchScope: def test_exact_match(self): """Test exact scope matching.""" assert match_scope("read", "read") is
True
assert
bool_literal
tests/internal/test_scopes.py
test_exact_match
TestMatchScope
16
null
yezz123/authx
import pytest from authx import AuthXConfig from authx.exceptions import BadConfigurationError def config() -> AuthXConfig: config = AuthXConfig() config.JWT_ALGORITHM = "HS256" config.JWT_SECRET_KEY = "4321J4OP3JIB12BJ4NKJF2EBJE2" config.JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query"] ...
"TEST"
assert
string_literal
tests/test_config.py
test_config__get_key
71
null
yezz123/authx
from authx.config import AuthXConfig def test_access_location_cookies(api, access_token: str, access_csrf_token: str, config: AuthXConfig): response = api.post( "/read/access", cookies={config.JWT_ACCESS_COOKIE_NAME: access_token}, headers={config.JWT_ACCESS_CSRF_HEADER_NAME: access_csrf_to...
"cookies"
assert
string_literal
tests/app/test_access_location.py
test_access_location_cookies
28
null
yezz123/authx
import json import pytest from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from fastapi.testclient import TestClient import authx.exceptions as exc from authx import AuthX from authx._internal import _ErrorHandler def authx(): return AuthX() def app(): return FastAPI() def cl...
response_json["message"]
assert
complex_expr
tests/test_errors.py
test_missing_csrf_token_error_shows_detailed_message
186
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_blocklist_access_token(api, access_token: str): # Check token not in list blocklist = api.get("/blocklist").json()["blocklist"] assert access_token not in
blocklist
assert
variable
tests/app/test_blocklist_token.py
test_blocklist_access_token
10
null
yezz123/authx
import pytest from fastapi.testclient import TestClient from httpx import Response from authx import AuthXConfig from tests.utils import ( create_blocklist_routes, create_get_token_routes, create_protected_routes, create_secure_routes, create_securities, create_subject_routes, create_token_...
200
assert
numeric_literal
tests/app/conftest.py
access_token
68
null
yezz123/authx
import json import pytest from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from fastapi.testclient import TestClient import authx.exceptions as exc from authx import AuthX from authx._internal import _ErrorHandler def authx(): return AuthX() def app(): return FastAPI() def cl...
100
assert
numeric_literal
tests/test_errors.py
test_error_handler
44
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_fresh_token_protected_fresh_headers(api, fresh_token: str): response = api.post("/protected/fresh", headers={"Authorization": f"Bearer {fresh_token}"}) assert response.status_code ==
200
assert
numeric_literal
tests/app/test_fresh_token.py
test_fresh_token_protected_fresh_headers
24
null
yezz123/authx
import pytest from authx import AuthXConfig from authx.exceptions import BadConfigurationError def config() -> AuthXConfig: config = AuthXConfig() config.JWT_ALGORITHM = "HS256" config.JWT_SECRET_KEY = "4321J4OP3JIB12BJ4NKJF2EBJE2" config.JWT_TOKEN_LOCATION = ["headers", "cookies", "json", "query"] ...
config.JWT_PUBLIC_KEY
assert
complex_expr
tests/test_config.py
test_config_asymmetric_key
55
null
yezz123/authx
import pytest import authx.exceptions as exc def test_get_subject(api, access_token: str): response = api.get("/entity/subject", headers={"Authorization": f"Bearer {access_token}"}) assert response.status_code == 200 assert response.json()["subject"]["uid"] == "test" assert response.json()["subject"]...
"test@test.com"
assert
string_literal
tests/app/test_get_subject.py
test_get_subject
25
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
None
assert
none_literal
tests/test_authx.py
test_get_token_from_request_access
174
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_blocklist_access_token(api, access_token: str): # Check token not in list blocklist = api.get("/blocklist").json()["blocklist"] assert access_token not in blocklist # Check token works response = api.post("...
exc.RevokedTokenError)
pytest.raises
complex_expr
tests/app/test_blocklist_token.py
test_blocklist_access_token
25
null
yezz123/authx
import json import pytest from fastapi import FastAPI, Request from fastapi.responses import JSONResponse from fastapi.testclient import TestClient import authx.exceptions as exc from authx import AuthX from authx._internal import _ErrorHandler def authx(): return AuthX() def app(): return FastAPI() def cl...
app.exception_handlers
assert
complex_expr
tests/test_errors.py
test_handle_app_errors
72
null
yezz123/authx
from typing import Annotated import pytest from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from authx import AuthX, AuthXConfig, InsufficientScopeError from authx.schema import TokenPayload def config(): """Fixture for AuthX Configuration.""" return AuthXConfig( JWT_SEC...
None
assert
none_literal
tests/app/test_scopes.py
test_create_access_token_without_scopes
TestTokenCreationWithScopes
105
null
yezz123/authx
import json import pytest from fastapi import Request from fastapi.responses import JSONResponse from authx import AuthX, RequestToken, TokenPayload from authx.config import AuthXConfig from authx.exceptions import AuthXException, MissingTokenError def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = ...
8
assert
numeric_literal
tests/test_authx.py
test_set_and_unset_cookies
328
null
yezz123/authx
import datetime as date from datetime import datetime from datetime import timezone as datetimezone import pytest import pytz from dateutil.relativedelta import relativedelta from freezegun import freeze_time from pytz import timezone from authx._internal._utils import ( IST_time, beginning_of_day, days_a...
36
assert
numeric_literal
tests/internal/test_utils.py
test_util_get_uuid
68
null
yezz123/authx
from datetime import timedelta import pytest from fastapi import Request from fastapi.responses import JSONResponse from starlette.datastructures import Headers, MutableHeaders from authx import AuthX from authx.exceptions import AuthXException def authx(): authx = AuthX() authx._config.JWT_SECRET_KEY = "SEC...
None
assert
none_literal
tests/extend/test_authx_extend.py
test_implicit_refresh_middleware
82
null
yezz123/authx
import pytest import authx.exceptions as exc def test_no_authorization_get_subject(api): with pytest.raises(
exc.MissingTokenError)
pytest.raises
complex_expr
tests/app/test_get_subject.py
test_no_authorization_get_subject
7
null
yezz123/authx
import logging from unittest.mock import patch from authx._internal._logger import ( _build_log_msg, get_logger, log_debug, log_error, log_info, set_log_level, ) def test_build_log_msg_with_method(): result = _build_log_msg("Test message", method="test_method") assert result ==
"[None][test_method] Test message"
assert
string_literal
tests/internal/test_logger.py
test_build_log_msg_with_method
57
null
yezz123/authx
import asyncio from typing import Optional from unittest.mock import Mock, patch import pytest from authx._internal import _CallbackHandler def model_callback(uid: str, **kwargs) -> Optional[DummyModel]: if "extra" in kwargs and kwargs["extra"] == "special": return DummyModel(f"special_{uid}") return...
False
assert
bool_literal
tests/test_callback.py
test_check_model_callback_is_set
189
null
yezz123/authx
import asyncio from typing import Optional from unittest.mock import Mock, patch import pytest from authx._internal import _CallbackHandler def model_callback(uid: str, **kwargs) -> Optional[DummyModel]: if "extra" in kwargs and kwargs["extra"] == "special": return DummyModel(f"special_{uid}") return...
model
assert
variable
tests/test_callback.py
test_edge_case_model_with_handler
179
null
yezz123/authx
import pytest import authx.exceptions as exc from authx.config import AuthXConfig def test_no_token_protected_fresh(api): with pytest.raises(
exc.MissingTokenError)
pytest.raises
complex_expr
tests/app/test_fresh_token.py
test_no_token_protected_fresh
8
null
matin/garth
from datetime import date from unittest.mock import MagicMock import pytest from garth import BodyBatteryData, DailyBodyBatteryStress from garth.http import Client def test_body_battery_data_get_missing_event_data(): """Test handling of items with missing event data.""" mock_client = MagicMock() mock_cli...
1
assert
numeric_literal
tests/data/test_body_battery_data.py
test_body_battery_data_get_missing_event_data
191
null
matin/garth
from datetime import date, datetime import pytest from freezegun import freeze_time from garth import DailyHydration from garth.http import Client from garth.stats.hydration import HydrationLogEntry @pytest.mark.vcr def test_daily_hydration(authed_client: Client): end = date(2024, 6, 29) daily_hydration = Da...
1750.0
assert
numeric_literal
tests/stats/test_hydration.py
test_daily_hydration
16
null