Skip to content

Conversation

@major
Copy link
Contributor

@major major commented Jan 22, 2026

Description

Add comprehensive end-to-end tests for the rh-identity authentication module. These tests cover all validation paths in src/authentication/rh_identity.py, ensuring proper error handling for malformed headers, missing fields, and entitlement validation.

Test Scenarios (17 total)

Header-level validation:

  • Missing x-rh-identity header (401)
  • Invalid base64 encoding (400)
  • Invalid JSON content (400)

Identity structure validation:

  • Missing identity field (400)
  • Null identity field (400)
  • Missing identity type field (400)
  • Unsupported identity type (400)

User identity validation:

  • Missing user field (400)
  • Missing user_id (400)
  • Missing username (400)

System identity validation:

  • Missing system field (400)
  • Missing cn (400)
  • Missing account_number (400)

Entitlement validation:

  • Missing required entitlement (403)
  • Empty entitlements (403)
  • Entitlement with is_entitled=false (403)

Success cases:

  • Valid User identity with required entitlements (200)
  • Valid System identity with required entitlements (200)

Type of change

  • End to end tests improvement

Tools used to create PR

  • Assisted-by: Claude (Anthropic)
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue # N/A
  • Closes # N/A

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  1. Run the e2e tests with rh-identity feature:

    uv run behave tests/e2e/features/authorized_rh_identity.feature
  2. Or run all e2e tests:

    uv run make test-e2e
  3. All 17 scenarios should pass, validating each error path and success case in the rh-identity authentication module.

Summary by CodeRabbit

  • Tests
    • Added comprehensive end-to-end coverage for RH Identity authentication: header validation, identity field checks, entitlement scenarios, and positive/negative flows.
  • Chores
    • Added mode-specific test configurations and test harness support to enable RH Identity scenarios and include the new feature in test runs.

✏️ Tip: You can customize this high-level summary in your review settings.

major added 4 commits January 22, 2026 16:47
Add configuration files for e2e testing with rh-identity authentication
module enabled for both server-mode and library-mode deployments.

Both configs require the 'rhel' entitlement for validation testing.

Signed-off-by: Major Hayden <major@redhat.com>
Add step definitions to set x-rh-identity headers in various formats:
- Raw string values (for invalid base64 testing)
- Base64-encoded raw strings (for invalid JSON testing)
- Base64-encoded JSON objects
- Valid User identity with configurable fields
- Valid System identity with configurable fields

Includes helper function to encode identity data to base64.

Signed-off-by: Major Hayden <major@redhat.com>
Register @RHIdentity tag in before_feature and after_feature hooks to
switch configuration to rh-identity auth mode during feature execution
and restore the original configuration afterwards.

Signed-off-by: Major Hayden <major@redhat.com>
Add comprehensive e2e test scenarios covering all validation paths in
the rh-identity authentication module:

- Missing x-rh-identity header (401)
- Invalid base64 encoding (400)
- Invalid JSON content (400)
- Missing/null identity field (400)
- Missing identity type field (400)
- Unsupported identity type (400)
- User identity: missing user field (400)
- User identity: missing user_id (400)
- User identity: missing username (400)
- System identity: missing system field (400)
- System identity: missing cn (400)
- System identity: missing account_number (400)
- Missing required entitlements (403)
- Empty entitlements (403)
- Entitlement with is_entitled=false (403)
- Valid User identity with entitlements (200)
- Valid System identity with entitlements (200)

Signed-off-by: Major Hayden <major@redhat.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

Walkthrough

Adds end-to-end RH Identity authentication tests and mode-specific configs, plus test harness hooks and step implementations to set and validate x-rh-identity headers across many scenarios.

Changes

Cohort / File(s) Summary
Configuration Files
tests/e2e/configuration/library-mode/lightspeed-stack-auth-rh-identity.yaml, tests/e2e/configuration/server-mode/lightspeed-stack-auth-rh-identity.yaml
New mode-specific LCS YAML configs enabling RH Identity auth, auth settings, logging, user-data collection, SQLite conversation cache, and required entitlements.
Feature Test Definition
tests/e2e/features/authorized_rh_identity.feature
New Gherkin feature (~293 lines) with numerous scenarios covering missing/invalid/malformed x-rh-identity headers, User/System identity success cases, and entitlement-related failures.
Test Environment Setup
tests/e2e/features/environment.py
Adds RHIdentity feature-tag hooks that back up current config, apply mode-specific RH Identity config, restart lightspeed-stack, and restore afterwards.
Test Step Implementations
tests/e2e/features/steps/auth.py
Adds _encode_rh_identity helper and multiple new steps to set/remove x-rh-identity in raw/base64/JSON/User/System forms and to remove Authorization header.
Test Registry
tests/e2e/test_list.txt
Registers the new feature file in the E2E test list.

Sequence Diagram(s)

(omitted — changes are test/config additions and do not introduce new multi-component runtime control flow requiring visualization)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested labels

ok-to-test

Suggested reviewers

  • tisnik
  • radofuchs
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding comprehensive end-to-end tests for rh-identity authentication.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

…y tests

The behave step 'body of the response contains {substring}' captures
the literal text after 'contains', including any quotes. The test
assertions were failing because they searched for quoted substrings
like '"Invalid base64 encoding"' instead of unquoted text that
actually exists in the JSON response body.

Fixes 6 failing test scenarios:
- Invalid base64 encoding detection
- Invalid JSON detection
- Unsupported identity type detection
- Missing required entitlement detection (3 scenarios)

Signed-off-by: Major Hayden <major@redhat.com>
@tisnik tisnik requested a review from radofuchs January 23, 2026 14:16
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.

1 participant