-
Notifications
You must be signed in to change notification settings - Fork 158
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
SAML Integration Tests #1088
Changes from 1 commit
861c909
c42dacc
7415746
a1afaa5
381de0c
69c765f
2234f77
776e134
4e73818
d68808a
1a641ba
016087c
4c3561a
5c486b4
fc133ae
a39fa6f
15f7483
07688fa
a0338d4
ad54b42
abff13a
60f97f4
85492d9
6423819
11dbee5
8062541
dc52652
e07ffb9
9fa7fbf
edf19e3
73d5251
ce0708b
ae2f818
9b45c10
22a1ac2
cd10d35
89950cc
4c696e4
8253163
51ad38a
847bc2d
c10cf2c
9af274a
f6d8032
f247dbb
fba014d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Aniketh Jain <anijainc@amazon.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
|
@@ -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', { | ||
|
@@ -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); | ||
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(); | ||
|
||
|
@@ -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"]')), | ||
|
@@ -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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense at all to parameterize There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 togetCookies
is returning all cookies that the browser encounters which is multiple cookies in this case. Perhaps we should rename this variable tocookies
?