Skip to content

ref: deduplicate creation of DCOR-dev users - #115

Merged
paulmueller merged 1 commit into
DCOR-dev:mainfrom
paulmueller-agent:ref-dev-user
Oct 22, 2026
Merged

paulmueller merged 1 commit into
DCOR-dev:mainfrom
paulmueller-agent:ref-dev-user

Conversation

@paulmueller-agent

Copy link
Copy Markdown
Contributor

Creating a user on DCOR-dev was implemented twice: in the setup wizard (gui/wizard_init.get_dcor_dev_api_key) and in the tests (tests/common.py, since #111). Both now use a new module dcoraid/api/users.py.

New functions (exported in dcoraid.api)

  • create_dcor_dev_user(server="dcor-dev.mpl.mpg.de", fullname=None, ssl_verify=True) -> str
    • Creates a user via user_create with with_apitoken=True and returns the API token.
    • The naming scheme is unchanged (dcoraid-xxxxx, …@dcor-dev.mpl.mpg.de), so the weekly purge keeps working.
    • The full name defaults to "Player xxxxx", as in the wizard before. The tests pass "DCOR-Aid Tester".
  • is_valid_api_key(server, api_key, ssl_verify=True) -> bool
    • Returns False for empty keys without contacting the server, and for APIAuthorizationError, APINotFoundError and NoAPIKeyError.

Users

  • get_dcor_dev_api_key() in the setup wizard shrinks to three lines.
  • tests/common.py drops its own is_valid_api_key and create_test_user.

The one behaviour difference: users created by the wizard get a full UUID as password instead of its first 8 characters. The password is never shown or used; the API token is what DCOR-Aid uses.

Tests

  • New tests/test_api_users.py:
    • offline tests with a mocked CKANAPI for the user_create payload, the default and custom full name, and invalid or empty keys
    • one server test of is_valid_api_key with a valid and a revoked-looking key. It doesn't create a user on every run.
  • End to end against dcor-dev, run locally:
    • With tests/api_key and tests/api_key_2 removed, the test session creates both users through the new function. test_api_users.py, test_dbmodel_api.py and test_dbmodel_api_cache.py pass (31 tests).
    • The wizard's get_dcor_dev_api_key() with empty settings creates a valid user ("Player 3ffb3").

🤖 Generated with Claude Code

Creating a user on DCOR-dev was implemented both in the setup wizard
(`get_dcor_dev_api_key`) and in the tests (`tests/common.py`). Move
it to `dcoraid.api.users` (`create_dcor_dev_user`) together with an
API key validity check (`is_valid_api_key`) and use these in both
places.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@paulmueller
paulmueller merged commit e3c5e6c into DCOR-dev:main Oct 22, 2026
0 of 3 checks passed
@paulmueller-agent
paulmueller-agent deleted the ref-dev-user branch October 23, 2026 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants