Skip to content
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

SAML Integration Tests #1088

Merged
merged 46 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
861c909
Refactor + add support to run saml based integ tests via selenium web…
devardee Jul 19, 2022
c42dacc
Add plugins.security.unsupported.restapi.allow_securityconfig_modific…
devardee Jul 19, 2022
7415746
Add one more test
devardee Aug 30, 2022
a1afaa5
Added tests for checking tenancy retention after logout in SAML
expani Aug 30, 2022
381de0c
Lint formatting fixes
expani Aug 30, 2022
69c765f
Removed unused imports
expani Aug 30, 2022
2234f77
Add plugins.security.unsupported.restapi.allow_securityconfig_modific…
devardee Jul 19, 2022
776e134
Added License header
expani Aug 30, 2022
4e73818
Added building the plugin bundles while running ITs
expani Sep 1, 2022
d68808a
Merge remote-tracking branch 'upstream/main' into saml_integ_tests_ra…
expani Sep 1, 2022
1a641ba
Signed off the commit
expani Sep 1, 2022
016087c
Added debug loggers for checking IT failures
expani Sep 1, 2022
4c3561a
Added debug loggers for checking IT failures
expani Sep 1, 2022
5c486b4
Added debug loggers for checking IT failures
expani Sep 1, 2022
fc133ae
Added debug loggers for checking IT failures
expani Sep 1, 2022
a39fa6f
Added a new stage for debug loggers before cleanup
expani Sep 1, 2022
15f7483
Added a new stage for debug loggers before cleanup
expani Sep 1, 2022
07688fa
Added logger to print error recieved from auth info during saml login
expani Sep 1, 2022
a0338d4
Added Docker host N/W Config to allow connection to SAML IDP
expani Sep 2, 2022
ad54b42
Added discovery type config to be single node for passing bootstrap c…
expani Sep 5, 2022
abff13a
Debug loggers
expani Sep 5, 2022
60f97f4
Debug loggers
expani Sep 5, 2022
85492d9
Debug loggers
expani Sep 5, 2022
6423819
Reverted run command to see change in error
expani Sep 5, 2022
11dbee5
Trying with full docker image of OS
expani Sep 5, 2022
8062541
Refactored the integration test yaml to use OS Full Docker image
expani Sep 5, 2022
dc52652
Removed all debug loggers
expani Sep 5, 2022
e07ffb9
Added selfSigned package for generating certs and integrated with sam…
expani Sep 5, 2022
9fa7fbf
Deleted checked-in key and cert for saml-idp server
expani Sep 5, 2022
edf19e3
Reverted use of docker image and testing again with manual build
expani Sep 9, 2022
73d5251
Reverted use of docker image and testing again with manual build
expani Sep 9, 2022
ce0708b
Merge remote-tracking branch 'upstream/main' into saml_integ_tests_ra…
expani Sep 9, 2022
ae2f818
Upgraded version from 2.3 to 2.4
expani Sep 9, 2022
9b45c10
Removed debug pointers
expani Sep 9, 2022
22a1ac2
Commented out failing IT temporarily
expani Sep 13, 2022
cd10d35
Rebased with upstream main and removed comment for Lint tests to pass
expani Sep 14, 2022
89950cc
Lint formatting fix
expani Sep 14, 2022
4c696e4
Added the commented failing test back again
expani Sep 14, 2022
8253163
Merge remote-tracking branch 'upstream/main' into saml_integ_tests_ra…
expani Sep 15, 2022
51ad38a
Removed assertion from test again to make it pass
expani Sep 15, 2022
847bc2d
Used a better XPath and improved error logging in tests
expani Sep 15, 2022
c10cf2c
Removed an unused XPath
expani Sep 15, 2022
9af274a
Added back the assertion for failing IT
expani Sep 15, 2022
f6d8032
Added steps to run Selenium based Integ Tests
expani Sep 15, 2022
f247dbb
Commented out the test, will re-enable it again in the fix PR
expani Sep 17, 2022
fba014d
Parameterized the getDriver function
expani Sep 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Lint formatting fixes
Signed-off-by: Aniketh Jain <anijainc@amazon.com>
  • Loading branch information
expani authored and devardee committed Aug 30, 2022
commit 381de0c972866a27f0527409c0c0c08a3410167a
6 changes: 5 additions & 1 deletion public/apps/account/account-nav-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ export function AccountNavButton(props: {
<EuiListGroupItem
color="subdued"
key="tenant"
label={<EuiText size="xs" id="tenantName">{resolveTenantName(props.tenant || '', username)}</EuiText>}
label={
<EuiText size="xs" id="tenantName">
{resolveTenantName(props.tenant || '', username)}
</EuiText>
}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Account navigation button renders 1`] = `
<EuiHeaderSectionItemButton>
<EuiHeaderSectionItemButton
id="user-icon-btn"
>
<EuiPopover
anchorPosition="downCenter"
button={
Expand Down Expand Up @@ -63,6 +65,7 @@ exports[`Account navigation button renders 1`] = `
key="tenant"
label={
<EuiText
id="tenantName"
size="xs"
>
tenant1
Expand Down
1 change: 0 additions & 1 deletion test/jest_integration/runIdpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ runServer({
acsUrl: 'http://localhost:5601/_opendistro/_security/saml/acs',
audience: 'https://localhost:9200',
});

49 changes: 18 additions & 31 deletions test/jest_integration/saml_auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('start OpenSearch Dashboards server', () => {
);
const responseBody = (getConfigResponse.payload as Buffer).toString();
config = JSON.parse(responseBody).config;
const saml_config = {
const samlConfig = {
http_enabled: true,
transport_enabled: false,
order: 5,
Expand All @@ -145,7 +145,7 @@ describe('start OpenSearch Dashboards server', () => {
},
};
try {
config.dynamic!.authc!.saml_auth_domain = saml_config;
config.dynamic!.authc!.saml_auth_domain = samlConfig;
config.dynamic!.authc!.basic_internal_auth_domain.http_authenticator.challenge = false;
config.dynamic!.http!.anonymous_auth_enabled = false;
await wreck.put('https://localhost:9200/_plugins/_security/api/securityconfig/config', {
Expand Down Expand Up @@ -226,22 +226,19 @@ describe('start OpenSearch Dashboards server', () => {
});

it('Login to app/opensearch_dashboards_overview#/ when SAML is enabled', async () => {
let driver = getDriver().build();
const driver = getDriver().build();
await driver.get('http://localhost:5601/app/opensearch_dashboards_overview#/');
await driver.findElement(By.id('btn-sign-in')).click();
await driver.wait(
until.elementsLocated(By.xpath(pageTitleXPath)),
10000
);
await driver.wait(until.elementsLocated(By.xpath(pageTitleXPath)), 10000);

let cookie = await driver.manage().getCookies();
const cookie = await driver.manage().getCookies();
expect(cookie.length).toEqual(2);
Copy link
Member

@cliu123 cliu123 Sep 1, 2022

Choose a reason for hiding this comment

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

Is the length of the cookie a constant here? alway equals to 2?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, one cookie for set by the idp and one cookie set by the security dashboard plugin. So in total there should be two cookies

Copy link
Member

Choose a reason for hiding this comment

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

It looks like the confusion here is in the variable name cookie. The call to getCookies is returning all cookies that the browser encounters which is multiple cookies in this case. Perhaps we should rename this variable to cookies?

await driver.manage().deleteAllCookies();
await driver.quit();
});

it('Login to app/dev_tools#/console when SAML is enabled', async () => {
let driver = getDriver().build();
const driver = getDriver().build();
await driver.get('http://localhost:5601/app/dev_tools#/console');
await driver.findElement(By.id('btn-sign-in')).click();

Expand All @@ -252,45 +249,39 @@ describe('start OpenSearch Dashboards server', () => {
10000
);

let cookie = await driver.manage().getCookies();
const cookie = await driver.manage().getCookies();
expect(cookie.length).toEqual(2);
await driver.manage().deleteAllCookies();
await driver.quit();
});

it('Login to Dashboard with Hash', async () => {
let url_with_hash = `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)`;
let driver = getDriver().build();
const urlWithHash = `http://localhost:5601/app/dashboards#/view/7adfa750-4c81-11e8-b3d7-01146121b73d?_g=(filters:!(),refreshInterval:(pause:!f,value:900000),time:(from:now-24h,to:now))&_a=(description:'Analyze%20mock%20flight%20data%20for%20OpenSearch-Air,%20Logstash%20Airways,%20OpenSearch%20Dashboards%20Airlines%20and%20BeatsWest',filters:!(),fullScreenMode:!f,options:(hidePanelTitles:!f,useMargins:!t),query:(language:kuery,query:''),timeRestore:!t,title:'%5BFlights%5D%20Global%20Flight%20Dashboard',viewMode:view)`;
const driver = getDriver().build();
await driver.manage().deleteAllCookies();
await driver.get(url_with_hash);
await driver.wait(
until.elementsLocated(By.xpath('/html/body/nav/div/div[1]/a/i/span')),
60000
);
await driver.get(urlWithHash);
await driver.wait(until.elementsLocated(By.xpath('/html/body/nav/div/div[1]/a/i/span')), 60000);
await driver.findElement(By.xpath(signInBtnXPath)).click();
await driver.wait(
until.elementsLocated(By.xpath('/html/body/div[1]/div/header/div/div[2]')),
20000
);
let window_hash = await driver.getCurrentUrl();
expect(window_hash).toEqual(url_with_hash);
let cookie = await driver.manage().getCookies();
const windowHash = await driver.getCurrentUrl();
expect(windowHash).toEqual(urlWithHash);
const cookie = await driver.manage().getCookies();
expect(cookie.length).toEqual(2);
await driver.manage().deleteAllCookies();
await driver.quit();
});

it('Testing Tenancy IT', async () => {
let driver = getDriver().build();
const driver = getDriver().build();

await driver.get('http://localhost:5601/app/opensearch_dashboards_overview#/');

await driver.findElement(By.xpath(signInBtnXPath)).click();

await driver.wait(
until.elementsLocated(By.xpath(pageTitleXPath)),
10000
);
await driver.wait(until.elementsLocated(By.xpath(pageTitleXPath)), 10000);

await driver.wait(
until.elementsLocated(By.xpath('//button[@aria-label="Closes this modal window"]')),
Expand Down Expand Up @@ -333,12 +324,8 @@ describe('start OpenSearch Dashboards server', () => {
await driver.manage().deleteAllCookies();
await driver.quit();
});

});


function getDriver() {
return new Builder()
.forBrowser('firefox')
.setFirefoxOptions(new Options().headless());
}
return new Builder().forBrowser('firefox').setFirefoxOptions(new Options().headless());
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense at all to parameterize firefox to be able to run these tests with a different browser?

Copy link
Member

Choose a reason for hiding this comment

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

Also making headless into a parameter for a developer writing tests to run this headed or headless could be useful.

}