Initial draft PR to introduce Integration Tests for SAML auth flow#1044
Initial draft PR to introduce Integration Tests for SAML auth flow#1044devardee wants to merge 9 commits intoopensearch-project:mainfrom devardee:saml_integ_tests
Conversation
…ation in developer guide
|
|
||
| // Create certificate pair on the fly and pass it to runServer | ||
| runServer({ | ||
| acsUrl: 'http://localhost:5601/_opendistro/_security/saml/acs', |
There was a problem hiding this comment.
is it possible to run idp server with acs /_plugins/_security/saml/acs? or will it be covered in next iteration of this PR?
There was a problem hiding this comment.
did not understand, can you please explain?
| { | ||
| path: '/_plugins/_security/saml/acs', | ||
| // need to change to /_opendistro to execute the tests. | ||
| path: '/_opendistro/_security/saml/acs', |
There was a problem hiding this comment.
Is there a way you can test both endpoints or just the new one?
There was a problem hiding this comment.
we can ignore this, since you had already merged this change
peternied
left a comment
There was a problem hiding this comment.
Really great work, I've added a couple of comments, but its looking very close. I noticed there were 4 scenarios called out in the saml tests but I only see 2 tests cases, were you working on implementing all 4?
test/jest.config.server.js
Outdated
| //for now only run saml integration test. | ||
| testMatch: ['**/test/jest_integration/**/saml_auth.tests.ts'], |
There was a problem hiding this comment.
Please revert
Note you can also use use test.only for quickly focusing on a single test, see https://devhints.io/jest Focusing tests
There was a problem hiding this comment.
yes, I will revert this config change
|
|
||
| }); | ||
|
|
||
| function sleepFor(sleepDuration: number) { |
There was a problem hiding this comment.
Doesn't look used,
IMO this is the better mechanism https://decipher.dev/30-seconds-of-typescript/docs/sleep/
There was a problem hiding this comment.
yes, will remove this
| @@ -0,0 +1,28 @@ | |||
| -----BEGIN PRIVATE KEY----- | |||
There was a problem hiding this comment.
I don't see a reference, can we remove both checked in certs?
There was a problem hiding this comment.
the IDP server uses this certificate to generate idp's metadata, we can acutally generate these certificates on the fly, I have just hardcoded for now
| "lint:es": "node ../../scripts/eslint", | ||
| "lint:style": "node ../../scripts/stylelint", | ||
| "lint": "yarn run lint:es && yarn run lint:style", | ||
| "pretest:jest_server": "node ./test/jest_integration/runIdpServer.js &", |
There was a problem hiding this comment.
Can this be started during saml_auth.tests.ts start up so it only impacts those tests it applies to?
There was a problem hiding this comment.
yes, this can be done, will only start idp server for the saml tests
| } | ||
| ); | ||
| } catch (error) { | ||
| console.log('Got an error!!'); |
There was a problem hiding this comment.
include that error in the logged output
| await driver | ||
| .wait( | ||
| until.elementsLocated( | ||
| By.xpath("/html/body/div[1]/div/div/div/div[2]/div/main/div[1]/span/button/span") |
There was a problem hiding this comment.
Is there a way this can be found by id that would be cleaner?
There was a problem hiding this comment.
sure, I will need to look at the DOM to see for ID's
|
Yes, I will add test to capture all the scenarios |
peternied
left a comment
There was a problem hiding this comment.
I don't see any pushed changes, please update the PR so it can be reviewed.
|
sure will update the PR, btw can we merge this PR #1001 ? |
|
@devardee I haven't seen any updates on this PR - could you let us know what you thoughts are? When I attempt to run the code locally I get an error that there is no gecko driver for firefox present, so it seems like there are some additional fundamentals that are missing. |
|
I will resume my work on this, I am hoping to complete (refactor + adding additional test cases) by end of next week. @peternied to run the selenium tests locally you need to install the geckodriver and add it to your PATH env variable. To run this test in CI, I was thinking of installing gecko driver via setup script and run it in Headless mode, is this the correct approach ? |
Please make sure you document what it takes to run the tests, as some folks are on mac/windows/linux - platform agnostic would be the best if there is an easy way to incorporate. No matter the local steps, please also update the ci.yml workflow to make sure the GitHub Action is setup with whatever it will need to run the tests. |
|
@devardee I haven't seen any updates, anything that you need help with? |
Signed-off-by: Deepak Devarakonda <devardee@amazon.com>
Signed-off-by: Aniketh Jain <anijainc@amazon.com>
Signed-off-by: Aniketh Jain <anijainc@amazon.com>
Signed-off-by: Aniketh Jain <anijainc@amazon.com>
Signed-off-by: Aniketh Jain <anijainc@amazon.com>
|
Closing this PR in favor of #1088 |
Description
Integration test to validate SAML flow, this is a draft PR. Integ tests are based on selenium web driver.
Category
Check List
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.