-
Notifications
You must be signed in to change notification settings - Fork 91
test(e2e): add comprehensive e2e tests for rh-identity authentication #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
radofuchs
merged 4 commits into
lightspeed-core:main
from
major:e2e-rh-identity-auth-tests
Jan 27, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b215f11
test(e2e): add rh-identity auth configuration files
major 2e2c3b5
test(e2e): add step definitions for rh-identity header handling
major 3ade919
test(e2e): add RHIdentity feature tag handling
major 8ca8553
test(e2e): add rh-identity authentication test scenarios
major File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
tests/e2e/configuration/library-mode/lightspeed-stack-auth-rh-identity.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| name: Lightspeed Core Service (LCS) - RH Identity Auth | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: true | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| use_as_library_client: true | ||
| library_client_config_path: run.yaml | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| conversation_cache: | ||
| type: "sqlite" | ||
| sqlite: | ||
| db_path: "/tmp/data/conversation-cache.db" | ||
| authentication: | ||
| module: "rh-identity" | ||
| rh_identity_config: | ||
| required_entitlements: ["rhel"] |
25 changes: 25 additions & 0 deletions
25
tests/e2e/configuration/server-mode/lightspeed-stack-auth-rh-identity.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Lightspeed Core Service (LCS) - RH Identity Auth | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: true | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| use_as_library_client: false | ||
| url: http://llama-stack:8321 | ||
| api_key: xyzzy | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| conversation_cache: | ||
| type: "sqlite" | ||
| sqlite: | ||
| db_path: "/tmp/data/conversation-cache.db" | ||
| authentication: | ||
| module: "rh-identity" | ||
| rh_identity_config: | ||
| required_entitlements: ["rhel"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| @RHIdentity | ||
| Feature: Authorized endpoint API tests for the rh-identity authentication module | ||
|
|
||
| Background: | ||
| Given The service is started locally | ||
| And REST API service prefix is /v1 | ||
|
|
||
| Scenario: Request fails when x-rh-identity header is missing | ||
| Given The system is in default state | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 401 | ||
| And The body of the response is the following | ||
| """ | ||
| {"detail": "Missing x-rh-identity header"} | ||
| """ | ||
|
|
||
| Scenario: Request fails when identity field is missing | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with JSON | ||
| """ | ||
| {"entitlements": {"rhel": {"is_entitled": true}}} | ||
| """ | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 400 | ||
| And The body of the response contains Missing 'identity' field | ||
|
|
||
| Scenario: Request succeeds with valid User identity and required entitlements | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with valid User identity | ||
| | field | value | | ||
| | user_id | test-user-123 | | ||
| | username | testuser@redhat.com | | ||
| | org_id | 321 | | ||
| | entitlements | rhel | | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 200 | ||
| And The body of the response is the following | ||
| """ | ||
| {"user_id": "test-user-123", "username": "testuser@redhat.com", "skip_userid_check": false} | ||
| """ | ||
|
|
||
| Scenario: Request succeeds with valid System identity and required entitlements | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with valid System identity | ||
| | field | value | | ||
| | cn | c87dcb4c-8af1-40dd-878e-60c744edddd0 | | ||
| | account_number | 456 | | ||
| | org_id | 654 | | ||
| | entitlements | rhel | | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 200 | ||
| And The body of the response is the following | ||
| """ | ||
| {"user_id": "c87dcb4c-8af1-40dd-878e-60c744edddd0", "username": "456", "skip_userid_check": false} | ||
| """ | ||
|
|
||
| Scenario: Request fails when required entitlement is missing | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with valid User identity | ||
| | field | value | | ||
| | user_id | test-user-123 | | ||
| | username | testuser@redhat.com | | ||
| | org_id | 321 | | ||
| | entitlements | ansible | | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 403 | ||
| And The body of the response contains Missing required entitlement | ||
|
|
||
| Scenario: Request fails when entitlement exists but is_entitled is false | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with JSON | ||
| """ | ||
| { | ||
| "identity": { | ||
| "type": "User", | ||
| "org_id": "321", | ||
| "user": {"user_id": "test-user-123", "username": "testuser@redhat.com"} | ||
| }, | ||
| "entitlements": {"rhel": {"is_entitled": false, "is_trial": true}} | ||
| } | ||
| """ | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 403 | ||
| And The body of the response contains Missing required entitlement | ||
|
|
||
| Scenario: Request fails when User identity is missing user_id | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with JSON | ||
| """ | ||
| { | ||
| "identity": { | ||
| "type": "User", | ||
| "org_id": "321", | ||
| "user": {"username": "testuser@redhat.com"} | ||
| }, | ||
| "entitlements": {"rhel": {"is_entitled": true}} | ||
| } | ||
| """ | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 400 | ||
| And The body of the response contains Missing 'user_id' in user data | ||
|
|
||
| Scenario: Request fails when User identity is missing username | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with JSON | ||
| """ | ||
| { | ||
| "identity": { | ||
| "type": "User", | ||
| "org_id": "321", | ||
| "user": {"user_id": "test-user-123"} | ||
| }, | ||
| "entitlements": {"rhel": {"is_entitled": true}} | ||
| } | ||
| """ | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 400 | ||
| And The body of the response contains Missing 'username' in user data | ||
|
|
||
| Scenario: Request fails when System identity is missing cn | ||
| Given The system is in default state | ||
| And I set the x-rh-identity header with JSON | ||
| """ | ||
| { | ||
| "identity": { | ||
| "type": "System", | ||
| "account_number": "456", | ||
| "org_id": "654", | ||
| "system": {} | ||
| }, | ||
| "entitlements": {"rhel": {"is_entitled": true}} | ||
| } | ||
| """ | ||
| When I access endpoint "authorized" using HTTP POST method | ||
| """ | ||
| {"placeholder":"abc"} | ||
| """ | ||
| Then The status code of the response is 400 | ||
| And The body of the response contains Missing 'cn' in system data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.