DataFed icon indicating copy to clipboard operation
DataFed copied to clipboard

[DAPS-1724] - feature python client support task and direct response allocation create

Open JoshuaSBrown opened this issue 2 months ago • 1 comments

Ticket

#1724

Description

How Has This Been Tested?

Artifacts (if appropriate):

Tasks

  • [ ] - A description of the PR has been provided, and a diagram included if it is a new feature.
  • [ ] - Formatter has been run
  • [ ] - CHANGELOG comment has been added
  • [ ] - Labels have been assigned to the pr
  • [ ] - A reviwer has been added
  • [ ] - A user has been assigned to work on the pr
  • [ ] - If new feature a unit test has been added

Summary by Sourcery

Add end-to-end support for authentication and repository creation in the mock core server and Python client, integrate mock core server into the build and CI pipelines, and add Python integration tests.

New Features:

  • Implement handlers for AuthenticateByPasswordRequest, AuthenticateByTokenRequest, GetAuthStatusRequest, and RepoCreateRequest in the mock core server
  • Expose manualAuthByPassword, manualAuthByToken, getAuthStatus, and repoCreate operations in the Python client

Enhancements:

  • Pre-populate session authentication keys and add detailed logging in AuthenticationManager
  • Centralize mock constants (credentials, tokens, repository metadata) in MockGlobals

Build:

  • Add BUILD_MOCK_CORE_SERVER option and integrate mock core server into CMake build and install targets
  • Include Dockerfile and install scripts for building and running the mock core server

CI:

  • Add GitLab CI jobs for building, image checking, and retagging the core-mock Docker image

Tests:

  • Add Python pytest-based integration tests for MessageLib and CommandLib
  • Include CMake support for running Python integration tests and update mock server test fixtures

Chores:

  • Rename mock core key files from mock-datafed-core-key to datafed-mock-core-key across scripts and code

JoshuaSBrown avatar Nov 05 '25 21:11 JoshuaSBrown

Reviewer's Guide

This PR extends the mock core server to handle password/token authentication and repo creation messages, integrates the mock core build into CMake and GitLab CI, adds Docker support, and introduces Python client integration tests for MessageLib and CommandLib.

Class diagram for updated mock core server authentication and repo creation

classDiagram
    class MockCoreServer {
        +handlePasswordAuth()
        +handleTokenAuth()
        +handleRepoCreate()
    }
    class AuthenticationManager {
        +verifyPassword()
        +verifyToken()
    }
    class ClientWorker {
        +processMessage()
        +processRepoCreate()
    }
    MockCoreServer --> AuthenticationManager : uses
    MockCoreServer --> ClientWorker : uses

File-Level Changes

Change Details Files
Extend mock core server with new message handlers and implementations
  • Injected IMockCoreServer reference in ClientWorker
  • Registered handlers for AuthenticateByPassword, AuthenticateByToken, GetAuthStatus, RepoCreate
  • Implemented procAuthenticateByPasswordRequest, procAuthenticateByTokenRequest, procGetAuthStatusRequest, procRepoCreate
  • Seeded AuthenticationManager with a session key and added logging for key lookup
tests/mock_core/source/ClientWorker.cpp
tests/mock_core/source/ClientWorker.hpp
tests/mock_core/source/AuthenticationManager.cpp
tests/mock_core/source/AuthenticationManager.hpp
tests/mock_core/source/MockGlobals.cpp
tests/mock_core/source/MockGlobals.hpp
Update CMake to build and install mock core server
  • Added BUILD_MOCK_CORE_SERVER option and conditional inclusion of mock_core
  • Configured CMakeLists in root, tests, and python package for integration tests
  • Set INSTALL_MOCK_CORE_SERVER variable
CMakeLists.txt
tests/CMakeLists.txt
python/datafed_pkg/CMakeLists.txt
Add GitLab CI jobs for mock core build and image checks
  • Introduced run-core-mock-build-job in stage_build.yml
  • Added check-core-mock-image in stage_image_check.yml
  • Added build_core_mock_image.yml and force_build_core_mock_image.yml under .gitlab/build
.gitlab/stage_build.yml
.gitlab/stage_image_check.yml
.gitlab/build/build_core_mock_image.yml
.gitlab/build/force_build_core_mock_image.yml
Provide Docker support and install scripts for mock core server
  • Created Dockerfile under tests/mock_core/docker to build mock-core image
  • Added entrypoint.sh for container startup logic
  • Added install_mock_core.sh to move and generate keys
tests/mock_core/docker/Dockerfile
tests/mock_core/docker/entrypoint.sh
scripts/install_mock_core.sh
Introduce Python integration tests for the Python client
  • Added test_MessageLib.py and test_CommandLib.py for API integration tests
  • Created mock_defaults.py to supply consistent test values
  • Added CMakeLists.txt for Python integration tests under tests/integration
python/datafed_pkg/tests/integration/test_MessageLib.py
python/datafed_pkg/tests/integration/test_CommandLib.py
python/datafed_pkg/tests/integration/mock_defaults.py
python/datafed_pkg/tests/integration/CMakeLists.txt

Possibly linked issues

  • #1724: PR implements Python client support for task and direct response on allocation creation, adding new client authentication and repo creation integration tests.
  • #[Refactor] - Core Mock move to root /tests folder mock core is useful for python client as well: The PR moves the mock core to /tests/mock_core/source and introduces Python client integration tests that utilize the refactored mock core.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Nov 05 '25 21:11 sourcery-ai[bot]