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

End to End test framework for MSAL 1.0 and 2.0 #1393

Merged
merged 34 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
60a72e4
Adding sample code
pkanher617 Mar 16, 2020
8e428ff
adding end to end test framework for 2.0
pkanher617 Mar 18, 2020
851b97f
Update browser.spec.ts
pkanher617 Mar 18, 2020
507d026
Added end to end tests for 1.0, added end to end test command to pipe…
pkanher617 Mar 18, 2020
3578b55
Merge branch 'dev' into e2e-test-framework
pkanher617 Mar 18, 2020
90646d2
Added full automation with accounts
pkanher617 Mar 18, 2020
61b17ff
Update npm-build-steps.yml
pkanher617 Mar 18, 2020
4c5e91b
Adding test retries and increased timeout
pkanher617 Mar 18, 2020
bb82fa7
Merge branch 'dev' into e2e-test-framework
Mar 18, 2020
87236b6
Merge branch 'dev' into e2e-test-framework
pkanher617 Mar 23, 2020
a695442
Update authConfig.js
pkanher617 Mar 23, 2020
e6de02b
Renamed sample app folder, updated docs for samples, added names for …
pkanher617 Mar 23, 2020
07e657b
Update authConfig.js
pkanher617 Mar 23, 2020
bb93545
Merge branch 'dev' into e2e-test-framework
Mar 24, 2020
97c5089
Merge branch 'dev' into e2e-test-framework
pkanher617 Mar 25, 2020
3a39921
Merge branch 'dev' into e2e-test-framework
pkanher617 Mar 26, 2020
2e769f0
fixing e2e tests
pkanher617 Mar 26, 2020
d6fd112
attempting to fix e2e
pkanher617 Mar 26, 2020
575dfe6
fixing e2e
pkanher617 Mar 27, 2020
67b1b9c
Update browser.spec.ts
pkanher617 Mar 27, 2020
cb13a7e
Merge branch 'dev' into e2e-test-framework
pkanher617 Mar 27, 2020
4f0234b
Updating packages from dev deps to regular deps
pkanher617 Mar 27, 2020
e895fa3
Update browser.spec.ts
pkanher617 Mar 27, 2020
b40c829
Update browser.spec.ts
pkanher617 Mar 27, 2020
f1ddf09
Update browser.spec.ts
pkanher617 Mar 30, 2020
1172754
Update browser.spec.ts
pkanher617 Mar 30, 2020
fcebe62
Update azure-pipelines.yml
pkanher617 Mar 30, 2020
c34f43e
adding puppeteer to root dependencies to try to fix e2e
pkanher617 Mar 30, 2020
04fff18
changing name from TestCredential to LabClient
pkanher617 Mar 30, 2020
ba1aadb
adding timeout
pkanher617 Mar 30, 2020
4e7a2c3
Adding puppeteer vars to other tests
pkanher617 Mar 30, 2020
d77d36f
Merge branch 'dev' into e2e-test-framework
pkanher617 Mar 30, 2020
a2648c9
Adding better postinstall logic for scoped bootstraps in ci
pkanher617 Mar 30, 2020
a64fdfa
Update package.json
pkanher617 Mar 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions build/npm-build-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,36 @@ steps:
displayName: 'Install Node.js'

- task: Npm@1
displayName: 'npm ci'
inputs:
command: 'custom'
customCommand: 'ci'
verbose: true

- task: Npm@1
displayName: 'Build Packages'
inputs:
command: 'custom'
customCommand: 'run build'

- task: Npm@1
displayName: 'Unit Tests'
inputs:
command: 'custom'
customCommand: 'run test:coverage'

- task: Npm@1
displayName: 'Code Coverage Reporting'
env:
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN)
inputs:
command: 'custom'
customCommand: 'run test:report'

- task: Npm@1
displayName: 'End-to-End Tests'
env:
AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
inputs:
command: 'custom'
customCommand: 'run test:e2e'
9 changes: 8 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
"lerna": "3.16.4",
"command": {
"run": {
"scope": ["msal", "@azure/msal-common", "@azure/msal-browser", "@azure/msal-angular"]
"scope": [
"msal",
"@azure/msal-common",
"@azure/msal-browser",
"@azure/msal-angular",
"vanilla-js-test-app",
"vanilla-js-test-app-2.0"
Copy link
Member

Choose a reason for hiding this comment

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

Can we confirm msal-node works even with dummy tests? Or is that not a concern?

Copy link
Member

Choose a reason for hiding this comment

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

wait! Is this only browser specific end-to-end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can include all end to end tests with this command, I will change the name to reflect this. For msal-browser and msal-core, the end to end tests are all browser based.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can add whatever sample runs your node end to end tests when you have it created.

]
}
},
"packages": [
Expand Down
12 changes: 7 additions & 5 deletions lib/msal-browser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@ If you have MSAL v1.x currently running in your application, you can follow the

## Samples

The [`samples`](../samples) folder contains samples applications for our libraries. Here is a complete list of samples for the MSAL.js 2.x library:
The [`VanillaJSTestApp2.0` folder](../samples/VanillaJSTestApp2.0) contains sample applications for our libraries. You can run any sample by changing the `authConfig.js` file in the respective folder to match your app registration and running the `npm` command `npm start -- -s <sample-name> -p <port>`.

| Sample | Description |
| ------ | ----------- |
| [Vanilla JS Sample](../../samples/VanillaJSTestApp2.0) | A vanilla Javascript sample showing basic usage of the MSAL 2.0 library (`msal-browser` package) with the Microsoft Graph API. |
Here is a complete list of samples for the MSAL.js 2.x library:

Instructions to run the samples can be found in the respective READMEs.
| Sample | Description | How to Run |
| ------ | ----------- | ---------- |
| [Basic Auth Sample](../../samples/VanillaJSTestApp2.0/default) | A vanilla Javascript sample showing basic usage of the MSAL 2.0 library (`msal-browser` package) with the Microsoft Graph API. | `npm start -- -s default` |

More instructions to run the sample can be found in the [`README.md` file](../samples/VanillaJSTestApp2.0/README.md) of the VanillaJSTestApp2.0 folder.

## Build and Test

Expand Down
2 changes: 1 addition & 1 deletion lib/msal-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ If you would like to skip a cached token and go to the server, please pass in th
## Usage
The example below walks you through how to login a user and acquire a token to be used for Microsoft's Graph Api.

#### Prerequisite
#### Prerequisites

Before using MSAL.js you will need to [register an application in Azure AD](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app) to get a valid `clientId` for configuration, and to register the routes that your app will accept redirect traffic on.

Expand Down
177 changes: 0 additions & 177 deletions lib/msal-core/oldTests/Authority.spec.ts

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"test": "lerna run test",
"test:coverage": "npm run clean:coverage && lerna run test:coverage",
"test:report": "nyc report | coveralls",
"test:e2e": "lerna run --concurrency 1 test:e2e",
"clean": "lerna run clean --no-private && lerna clean",
"clean:coverage": "rimraf ./.nyc_output/*"
},
Expand Down
2 changes: 1 addition & 1 deletion samples/VanillaJSTestApp/.mocharc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"require": ["test/setup.js", "@babel/polyfill"],
"require": ["e2eTests/testSetup.js", "@babel/polyfill"],
"spec": ["./test/*.spec.ts", "./test/**/*.spec.ts"]
}
52 changes: 35 additions & 17 deletions samples/VanillaJSTestApp/Readme.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
What are the dev apps?
----------------------
index.html shows how to get profile data and read email with the Microsoft Graph, using msal.js loginRedirect()/loginPopup()/acquireTokenSilent-acquireTokenPopup() APIs.
# MSAL.js 1.x Sample - Authorization Code Flow in Single-Page Applications

If loginRedirect() is used, the web page redirects to the Azure AD or Azure AD B2C login screen for authentication. Once authentication is completed, the page redirects back to the redirect uri given with the requested tokens.
## About this sample
This developer sample is used to run basic use cases for the MSAL library. You can also alter the configuration in `./app/<sample-name>/authConfig.js` to execute other behaviors.

If loginPopup() is used, the authentication occurs inside a popup window created by the browser. The main window will handle token retrieval once authentication has been completed in the popup.
## How to run the sample:

How to run the dev apps:
--------------------
Pre-requisite
- Install node.js if needed (https://nodejs.org/en/)
- Build the `msal-core` project.
### Pre-requisites
- Ensure [all pre-requisites](../../lib/msal-core/README.md#pre-requisites) have been completed to run msal-core.
- Install node.js if needed (https://nodejs.org/en/).
- Build the `msal-core` project with instructions provided in the [`README.md`](../../lib/msal-core/README.md) or using the command `npm run build:package`.

Resolving the server.js references
- In a command prompt, run `npm install`
### Configure the application
- Open `./app/<sample-name>/authConfig.js` in an editor.
- Replace client id with the Application (client) ID from the portal registration, or use the currently configured lab registration.
- Optionally, you may replace any of the other parameters, or you can remove them and use the default values.

Running the sample
- In a command prompt, run `npm start`
#### Install npm dependencies for sample
- In a command prompt, run `npm install`.

You may also run `npm run start:build` to build the `msal-core` project and start the server in one command.
#### Running the sample
1. In a command prompt, run `npm start`.
- If you wish to specify a different sample than the default, you may provide the sample name in the command prompt:
```javascript
npm start -- -sample <sample-name> // defaults to vanilla sample in `default` folder
```

- Navigate to http://localhost:30662 with the browser of your choice
```javascript
npm start -- -s <sample-name> // defaults to vanilla sample in 'default' folder
```

- In the web page, click on the "Sign In" button and select either `Sign in using Popup` or `Sign in using Redirect`
- If you wish to specify the port, you can provide the `-p` or `-port` flag:
```javascript
npm start -- -port <port-#> // defaults to 30662
```

```javascript
npm start -- -p <port-#> // defaults to 30662
```

- Navigate to http://localhost:30662 (or whatever port number specified) with the browser of your choice.

- In the web page, click on the "Sign In" button and select either `Sign in using Popup` or `Sign in using Redirect` to begin the auth flow.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Config object to be passed to Msal on creation
const msalConfig = {
auth: {
clientId: "6226576d-37e9-49eb-b201-ec1eeb0029b6",
clientId: "4b0db8c2-9f26-4417-8bde-3f0e3656f8e0",
redirectUri: "http://localhost:30662/"
},
cache: {
Expand Down