+18


![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)

![autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)




FFXN
GitHub
yyh
盐粒 Yanli
autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Tianle
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Yunlu Wen
zyssyz123
Claude Opus 4.7
chariri
Asuka Minato
Copilot Autofix powered by AI
Nian
非法操作
Carmen Fernández Ruiz
wangxiaolei
QuantumGhost
L1nSn0w
Evan
Escape0707
Jingyi
Amr Sherif
ZHOU ZHICHEN
unknown
JzoNg
Xiyuan Chen
-LAN-
107bba0116
Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: EvanYao826 <[email protected]> Co-authored-by: yyh <[email protected]> Co-authored-by: 盐粒 Yanli <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Tianle <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yunlu Wen <[email protected]> Co-authored-by: zyssyz123 <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> Co-authored-by: chariri <[email protected]> Co-authored-by: Asuka Minato <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> Co-authored-by: Nian <[email protected]> Co-authored-by: 非法操作 <[email protected]> Co-authored-by: Carmen Fernández Ruiz <[email protected]> Co-authored-by: wangxiaolei <[email protected]> Co-authored-by: QuantumGhost <[email protected]> Co-authored-by: L1nSn0w <[email protected]> Co-authored-by: Evan <[email protected]> Co-authored-by: Escape0707 <[email protected]> Co-authored-by: Jingyi <[email protected]> Co-authored-by: Amr Sherif <[email protected]> Co-authored-by: ZHOU ZHICHEN <[email protected]> Co-authored-by: unknown <[email protected]> Co-authored-by: JzoNg <[email protected]> Co-authored-by: Xiyuan Chen <[email protected]> Co-authored-by: -LAN- <[email protected]>
49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
import uuid
|
|
|
|
import pytest
|
|
from flask import Flask
|
|
|
|
from controllers.openapi import bp as openapi_bp
|
|
from controllers.openapi.auth.data import AuthData
|
|
from controllers.openapi.auth.pipeline import PipelineRouter
|
|
from libs.oauth_bearer import Scope, TokenType
|
|
|
|
|
|
def _stub_execute(self, args, kwargs, view, *, scope=None, allowed_token_types=None, edition=None):
|
|
"""Bypass all auth logic; inject minimal AuthData and call the view directly."""
|
|
kwargs["auth_data"] = AuthData(
|
|
token_type=TokenType.OAUTH_ACCOUNT,
|
|
account_id=uuid.uuid4(),
|
|
token_hash="test",
|
|
token_id=uuid.uuid4(),
|
|
scopes=frozenset({Scope.FULL}),
|
|
required_scope=scope,
|
|
)
|
|
return view(*args, **kwargs)
|
|
|
|
|
|
@pytest.fixture
|
|
def bypass_pipeline(monkeypatch):
|
|
"""Stub PipelineRouter._execute so endpoints skip real auth at request time.
|
|
|
|
Module-level @auth_router.guard(...) captures the real router at import
|
|
time — patching guard itself does nothing. Patching _execute on the class
|
|
is the seam that fires at request time.
|
|
"""
|
|
monkeypatch.setattr(PipelineRouter, "_execute", _stub_execute)
|
|
|
|
|
|
@pytest.fixture
|
|
def openapi_app():
|
|
app = Flask(__name__)
|
|
app.config["TESTING"] = True
|
|
app.register_blueprint(openapi_bp)
|
|
return app
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
a = Flask(__name__)
|
|
a.config["TESTING"] = True
|
|
return a
|