Skip to content

Feat(provisioning): add occ commands - #13670

Draft
hamza221 wants to merge 1 commit into
mainfrom
feat/occ-provisioning
Draft

Feat(provisioning): add occ commands#13670
hamza221 wants to merge 1 commit into
mainfrom
feat/occ-provisioning

Conversation

@hamza221

@hamza221 hamza221 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Assisted-by: ClaudeCode:claude-opus-5

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Summary by CodeRabbit

  • New Features
    • Added console commands to create, update, list, delete, and apply mail account provisioning configurations.
    • Provisioning listings support table and JSON output.
    • Deletion supports confirmation prompts and a force option.
    • Added validation and interactive or standard-input handling for provisioning settings and passwords.
  • Tests
    • Added comprehensive coverage for provisioning workflows, validation, error handling, and output formats.

Assisted-by: ClaudeCode:claude-opus-5

Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
@hamza221 hamza221 self-assigned this Sep 11, 2026
@hamza221 hamza221 added enhancement 2. developing skill:backend Issues and PRs that require backend development skills feature: provisioning AI assisted This PR contains AI-assisted commits labels Sep 11, 2026
@hamza221

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

Added five provisioning console commands for creating, updating, listing, applying, and deleting configurations. Shared option handling validates connection settings, feature toggles, ports, SSL modes, and master-password input. Unit tests cover command flows and validation.

Changes

Provisioning option handling

Layer / File(s) Summary
Shared option parsing and validation
lib/Command/ProvisioningOptions.php, tests/Unit/Command/CreateProvisioningTest.php, tests/Unit/Command/UpdateProvisioningTest.php
Shared options build provisioning data and validate ports, SSL modes, Sieve settings, LDAP aliases, and master-password input.

Create and update commands

Layer / File(s) Summary
Create provisioning flow
lib/Command/CreateProvisioning.php, tests/Unit/Command/CreateProvisioningTest.php
The create command builds configuration data, calls newProvisioning(), reports validation errors, and prints the new ID.
Update provisioning flow
lib/Command/UpdateProvisioning.php, tests/Unit/Command/UpdateProvisioningTest.php
The update command validates the ID, loads the existing configuration, applies validated changes, and reports lookup or validation errors.

Operational commands

Layer / File(s) Summary
Provisioning operations and registration
lib/Command/DeleteProvisioning.php, lib/Command/ListProvisionings.php, lib/Command/ProvisionAccounts.php, appinfo/info.xml, tests/Unit/Command/DeleteProvisioningTest.php, tests/Unit/Command/ListProvisioningsTest.php, tests/Unit/Command/ProvisionAccountsTest.php
Added deletion with confirmation, table or JSON listing, account application, command registration, and unit-test coverage for each flow.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: christophwurst

Sequence Diagram(s)

sequenceDiagram
  participant ConsoleCommand
  participant ProvisioningOptions
  participant ProvisioningManager
  ConsoleCommand->>ProvisioningOptions: Build provisioning data
  ProvisioningOptions-->>ConsoleCommand: Return validated data
  ConsoleCommand->>ProvisioningManager: Create provisioning
  ProvisioningManager-->>ConsoleCommand: Return ID or validation error
Loading

Merge Risk: 🟠 High · up to d07c3

The new mail provisioning console commands rely on shared option code that cannot be loaded on one of the supported PHP versions, so administrators on that version would see the commands fail outright. In addition, the master password can be supplied directly on the command line, where it can be observed by other local processes. Both should be addressed before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 13.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 68 functions across 11 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding OCC commands for provisioning. It is concise and related to the changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 13.24% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 68 functions across 11 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/occ-provisioning

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 8391b4e6-03d5-4205-a290-3de3282de7b6

📥 Commits

Reviewing files that changed from the base of the PR and between f046085 and d07c334.

📒 Files selected for processing (12)
  • appinfo/info.xml
  • lib/Command/CreateProvisioning.php
  • lib/Command/DeleteProvisioning.php
  • lib/Command/ListProvisionings.php
  • lib/Command/ProvisionAccounts.php
  • lib/Command/ProvisioningOptions.php
  • lib/Command/UpdateProvisioning.php
  • tests/Unit/Command/CreateProvisioningTest.php
  • tests/Unit/Command/DeleteProvisioningTest.php
  • tests/Unit/Command/ListProvisioningsTest.php
  • tests/Unit/Command/ProvisionAccountsTest.php
  • tests/Unit/Command/UpdateProvisioningTest.php

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

* @psalm-type ProvisioningData = array<string, mixed>
*/
trait ProvisioningOptions {
private const SSL_MODES = ['none', 'ssl', 'tls'];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🔎 Supported by static analysis

🤖 get_repo_knowledge executed:

get_repo_knowledge nextcloud/mail /tmp/coderabbit-repo-knowledge/nextcloud-mail-16433369/conventions

Length of output: 1694


🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- changed file ---'
git diff -- lib/Command/ProvisioningOptions.php
printf '%s\n' '--- file outline ---'
ast-grep outline lib/Command/ProvisioningOptions.php
printf '%s\n' '--- relevant source ---'
sed -n '1,190p' lib/Command/ProvisioningOptions.php
printf '%s\n' '--- PHP version declarations and CI references ---'
rg -n --glob '!vendor/**' --glob '!node_modules/**' 'PHP_VERSION|php-version|php:|PHP 8\.1|8\.1|ProvisioningOptions|master-password' .github composer.json lib tests 2>/dev/null | head -200

Repository: nextcloud/mail

Length of output: 13054


Remove trait constants to restore PHP 8.1 compatibility.

The project supports PHP 8.1 and runs PHP 8.1 checks. PHP 8.1 does not support trait constants, so loading ProvisioningOptions causes a parse error. Move the constants on Lines 25–50 to a class and reference them from the trait, or replace them with PHP 8.1-compatible methods or local values.

🧰 Tools
🪛 GitHub Actions: Lint php / 2_php-lint (8.1).txt

[error] 25-25: PHP syntax lint failed: Traits cannot have constants. The command 'composer run lint' reported a fatal error while parsing this file.

🪛 GitHub Actions: Lint php / php-lint (8.1)

[error] 25-25: PHP syntax lint failed: Traits cannot have constants. Command 'composer run lint' reported a fatal error while parsing this file.


[error] 25-25: The lint step aborted with exit code 124 after PHP exited with status 255 while parsing the trait.

🪛 GitHub Actions: Static analysis / 1_static-psalm-analysis dev-stable34.txt

[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. The 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' command failed.

🪛 GitHub Actions: Static analysis / 2_static-psalm-analysis dev-stable32.txt

[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github'.

🪛 GitHub Actions: Static analysis / 3_static-psalm-analysis dev-stable35.txt

[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. The command 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' failed with exit code 2.

🪛 GitHub Actions: Static analysis / 4_static-psalm-analysis dev-master.txt

[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github'.

🪛 GitHub Actions: Static analysis / 5_static-psalm-analysis dev-stable33.txt

[error] 25-25: Psalm failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github': ConstantDeclarationInTrait. Traits cannot declare constants until PHP 8.2.0.

🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-master

[error] 25-25: Psalm reported ConstantDeclarationInTrait: traits cannot declare constants until PHP 8.2.0. Command 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' failed.

🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable32

[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command failed during 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github'.

🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable33

[error] 25-25: Psalm (composer run psalm) reported ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0.

🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable34

[error] 25-25: Psalm (ConstantDeclarationInTrait): Traits cannot declare constants until PHP 8.2.0. Command failed: composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github.

🪛 GitHub Actions: Static analysis / static-psalm-analysis dev-stable35

[error] 25-25: Psalm ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0. Command 'composer run psalm -- --threads=1 --monochrome --no-progress --output-format=github' failed with exit code 2.

🪛 GitHub Check: static-psalm-analysis dev-master

[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)

🪛 GitHub Check: static-psalm-analysis dev-stable32

[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)

🪛 GitHub Check: static-psalm-analysis dev-stable33

[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)

🪛 GitHub Check: static-psalm-analysis dev-stable34

[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)

🪛 GitHub Check: static-psalm-analysis dev-stable35

[failure] 25-25: ConstantDeclarationInTrait
lib/Command/ProvisioningOptions.php:25:2: ConstantDeclarationInTrait: Traits cannot declare constants until PHP 8.2.0 (see https://psalm.dev/315)

Sources: Linters/SAST tools, Pipeline failures

Comment on lines +72 to +73
InputOption::VALUE_OPTIONAL,
'Master password used for all accounts instead of the login password. Pass without a value to read it from stdin',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🛡️ Analyzed with Security Review | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu
printf '%s\n' '--- ProvisioningOptions.php outline ---'
ast-grep outline lib/Command/ProvisioningOptions.php
printf '%s\n' '--- ProvisioningOptions.php relevant sections ---'
cat -n lib/Command/ProvisioningOptions.php | sed -n '1,180p'
printf '%s\n' '--- direct references to master-password handling ---'
rg -n -C 4 -- '--master-password|OPTION_MASTER_PASSWORD|masterPassword|MASTER_PASSWORD' lib tests | head -240

Repository: nextcloud/mail

Length of output: 24484


Sensitive Data Exposure

Reachability: External
Exploitability: Moderate
CWE: CWE-214

Do not accept the master password as an option value.

InputOption::VALUE_OPTIONAL allows --master-password=<secret>, which exposes the secret through the process argument list. Accept only --master-password without a value, then read the password through the existing hidden prompt or stdin path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2. developing AI assisted This PR contains AI-assisted commits enhancement feature: provisioning skill:backend Issues and PRs that require backend development skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant