Skip to content
Open
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
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ markers = [
"config_hygiene: checks of VIP's own configuration (opt-in; excluded by default)",
"min_version(product, version): only run when product meets minimum version",
"if_applicable: test is skipped when the feature is not configured",
"api_auth: test requires only an API key, not browser credentials",
]

[tool.semantic_release]
Expand Down
1 change: 1 addition & 0 deletions selftests/test_cli_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def _make_args(**overrides) -> argparse.Namespace:
"report": "report/results.json",
"interactive_auth": False,
"no_auth": False,
"api_auth": False,
"extensions": [],
"categories": None,
"filter_expr": None,
Expand Down
18 changes: 17 additions & 1 deletion src/vip/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,18 @@ def _run_verify_local(args: argparse.Namespace) -> None:
)
sys.exit(1)

if args.no_auth and args.api_auth:
print(
"\033[1mError: --no-auth and --api-auth are mutually exclusive.\033[0m",
file=sys.stderr,
flush=True,
)
sys.exit(1)

# Print notes for products that are not configured so the user knows
# upfront which categories will be skipped.
_print_skip_notes(config_path)
if not args.no_auth:
if not args.no_auth and not args.api_auth:
_check_credentials(
config_path,
interactive_auth=args.interactive_auth or args.headless_auth,
Expand Down Expand Up @@ -552,6 +560,8 @@ def _run_verify_local(args: argparse.Namespace) -> None:
cmd.append("--headless-auth")
if args.no_auth:
cmd.append("--no-auth")
if args.api_auth:
cmd.append("--api-auth")
for ext in args.extensions or []:
cmd.append(f"--vip-extensions={ext}")
if args.categories:
Expand Down Expand Up @@ -1063,6 +1073,12 @@ def main() -> None:
default=False,
help="Skip all tests that require authentication (Connect and Workbench)",
)
verify_parser.add_argument(
"--api-auth",
action="store_true",
default=False,
help="Run only API-key-authenticated tests; skip tests requiring browser credentials",
)

# Test selection
verify_parser.add_argument(
Expand Down
19 changes: 19 additions & 0 deletions src/vip/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ def pytest_addoption(parser: pytest.Parser) -> None:
default=False,
help="Skip all tests that require authentication credentials (Connect and Workbench).",
)
group.addoption(
"--api-auth",
action="store_true",
default=False,
help="Run only API-key-authenticated tests; skip tests that require browser credentials.",
)
group.addoption(
"--vip-verbose",
action="store_true",
Expand Down Expand Up @@ -148,6 +154,10 @@ def pytest_configure(config: pytest.Config) -> None:
"markers",
"if_applicable: skip when the related feature is not configured",
)
config.addinivalue_line(
"markers",
"api_auth: test requires only an API key, not browser credentials",
)

# In concise mode, suppress the "short test summary info" section — the
# inline concise error messages make it redundant.
Expand Down Expand Up @@ -310,6 +320,7 @@ def pytest_collection_modifyitems(
version requirement is not met, and ensure prerequisites run first."""
vip_cfg: VIPConfig = config.stash[_vip_config_key]
no_auth = config.getoption("--no-auth", default=False)
api_auth = config.getoption("--api-auth", default=False)

# Sort so prerequisites run before everything else, and assign xdist
# groups so that each product's tests land on a dedicated worker.
Expand All @@ -325,6 +336,9 @@ def pytest_collection_modifyitems(
if no_auth and _requires_auth(item):
deselected.append(item)
continue
if api_auth and _requires_auth(item) and not _is_api_auth_only(item):
deselected.append(item)
continue
_maybe_skip_for_version(item, vip_cfg)
_assign_xdist_group(item)
_stash_scenario_metadata(item)
Expand Down Expand Up @@ -454,6 +468,11 @@ def _requires_auth(item: pytest.Item) -> bool:
return False


def _is_api_auth_only(item: pytest.Item) -> bool:
"""Return True if *item* is marked as requiring only API-key authentication."""
return item.get_closest_marker("api_auth") is not None


def _maybe_skip_for_version(item: pytest.Item, cfg: VIPConfig) -> None:
marker = item.get_closest_marker("min_version")
if marker is None:
Expand Down
1 change: 1 addition & 0 deletions src/vip_tests/connect/test_auth.feature
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Feature: Connect authentication
Then the user is successfully authenticated
And the Connect dashboard is displayed

@api_auth
Scenario: API key authentication works
Given Connect is accessible at the configured URL
And a valid API key is configured
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_content_deploy.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect
@connect @api_auth
Feature: Connect content deployment
As a Posit Team administrator
I want to verify that content can be deployed and executed
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_data_sources.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect @if_applicable
@connect @if_applicable @api_auth
Feature: Connect external data sources
As a Posit Team administrator
I want to verify that external data sources connect and function
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_email.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect @if_applicable
@connect @if_applicable @api_auth
Feature: Connect email delivery
As a Posit Team administrator
I want to verify that Connect can send emails
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_packages.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect
@connect @api_auth
Feature: Connect package installation source
As a Posit Team administrator
I want to verify that Connect installs packages from the correct source
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_runtime_versions.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect
@connect @api_auth
Feature: Connect R and Python versions
As a Posit Team administrator
I want to verify that the expected R and Python versions are available
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_system_checks.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect
@connect @api_auth
Feature: Connect system checks
As a Posit Team administrator
I want to run the Connect system diagnostics
Expand Down
2 changes: 1 addition & 1 deletion src/vip_tests/connect/test_users.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@connect
@connect @api_auth
Feature: Connect user management
As a Posit Team administrator
I want to verify that user and group management APIs are functional
Expand Down
Loading
Loading