面板可传 --author 避免 web 默认 identity 污染;list 统计 open 时缺省 status 按 open。补 web action 白名单单测(idea list 等)。
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""web action 白名单:精确匹配与带参前缀(idea list 等)"""
|
||
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
import pytest
|
||
|
||
SRC = Path(__file__).parent.parent / "src"
|
||
sys.path.insert(0, str(SRC))
|
||
|
||
from joy.commands.web import _check_action # noqa: E402
|
||
|
||
|
||
@pytest.mark.parametrize(
|
||
"args,expected",
|
||
[
|
||
(["idea", "list"], True),
|
||
(["idea", "list", "--limit", "20"], True),
|
||
(["idea", "list", "--all"], True),
|
||
(["idea", "add", "hello"], True),
|
||
(["idea", "add", "hello", "body", "--tag", "a,b"], True),
|
||
(["idea", "add", "t", "--author", "linuxjoy"], True),
|
||
(["idea", "close", "IDEA-1"], True),
|
||
(["dashboard", "--json"], True),
|
||
(["board", "create", "devops", "desc", "--family", "business"], True),
|
||
(["evil", "cmd"], False),
|
||
(["idea"], False),
|
||
(["idea", "search", "x"], False), # 未进白名单
|
||
],
|
||
)
|
||
def test_check_action_whitelist(args, expected):
|
||
assert _check_action(args) is expected
|
||
|
||
|
||
def test_idea_list_exact_not_require_rest():
|
||
"""回归:takes_arg=True 时不得误杀精确 idea list。"""
|
||
assert _check_action(["idea", "list"]) is True
|
||
assert _check_action(["idea", "list", "--limit", "50"]) is True
|