Skip to content

fix: replace removed Cypress.Cookies API in proxy auth setup with cy.session - #2096

Merged
SuZhou-Joe merged 1 commit into
opensearch-project:mainfrom
sejli:remove-cookies
Jul 17, 2026
Merged

fix: replace removed Cypress.Cookies API in proxy auth setup with cy.session#2096
SuZhou-Joe merged 1 commit into
opensearch-project:mainfrom
sejli:remove-cookies

Conversation

@sejli

@sejli sejli commented Jul 17, 2026

Copy link
Copy Markdown
Member

Description

Replaces Cypress.Cookies API since 'Cypress.Cookies.preserveOnce() was removed in Cypress version 12.0.0.

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…session

Signed-off-by: Sean Li <lnse@amazon.com>
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Validate and cache the login session

cy.session() by default clears cookies between tests, which may drop the
security_authentication cookie needed by the proxy. Pass a validate function and/or
cacheAcrossSpecs: true to ensure the session (including the auth cookie) is restored
reliably before each test.

cypress/support/index.js [66-72]

 if (Cypress.env('ENDPOINT_WITH_PROXY')) {
   beforeEach(() => {
-    cy.session('security_authentication', () => {
-      cy.login();
-    });
+    cy.session(
+      'security_authentication',
+      () => {
+        cy.login();
+      },
+      {
+        cacheAcrossSpecs: true,
+        validate() {
+          cy.getCookie('security_authentication').should('exist');
+        },
+      }
+    );
   });
 }
Suggestion importance[1-10]: 7

__

Why: Adding a validate function and cacheAcrossSpecs: true to cy.session() is a reasonable improvement to ensure the auth cookie is reliably restored across tests and specs, which is relevant given the removal of Cypress.Cookies.preserveOnce(). This addresses potential session reliability issues.

Medium

@SuZhou-Joe SuZhou-Joe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@SuZhou-Joe
SuZhou-Joe merged commit 7f99330 into opensearch-project:main Jul 17, 2026
67 checks passed
sejli added a commit that referenced this pull request Jul 17, 2026
…session (#2096) (#2097)

(cherry picked from commit 7f99330)

Signed-off-by: Sean Li <lnse@amazon.com>
Signed-off-by: opensearch-ci-bot <opensearch-infra@amazon.com>
Co-authored-by: Sean Li <lnse@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants