Skip to content

Commit ecd9636

Browse files
authored
Merge branch 'main' into upgrade-cypress
2 parents 45e724e + 600ab91 commit ecd9636

File tree

6 files changed

+130
-46
lines changed

6 files changed

+130
-46
lines changed

.github/actions/download-plugin/action.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
mvn dependency:get \
2626
-DremoteRepositories=https://aws.oss.sonatype.org/content/repositories/snapshots/ \
2727
-Dartifact=org.opensearch.plugin:${{ inputs.plugin-name }}:${{ inputs.plugin-version }}-SNAPSHOT:zip \
28-
-Dtransitive=false \
29-
-Ddest=${{ inputs.download-location }}.zip
28+
-Dtransitive=false
29+
cp ~/.m2/repository/org/opensearch/plugin/${{ inputs.plugin-name }}/${{ inputs.plugin-version }}-SNAPSHOT/${{ inputs.plugin-name }}-${{ inputs.plugin-version }}-SNAPSHOT.zip ${{ inputs.download-location }}.zip
3030
shell: bash
3131

.github/workflows/cypress-test-multiauth-e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
config:
6060
idp:
6161
entity_id: urn:example:idp
62-
metadata_url: http://localhost:7000/metadata
62+
metadata_url: http://[::1]:7000/metadata
6363
sp:
6464
entity_id: https://localhost:9200
6565
kibana_url: http://localhost:5601${{ matrix.basePath }}

.github/workflows/cypress-test-saml-e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
config:
6060
idp:
6161
entity_id: urn:example:idp
62-
metadata_url: http://localhost:7000/metadata
62+
metadata_url: http://[::1]:7000/metadata
6363
sp:
6464
entity_id: https://localhost:9200
6565
kibana_url: http://localhost:5601${{ matrix.basePath }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## Version 2.19.0 Release Notes
2+
3+
Compatible with OpenSearch and OpenSearch Dashboards version 2.19.0
4+
5+
### Enhancements
6+
* Add LTR transport actions to cluster permissions list ([#2170](https://github.com/opensearch-project/security-dashboards-plugin/pull/2170))
7+
8+
### Bug Fixes
9+
* Preserve query in nextUrl during openid login redirect ([#2140](https://github.com/opensearch-project/security-dashboards-plugin/pull/2140))
10+
* Fix tenant defaulting incorrectly ([#2163](https://github.com/opensearch-project/security-dashboards-plugin/pull/2163))

test/cypress/e2e/saml/saml_auth_test.spec.js

+116-30
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,70 @@ before(() => {
2929

3030
// Avoid Cypress lock onto the ipv4 range, so fake `visit()` before `request()`.
3131
// See: https://github.com/cypress-io/cypress/issues/25397#issuecomment-1402556488
32-
cy.visit(`http://localhost:5601${basePath}`);
32+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
33+
cy.visit(`http://localhost:5601${basePath}`);
34+
} else {
35+
cy.request(`http://localhost:5601${basePath}`);
36+
}
3337

3438
cy.createRoleMapping(ALL_ACCESS_ROLE, samlUserRoleMapping);
3539
cy.clearCookies();
3640
cy.clearLocalStorage();
3741
});
3842

43+
beforeEach(() => {
44+
cy.intercept('GET', '**/**', (req) => {
45+
// Replace [::1] with localhost in the request URL and headers
46+
if (req.url.includes('[::1]')) {
47+
req.url = req.url.replace(/\[::1\]/g, 'localhost');
48+
}
49+
50+
req.on('response', (res) => {
51+
if (res && res.headers) {
52+
Object.keys(res.headers).forEach((key) => {
53+
if (typeof res.headers[key] === 'string' && res.headers[key].includes('[::1]')) {
54+
res.headers[key] = res.headers[key].replace(/\[::1\]/g, 'localhost');
55+
}
56+
});
57+
}
58+
return res;
59+
});
60+
});
61+
});
62+
3963
afterEach(() => {
4064
cy.clearCookies();
4165
cy.clearLocalStorage();
4266
});
4367

4468
describe('Log in via SAML', () => {
45-
const samlLogin = () => {
46-
if (Cypress.env('loginMethod') === 'saml_multiauth') {
47-
cy.loginWithSamlMultiauth();
48-
} else {
49-
cy.loginWithSaml();
50-
}
69+
const loginWithSamlMultiauth = () => {
70+
cy.get('a[aria-label="saml_login_button"]').should('be.visible');
71+
cy.get('a[aria-label="saml_login_button"]').should('be.visible').click();
72+
cy.origin('http://localhost:7000', () => {
73+
cy.get('input[id=userName]').should('be.visible');
74+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
75+
});
5176
};
5277

5378
it('Login to app/opensearch_dashboards_overview#/ when SAML is enabled', () => {
5479
localStorage.setItem('opendistro::security::tenant::saved', '"__user__"');
5580
localStorage.setItem('home:newThemeModal:show', 'false');
5681

57-
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
58-
failOnStatusCode: false,
59-
});
60-
61-
samlLogin();
82+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
83+
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
84+
failOnStatusCode: false,
85+
});
86+
loginWithSamlMultiauth();
87+
} else {
88+
cy.origin('http://localhost:7000', { args: { basePath } }, ({ basePath }) => {
89+
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
90+
failOnStatusCode: false,
91+
});
92+
cy.get('input[id=userName]').should('be.visible');
93+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
94+
});
95+
}
6296

6397
cy.get('#osdOverviewPageHeader__title').should('be.visible');
6498
cy.getCookie('security_authentication').should('exist');
@@ -68,11 +102,20 @@ describe('Log in via SAML', () => {
68102
localStorage.setItem('opendistro::security::tenant::saved', '"__user__"');
69103
localStorage.setItem('home:newThemeModal:show', 'false');
70104

71-
cy.visit(`http://localhost:5601${basePath}/app/dev_tools#/console`, {
72-
failOnStatusCode: false,
73-
});
74-
75-
samlLogin();
105+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
106+
cy.visit(`http://localhost:5601${basePath}/app/dev_tools#/console`, {
107+
failOnStatusCode: false,
108+
});
109+
loginWithSamlMultiauth();
110+
} else {
111+
cy.origin('http://localhost:7000', { args: { basePath } }, ({ basePath }) => {
112+
cy.visit(`http://localhost:5601${basePath}/app/dev_tools#/console`, {
113+
failOnStatusCode: false,
114+
});
115+
cy.get('input[id=userName]').should('be.visible');
116+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
117+
});
118+
}
76119

77120
cy.get('a.euiBreadcrumb--last').contains('Dev Tools');
78121
cy.getCookie('security_authentication').should('exist');
@@ -84,11 +127,20 @@ describe('Log in via SAML', () => {
84127

85128
const urlWithHash = `http://localhost:5601${basePath}/app/security-dashboards-plugin#/getstarted`;
86129

87-
cy.visit(urlWithHash, {
88-
failOnStatusCode: false,
89-
});
90-
91-
samlLogin();
130+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
131+
cy.visit(urlWithHash, {
132+
failOnStatusCode: false,
133+
});
134+
loginWithSamlMultiauth();
135+
} else {
136+
cy.origin('http://localhost:7000', { args: { urlWithHash } }, ({ urlWithHash }) => {
137+
cy.visit(urlWithHash, {
138+
failOnStatusCode: false,
139+
});
140+
cy.get('input[id=userName]').should('be.visible');
141+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
142+
});
143+
}
92144

93145
cy.get('h1').contains('Get started');
94146
cy.getCookie('security_authentication').should('exist');
@@ -97,11 +149,20 @@ describe('Log in via SAML', () => {
97149
it('Tenancy persisted after logout in SAML', () => {
98150
localStorage.setItem('home:newThemeModal:show', 'false');
99151

100-
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
101-
failOnStatusCode: false,
102-
});
103-
104-
samlLogin();
152+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
153+
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
154+
failOnStatusCode: false,
155+
});
156+
loginWithSamlMultiauth();
157+
} else {
158+
cy.origin('http://localhost:7000', { args: { basePath } }, ({ basePath }) => {
159+
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
160+
failOnStatusCode: false,
161+
});
162+
cy.get('input[id=userName]').should('be.visible');
163+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
164+
});
165+
}
105166

106167
cy.get('#private').should('be.enabled');
107168
cy.get('#private').click({ force: true });
@@ -114,7 +175,20 @@ describe('Log in via SAML', () => {
114175

115176
cy.get('button[data-test-subj^="log-out-"]').click();
116177

117-
samlLogin();
178+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
179+
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
180+
failOnStatusCode: false,
181+
});
182+
loginWithSamlMultiauth();
183+
} else {
184+
cy.origin('http://localhost:7000', { args: { basePath } }, ({ basePath }) => {
185+
cy.visit(`http://localhost:5601${basePath}/app/opensearch_dashboards_overview`, {
186+
failOnStatusCode: false,
187+
});
188+
cy.get('input[id=userName]').should('be.visible');
189+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
190+
});
191+
}
118192

119193
cy.get('#user-icon-btn').should('be.visible');
120194
cy.get('#user-icon-btn').click();
@@ -131,8 +205,20 @@ describe('Log in via SAML', () => {
131205
// since the Shorten URL api is return's set-cookie header for admin user.
132206
cy.clearCookies().then(() => {
133207
const gotoUrl = `http://localhost:5601${basePath}/goto/${response.urlId}?security_tenant=global`;
134-
cy.visit(gotoUrl);
135-
samlLogin();
208+
if (Cypress.env('loginMethod') === 'saml_multiauth') {
209+
cy.visit(gotoUrl, {
210+
failOnStatusCode: false,
211+
});
212+
loginWithSamlMultiauth();
213+
} else {
214+
cy.origin('http://localhost:7000', { args: { gotoUrl } }, ({ gotoUrl }) => {
215+
cy.visit(gotoUrl, {
216+
failOnStatusCode: false,
217+
});
218+
cy.get('input[id=userName]').should('be.visible');
219+
cy.get('button[id=btn-sign-in]').should('be.visible').click();
220+
});
221+
}
136222
cy.getCookie('security_authentication').should('exist');
137223
});
138224
});

test/cypress/support/commands.js

-12
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ Cypress.Commands.add('createRoleMapping', (roleID, rolemappingJson) => {
7979
});
8080
});
8181

82-
Cypress.Commands.add('loginWithSaml', () => {
83-
cy.get('input[id=userName]').should('be.visible');
84-
cy.get('button[id=btn-sign-in]').should('be.visible').click();
85-
});
86-
87-
Cypress.Commands.add('loginWithSamlMultiauth', () => {
88-
cy.get('a[aria-label="saml_login_button"]').should('be.visible');
89-
cy.get('a[aria-label="saml_login_button"]').should('be.visible').click();
90-
cy.get('input[id=userName]').should('be.visible');
91-
cy.get('button[id=btn-sign-in]').should('be.visible').click();
92-
});
93-
9482
if (Cypress.env('LOGIN_AS_ADMIN')) {
9583
// Define custom cy.visit() only if LOGIN_AS_ADMIN is true
9684
Cypress.Commands.overwrite('visit', (orig, url, options = {}) => {

0 commit comments

Comments
 (0)