Skip to content

[tests-only][full-ci]test(cli): add clean-orphaned-grants CLI test scenarios#12470

Open
anon-pradip wants to merge 4 commits into
owncloud:masterfrom
anon-pradip:test/cli-test-to-clean-orphan-grants
Open

[tests-only][full-ci]test(cli): add clean-orphaned-grants CLI test scenarios#12470
anon-pradip wants to merge 4 commits into
owncloud:masterfrom
anon-pradip:test/cli-test-to-clean-orphan-grants

Conversation

@anon-pradip

@anon-pradip anon-pradip commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

Add acceptance tests for ocis shares clean-orphaned-grants CLI command.

Changes

New feature file

tests/acceptance/features/cliCommands/cleanOrphanedGrants.feature with 4 scenarios:

  • Run in non-dry-run mode
  • Run with space-id filter
  • Run with force flag
  • Run on a space with shares (no orphans expected)

New step definitions in CliContext.php

  • Given the administrator has configured service account credentials
  • When the administrator runs clean-orphaned-grants in non-dry-run mode
  • When the administrator runs clean-orphaned-grants for space :spaceName owned by :user
  • When the administrator runs clean-orphaned-grants with force flag

Related Issue

Motivation and Context

How Has This Been Tested?

  • test environment:
  • locally
  • ci

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@update-docs

update-docs Bot commented Jun 26, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@kw-security

kw-security commented Jun 26, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@anon-pradip anon-pradip changed the title [test-only]test(cli): add clean-orphaned-grants CLI test scenarios [tests-only][full-ci]test(cli): add clean-orphaned-grants CLI test scenarios Jun 26, 2026
@anon-pradip anon-pradip force-pushed the test/cli-test-to-clean-orphan-grants branch from 0529324 to 95f3f47 Compare June 29, 2026 07:06
@anon-pradip anon-pradip marked this pull request as ready for review June 29, 2026 08:34
@anon-pradip anon-pradip self-assigned this Jun 29, 2026

@DeepDiver1975 DeepDiver1975 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed as tests-only — looks good overall. The 4 scenarios build real ocis shares clean-orphaned-grants invocations (correct --service-account-id/secret, --space-id, --force, --dry-run=false flags) through CliHelper::runCommand, and every asserted output substring maps to an actual print statement in ocis/pkg/command/shares.go (pre-flight mode/scope/force lines, == Primary scan ==, Summary:, Orphans:/Reverse orphans: counts). The flag-specific assertions (scope: limiting scan to space, 1 target space(s), flags: --force active) keep the scenarios genuinely distinct and exercise different branches. No hard sleeps, no cross-scenario ordering deps, and the assertion steps (the command output should contain, the command should be successful) are the existing harness steps that decode the JSON response and assert on real stdout — not no-ops. CI is fully green, including the cliCommands acceptance job.

One observation (non-blocking): all scenarios assert Orphans: 0 candidate(s) / Reverse orphans: 0 candidate(s) and none set up a genuinely orphaned grant, so the count is effectively pinned at 0 in every path (incl. the "space with shares" case, where a legitimately-shared file correctly yields a non-orphan grant). These tests confirm the command runs, accepts its flags, scopes correctly, and reports cleanly on a healthy system, but they do not exercise the detection/removal path (count going N→0). A follow-up that orphans a grant and asserts it gets cleaned would strengthen coverage — but that requires corrupting share-manager state, so the current scope is reasonable for acceptance tests.

mergeable=MERGEABLE; the BLOCKED merge state is just the required-review gate.

🤖 Generated with Claude Code

@anon-pradip anon-pradip force-pushed the test/cli-test-to-clean-orphan-grants branch from 96bf6e2 to 3a9bb42 Compare June 30, 2026 04:16
@anon-pradip anon-pradip force-pushed the test/cli-test-to-clean-orphan-grants branch from 3a9bb42 to d62c1c1 Compare June 30, 2026 04:17
@anon-pradip anon-pradip force-pushed the test/cli-test-to-clean-orphan-grants branch from d62c1c1 to 7d558e8 Compare June 30, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QA] Add CLI test to clean orphaned grants

3 participants