-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Added msal-node client-credential regression test #6276
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
1a1ac14
Added msal-node client-credential regression test
Robbie-Microsoft eeda597
modified client-credential.yml
Robbie-Microsoft d6ac2cd
modified client-credential.yml
Robbie-Microsoft 4a303fb
modified client-credential.yml
Robbie-Microsoft 3f40e16
modified client-credential.yml
Robbie-Microsoft 72e01b7
added fake regression for testing github actions, will remove later
Robbie-Microsoft 917e9c4
added sleep function for regression test
Robbie-Microsoft 476f58e
removed fake regression
Robbie-Microsoft 0af3b31
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft b327798
Testing minSamples on GitHub actions
Robbie-Microsoft 5271450
reverted changes for testing. Added a minSamples value of 150
Robbie-Microsoft 7231dda
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 4427feb
Added charts for gh-pages
Robbie-Microsoft af3472b
Added fake regression
Robbie-Microsoft 9fdec9a
Removed fake regression
Robbie-Microsoft b8dab61
Finalized workflow file
Robbie-Microsoft 32d7845
Implemented GitHub Feedback
Robbie-Microsoft 58ba824
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 4d2f748
Testing push to gh-pages branch
Robbie-Microsoft 6f77167
Removing testing that determined typedocs and performance data can bo…
Robbie-Microsoft 9afa540
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 964dfda
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 6a06154
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft bcaba56
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 2166091
Added all confidential client devs to codeowners for confidential cli…
Robbie-Microsoft 773d873
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 9875ec2
Renamed files. Removed code from .yml for testing purposes.
Robbie-Microsoft 44e4fa9
Removed code from .yml that was for testing purposes
Robbie-Microsoft 4ace75b
Implemented gitHub Feedback
Robbie-Microsoft f33cb63
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 3ef6807
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 72d0b06
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft c39bd8b
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 64b41f3
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft 345a21f
Merge branch 'dev' into client_credentials_regression_test
Robbie-Microsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: msal-node client-credential Regression Test | ||
on: | ||
# Allows manual triggering of workflow | ||
workflow_dispatch: | ||
|
||
pull_request: | ||
types: [opened, reopened, synchronize, ready_for_review] | ||
paths: | ||
- "regression-tests/msal-node/client-credential/*" | ||
- "lib/msal-node/**/*" | ||
- "lib/msal-common/**/*" | ||
- "!**.md" | ||
- ".github/workflows/client-credential.yml" | ||
|
||
merge_group: | ||
types: [checks_requested] | ||
|
||
jobs: | ||
benchmark: | ||
name: Run msal-node client-credential Regression Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
- name: Run benchmark | ||
run: cd regression-tests/msal-node/client-credential && npm install && node index.js | tee output.txt | ||
|
||
- name: Download previous benchmark data | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./cache | ||
key: ${{ runner.os }}-benchmark | ||
|
||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: msal-node client-credential Regression Test | ||
tool: 'benchmarkjs' | ||
output-file-path: regression-tests/msal-node/client-credential/output.txt | ||
external-data-json-path: ./cache/client-credential-benchmark-data.json | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# Show alert with commit comment on detecting possible performance regression | ||
alert-threshold: '110%' | ||
Robbie-Microsoft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
comment-on-alert: true | ||
fail-on-alert: false | ||
alert-comment-cc-users: '@bgavrilMS @robbie-microsoft' |
35 changes: 35 additions & 0 deletions
35
.github/workflows/msal-node-confidential-client-benchmarks.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Do not run this workflow on pull request since this workflow has permission to modify contents. | ||
on: | ||
push: | ||
branches: | ||
- dev | ||
|
||
permissions: | ||
# deployments permission to deploy GitHub pages website | ||
deployments: write | ||
# contents permission to update benchmark contents in gh-pages branch | ||
contents: write | ||
|
||
jobs: | ||
benchmark: | ||
name: Performance regression check | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
- name: Run benchmark | ||
run: cd regression-tests/msal-node/client-credential && npm install && node index.js | tee output.txt | ||
|
||
# gh-pages branch is updated and pushed automatically with extracted benchmark data | ||
# By default, this action assumes that gh-pages is the GitHub Pages branch and that | ||
# /dev/bench is a path to put the benchmark dashboard page. They can be tweaked by | ||
# the gh-pages-branch, gh-repository and benchmark-data-dir-path inputs. | ||
- name: Store benchmark result | ||
uses: benchmark-action/github-action-benchmark@v1 | ||
with: | ||
name: msal-node client-credential Regression Test | ||
tool: 'benchmarkjs' | ||
output-file-path: regression-tests/msal-node/client-credential/output.txt | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# Push and deploy GitHub pages branch automatically | ||
auto-push: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
const NetworkUtils = class NetworkUtils { | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
static getNetworkResponse(headers, body, statusCode) { | ||
return { | ||
headers: headers, | ||
body: body, | ||
status: statusCode, | ||
}; | ||
} | ||
}; | ||
|
||
const DEFAULT_OPENID_CONFIG_RESPONSE = { | ||
headers: {}, | ||
status: 200, | ||
body: { | ||
token_endpoint: | ||
"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token", | ||
token_endpoint_auth_methods_supported: [ | ||
"client_secret_post", | ||
"private_key_jwt", | ||
"client_secret_basic", | ||
], | ||
jwks_uri: | ||
"https://login.microsoftonline.com/{tenant}/discovery/v2.0/keys", | ||
response_modes_supported: ["query", "fragment", "form_post"], | ||
subject_types_supported: ["pairwise"], | ||
id_token_signing_alg_values_supported: ["RS256"], | ||
response_types_supported: [ | ||
"code", | ||
"id_token", | ||
"code id_token", | ||
"id_token token", | ||
], | ||
scopes_supported: ["openid", "profile", "email", "offline_access"], | ||
issuer: "https://login.microsoftonline.com/{tenant}/v2.0", | ||
request_uri_parameter_supported: false, | ||
userinfo_endpoint: "https://graph.microsoft.com/oidc/userinfo", | ||
authorization_endpoint: | ||
"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize", | ||
http_logout_supported: true, | ||
frontchannel_logout_supported: true, | ||
end_session_endpoint: | ||
"https://login.microsoftonline.com/{tenant}/oauth2/v2.0/logout", | ||
claims_supported: [ | ||
"sub", | ||
"iss", | ||
"cloud_instance_name", | ||
"cloud_instance_host_name", | ||
"cloud_graph_host_name", | ||
"msgraph_host", | ||
"aud", | ||
"exp", | ||
"iat", | ||
"auth_time", | ||
"acr", | ||
"nonce", | ||
"preferred_username", | ||
"name", | ||
"tid", | ||
"ver", | ||
"at_hash", | ||
"c_hash", | ||
"email", | ||
], | ||
tenant_region_scope: null, | ||
cloud_instance_name: "microsoftonline.com", | ||
cloud_graph_host_name: "graph.windows.net", | ||
msgraph_host: "graph.microsoft.com", | ||
rbac_url: "https://pas.windows.net", | ||
}, | ||
}; | ||
|
||
const CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT = { | ||
headers: {}, | ||
status: 200, | ||
body: { | ||
token_type: "Bearer", | ||
expires_in: 3599, | ||
ext_expires_in: 3599, | ||
refresh_in: 3598 / 2, | ||
access_token: "thisIs.an.accessT0ken", | ||
}, | ||
}; | ||
|
||
module.exports = { | ||
CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT, | ||
DEFAULT_OPENID_CONFIG_RESPONSE, | ||
NetworkUtils, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. | ||
*/ | ||
|
||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
|
||
import benchmark from "benchmark"; | ||
import * as msal from "@azure/msal-node"; | ||
import { | ||
CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT, | ||
DEFAULT_OPENID_CONFIG_RESPONSE, | ||
NetworkUtils, | ||
} from "../Constants.js"; | ||
|
||
const clientConfig = { | ||
auth: { | ||
clientId: "client_id", | ||
authority: "https://login.microsoftonline.com/tenant_id", | ||
knownAuthorities: ["https://login.microsoftonline.com/tenant_id"], | ||
clientSecret: "client_secret", | ||
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. nit: should probably also do one for certificates. maybe in another PR. |
||
}, | ||
system: { | ||
networkClient: new class CustomHttpClient { | ||
sendGetRequestAsync(url, options, cancellationToken) { | ||
return new Promise((resolve, reject) => { | ||
const networkResponse = NetworkUtils.getNetworkResponse( | ||
DEFAULT_OPENID_CONFIG_RESPONSE.headers, | ||
DEFAULT_OPENID_CONFIG_RESPONSE.body, | ||
DEFAULT_OPENID_CONFIG_RESPONSE.status, | ||
); | ||
resolve(networkResponse); | ||
}); | ||
} | ||
sendPostRequestAsync(url, options) { | ||
return new Promise((resolve, _reject) => { | ||
const networkResponse = NetworkUtils.getNetworkResponse( | ||
CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT.headers, | ||
CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT.body, | ||
CONFIDENTIAL_CLIENT_AUTHENTICATION_RESULT.status, | ||
); | ||
resolve(networkResponse); | ||
}); | ||
} | ||
} | ||
}, | ||
}; | ||
|
||
const NUM_CACHE_ITEMS = 10; | ||
|
||
const confidentialClientApplication = new msal.ConfidentialClientApplication(clientConfig); | ||
const firstResourceRequest = { | ||
scopes: ["resource-1/.default"], | ||
}; | ||
const lastResourceRequest = { | ||
scopes: [`resource-${NUM_CACHE_ITEMS}/.default`], | ||
}; | ||
|
||
(async () => { | ||
// pre populate the cache | ||
for (let i = 1; i <= NUM_CACHE_ITEMS; i++) { | ||
const request = { | ||
scopes: [`resource-${i}/.default`], | ||
}; | ||
await confidentialClientApplication.acquireTokenByClientCredential(request); | ||
} | ||
|
||
const suite = new benchmark.Suite(); | ||
suite | ||
.add("ConfidentialClientApplication#acquireTokenByClientCredential-fromCache-resourceIsFirstItemInTheCache", { | ||
"fn": async () => { | ||
await confidentialClientApplication.acquireTokenByClientCredential(firstResourceRequest); | ||
}, | ||
"minSamples": 150, | ||
}) | ||
.add("ConfidentialClientApplication#acquireTokenByClientCredential-fromCache-resourceIsLastItemInTheCache", { | ||
"fn": async () => { | ||
await confidentialClientApplication.acquireTokenByClientCredential(lastResourceRequest); | ||
}, | ||
"minSamples": 150, | ||
}) | ||
.on("cycle", (event) => { | ||
// eslint-disable-next-line no-console | ||
console.log(String(event.target)); | ||
}) | ||
.run({ "async": true }); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "client-credential", | ||
"version": "1.0.0", | ||
"description": "Client Credential Regression Test", | ||
"main": "index.js", | ||
"type": "module", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@azure/msal-node": "^2.0.0", | ||
"benchmark": "^2.1.4" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
FWIW, although this
external-data-json-path
and theactions/cache@v3
above were mentioned in Continuous Benchmark's README, its actual github workflow yml file did not need to use such an external data file. I ended up not using this setting.