Demo app for windows authentication testing. Used for the session "E2E testing goes corporate", presented at NDC Oslo 2020. Slides
Decide if you want to use hostnames or not. Without hostnames, you can run the demo app and api from Visual Studio. With hostnames, you need to deploy to IIS. If you want to experiment with https, you need to pick the "with hostnames" path, generate the certs for the sites and make sure Node.js is configured to accept the CA cert for those certs (see the slides on how this is done).
- Open WinAuthDemoApp in Visual Studio and start it (Debug mode works). Note the URL used.
- Open WinAuthDemoApi in Visual Studio and start it (Debug mode works). Note the URL used.
- Continue in the config section below
- Create certificates for the hostnames you have decided to use
- Create websites for WinAuthDemoApp and WinAuthDemoApi in IIS
- Setup https bindings for these websites with the created certificates
- Unless you have added them to your DNS, edit the hosts file on your machine (
c:\Windows\System32\drivers\etc\hosts
on Windows) and add a line for each hostname, mapping them to the IP of your IIS machine. - Export the CA cert for the created certificates in Base64 X.509 format, store it in the e2e folder.
- Continue in the config section below
- Edit the appsettings.json in WinAuthDemoApp and set "Resources/Intranet" to the URL to WinAuthDemoApi
- Edit the appsettings.json in WinAuthDemoApi and set "WinAuthDemoAppHost" to the hostname of WinAuthDemoApp (this is for CORS settings)
- Edit the cypress.json file in e2e and set baseUrl to the URL to WinAuthDemoApp
- Update the spec files in e2e, replace the URLs in the cy.ntlm and cy.ntlmSso calls to match the URLs of WinAuthDemoApp and WinAuthDemoApi.
- Rename the file cypress.env.template.json to cypress.env.json in e2e. Update that file with the user account you want to authenticate with.
- The package.json in the e2e folder is configured for Windows. To adapt it to another OS, please see the cypress-ntlm-auth readme
- In the e2e folder, run
npm install
- In the e2e folder, run
npm run cypress-ntlm
. If you are trying to use https, you can add a CA cert to for Node.js to trust in the e2e folder and update the package.json script "demo" to use it.