Skip to content

Conversation

@enriquesanchez-elastic
Copy link
Contributor

Summary

Fixes a 401 authentication error occurring in the AI Assistant shared conversations Cypress test when running in serverless environments.

Problem

The test was failing during the before hook with a 401 Unauthorized error when attempting to logout using the logout() function. This was specifically happening in serverless environments where the authentication flow differs from ESS.

Solution

Replace logout() with cy.clearCookies() in the before hook. This approach:

  • Is already used successfully throughout the rest of the test file
  • Is the established pattern for user switching in Cypress tests
  • Works correctly in both ESS and serverless environments

Changes

  • x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/ai_assistant/shared_conversations.cy.ts: Replace logout() call with cy.clearCookies() in line 93

Testing

  • Verified the change follows the existing pattern in the same test file
  • Confirmed cy.clearCookies() is used in lines 175, 209, 233, 258 for user switching

Related Issues

Resolves authentication failures in serverless environments for the AI Assistant shared conversations test suite.

…Cypress test

Replace logout() with cy.clearCookies() in the before hook to fix 401 authentication
errors when running tests in serverless environments. The logout() function causes
authentication failures in serverless due to different session handling, while
cy.clearCookies() is the established pattern used throughout the rest of the test.
@enriquesanchez-elastic enriquesanchez-elastic requested a review from a team as a code owner September 12, 2025 14:54
@enriquesanchez-elastic enriquesanchez-elastic added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI labels Sep 12, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for the quick fix!! You rock 🎸

@enriquesanchez-elastic enriquesanchez-elastic enabled auto-merge (squash) September 12, 2025 15:03
@enriquesanchez-elastic enriquesanchez-elastic merged commit 917bfe6 into main Sep 12, 2025
12 checks passed
@enriquesanchez-elastic enriquesanchez-elastic deleted the fix-ai-assistant-cypress-auth-serverless branch September 12, 2025 17:46
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Saved Objects .kibana field count

Every field in each saved object type adds overhead to Elasticsearch. Kibana needs to keep the total field count below Elasticsearch's default limit of 1000 fields. Only specify field mappings for the fields you wish to search on or query. See https://www.elastic.co/guide/en/kibana/master/saved-objects-service.html#_mappings

id before after diff
_data_stream_timestamp 1 - -1
_doc_count 1 - -1
_ignored_source 1 - -1
_index_mode 1 - -1
_inference_fields 1 - -1
_tier 1 - -1
apm-custom-dashboards 5 - -5
apm-server-schema 2 - -2
apm-service-group 5 - -5
application_usage_daily 2 - -2
config 2 - -2
config-global 2 - -2
coreMigrationVersion 1 - -1
created_at 1 - -1
created_by 1 - -1
entity-definition 9 - -9
entity-discovery-api-key 2 - -2
event_loop_delays_daily 2 - -2
favorites 4 - -4
file 11 - -11
file-upload-usage-collection-telemetry 3 - -3
fileShare 5 - -5
infra-custom-dashboards 4 - -4
infrastructure-monitoring-log-view 2 - -2
intercept_trigger_record 5 - -5
legacy-url-alias 7 - -7
managed 1 - -1
ml-job 6 - -6
ml-module 13 - -13
ml-trained-model 7 - -7
monitoring-telemetry 2 - -2
namespace 1 - -1
namespaces 1 - -1
observability-onboarding-state 2 - -2
originId 1 - -1
product-doc-install-status 7 - -7
references 4 - -4
sample-data-telemetry 3 - -3
security-ai-prompt 8 - -8
slo 11 - -11
space 5 - -5
synthetics-monitor 34 - -34
synthetics-monitor-multi-space 34 - -34
tag 4 - -4
type 1 - -1
typeMigrationVersion 1 - -1
ui-metric 2 - -2
updated_at 1 - -1
updated_by 1 - -1
upgrade-assistant-ml-upgrade-operation 3 - -3
upgrade-assistant-reindex-operation 3 - -3
uptime-synthetics-api-key 2 - -2
url 5 - -5
usage-counters 2 - -2
total -246

cc @enriquesanchez-elastic

KodeRad pushed a commit to KodeRad/kibana that referenced this pull request Sep 15, 2025
…Cypress test (elastic#234932)

## Summary

Fixes a 401 authentication error occurring in the AI Assistant shared
conversations Cypress test when running in serverless environments.

### Problem
The test was failing during the `before` hook with a 401 Unauthorized
error when attempting to logout using the `logout()` function. This was
specifically happening in serverless environments where the
authentication flow differs from ESS.

### Solution
Replace `logout()` with `cy.clearCookies()` in the before hook. This
approach:
- Is already used successfully throughout the rest of the test file
- Is the established pattern for user switching in Cypress tests
- Works correctly in both ESS and serverless environments

### Changes
-
`x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/ai_assistant/shared_conversations.cy.ts`:
Replace `logout()` call with `cy.clearCookies()` in line 93

### Testing
- [x] Verified the change follows the existing pattern in the same test
file
- [x] Confirmed `cy.clearCookies()` is used in lines 175, 209, 233, 258
for user switching

### Related Issues
Resolves authentication failures in serverless environments for the AI
Assistant shared conversations test suite.
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Sep 24, 2025
…Cypress test (elastic#234932)

## Summary

Fixes a 401 authentication error occurring in the AI Assistant shared
conversations Cypress test when running in serverless environments.

### Problem
The test was failing during the `before` hook with a 401 Unauthorized
error when attempting to logout using the `logout()` function. This was
specifically happening in serverless environments where the
authentication flow differs from ESS.

### Solution
Replace `logout()` with `cy.clearCookies()` in the before hook. This
approach:
- Is already used successfully throughout the rest of the test file
- Is the established pattern for user switching in Cypress tests
- Works correctly in both ESS and serverless environments

### Changes
-
`x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/ai_assistant/shared_conversations.cy.ts`:
Replace `logout()` call with `cy.clearCookies()` in line 93

### Testing
- [x] Verified the change follows the existing pattern in the same test
file
- [x] Confirmed `cy.clearCookies()` is used in lines 175, 209, 233, 258
for user switching

### Related Issues
Resolves authentication failures in serverless environments for the AI
Assistant shared conversations test suite.
niros1 pushed a commit that referenced this pull request Sep 30, 2025
…Cypress test (#234932)

## Summary

Fixes a 401 authentication error occurring in the AI Assistant shared
conversations Cypress test when running in serverless environments.

### Problem
The test was failing during the `before` hook with a 401 Unauthorized
error when attempting to logout using the `logout()` function. This was
specifically happening in serverless environments where the
authentication flow differs from ESS.

### Solution
Replace `logout()` with `cy.clearCookies()` in the before hook. This
approach:
- Is already used successfully throughout the rest of the test file
- Is the established pattern for user switching in Cypress tests
- Works correctly in both ESS and serverless environments

### Changes
-
`x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/ai_assistant/shared_conversations.cy.ts`:
Replace `logout()` call with `cy.clearCookies()` in line 93

### Testing
- [x] Verified the change follows the existing pattern in the same test
file
- [x] Confirmed `cy.clearCookies()` is used in lines 175, 209, 233, 258
for user switching

### Related Issues
Resolves authentication failures in serverless environments for the AI
Assistant shared conversations test suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants