Skip to content

test(auth-app): cover custom labels of app tokens and document the label parameter - #4114

Merged
asaah262 merged 1 commit into
opencloud-eu:mainfrom
asaah262:test/861-auth-app-token-label
Nov 25, 2026
Merged

asaah262 merged 1 commit into
opencloud-eu:mainfrom
asaah262:test/861-auth-app-token-label

Conversation

@asaah262

Copy link
Copy Markdown
Contributor

Description

POST /auth-app/tokens accepts an optional label query parameter: without it the label is Generated via API, and tokens created through impersonation always get (Impersonation) appended, also to a custom label. Neither the README nor any test covered this. This PR adds:

  • Unit tests (TestHandleCreateLabel in services/auth-app/pkg/service/service_test.go): no label, an empty label, a custom label, a unicode label, impersonation without a label, and impersonation with a custom label (WebDAV sync (Impersonation)). Each case checks the label passed to the gateway and the one in the response.
  • Acceptance tests (apiAuthApp/token.feature): a user creates a token with a custom label, and an admin creates one with a custom label for another user. Two new steps in AuthAppContext.php.
  • README of the auth-app service: documents the label parameter, its default and the (Impersonation) suffix. It also fixes the list example, which showed a label (Generated via Impersonation API) the service never produces.

No change to the service code.

Related Issue

  • None

Motivation and Context

The web client already sends a label when a user creates an app token, and shows it in the token list. Without tests, a change that drops the label or the (Impersonation) suffix would go unnoticed. API users had no documentation of the parameter.

How Has This Been Tested?

  • Test environment: macOS, Go tests.
  • go test -race ./services/auth-app/... passes. The new tests pass as the behaviour already exists. To check that they catch regressions, I changed the handler locally (not part of this PR) to ignore label: the three custom-label cases fail. Changing it to drop the suffix on a custom label makes the impersonation case fail.
  • go vet ./services/auth-app/... reports nothing. gofmt and git diff --check are clean.
  • Not run locally: golangci-lint and the acceptance tests (the new scenarios run in CI).

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 added

AI assistance: Claude Code (claude-opus-5-5) wrote the first draft of the tests, the README changes and this description; I reviewed and adjusted them.

…bel parameter

Assisted-by: Claude Code:claude-opus-5-5
@codacy-production

codacy-production Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

🟢 Coverage ∅ diff coverage · +0.01% coverage variation

Metric Results
Coverage variation ✅ +0.01% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (0b73e9e) 95037 29280 30.81%
Head commit (05933a6) 95037 (+0) 29292 (+12) 30.82% (+0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4114) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@pbleser-oc pbleser-oc 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.

Thanks, looks good to me. Nice that the README example now shows the labels the code really produces.

@asaah262
asaah262 merged commit e7ddde8 into opencloud-eu:main Nov 25, 2026
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants