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

Migrate to Lab Vault Cert for E2E Tests #7085

Merged
merged 37 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8f0192d
Update Azure SDK Identity to latest version
hectormmg Apr 29, 2024
69fd699
Update gen_env and lab client
hectormmg Apr 30, 2024
492cfc9
Update LabClient and gen_env scripts to use Lab Vault Certificate
hectormmg May 8, 2024
ada2a59
Merge branch 'dev' into use-lab-cert
hectormmg May 8, 2024
71c6aa0
Add 3p-e2e OB pipeline
hectormmg May 8, 2024
b06a5c4
Fix override parameter for 3p e2e tests
hectormmg May 8, 2024
fbc8839
Fix repo reference
hectormmg May 8, 2024
25fff01
Temporarily use use-lab-cert branch for 1p source
hectormmg May 8, 2024
8c719ac
Disable non-browser tests
hectormmg May 8, 2024
120e202
Update dependencies
hectormmg May 8, 2024
c792be6
Update package-lock
hectormmg May 8, 2024
735acaa
Update dependencies
hectormmg May 8, 2024
ac416d9
Revert @azure/identity version
hectormmg May 8, 2024
cc0f2ad
Add e2e tests for node react and angular
hectormmg May 8, 2024
4fd34f7
Add node versions to node e2e tests
hectormmg May 8, 2024
0f65c32
Use randomUUID for express session secret in msal-node samples
hectormmg May 8, 2024
4560b1c
Revert to environment variable for express session secret
hectormmg May 9, 2024
8e24127
Add express session secret variable to auth-code sample
hectormmg May 9, 2024
9db4b94
Update 1p e2e test yml
hectormmg May 9, 2024
8a13106
Use SourceBranchName instead of SourceBranch
hectormmg May 9, 2024
c9b4f44
Test new source branch for tags
hectormmg May 9, 2024
0e1cf72
Fix template
hectormmg May 9, 2024
8a12b37
Update 3p e2e
hectormmg May 9, 2024
d78dcf0
Update pull request branch logic
hectormmg May 10, 2024
ec14467
Update ref logic
hectormmg May 10, 2024
2a09074
Add params
hectormmg May 10, 2024
a92294c
Fix template
hectormmg May 10, 2024
042f8ee
Empty commit to trigger CI
hectormmg May 10, 2024
bdf769b
Revert 1p-e2e pipeline changes
hectormmg May 10, 2024
0dd6ba4
Add angular17-standalone-sample
hectormmg May 10, 2024
13a12df
Trigger CI
hectormmg May 10, 2024
530da5c
Add jest-junit to angular17 standalone sample
hectormmg May 10, 2024
bc915e5
Trigger CI
hectormmg May 10, 2024
1a182f6
Update package-lock
hectormmg May 10, 2024
c010af2
Remove GitHub e2e workflows
hectormmg May 10, 2024
197178f
Remove todos
hectormmg May 11, 2024
e1fc2b0
Trigger build
hectormmg May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pipelines/1p-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ variables:
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
sourceBranchName: ${{ replace(variables['Build.SourceBranch'], 'refs/heads/', '') }}
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
sourceBranchName: ${{ replace(variables['System.PullRequest.SourceBranch'], 'refs/heads/', '') }}
sourceBranchName: ${{ variables['System.PullRequest.SourceBranch'] }}

resources:
repositories:
Expand All @@ -16,7 +16,7 @@ resources:
- repository: 1P
type: git
name: IDDP/msal-javascript-1p
ref: master
ref: use-lab-cert # TODO: replace with master before merging

extends:
template: v2/OneBranch.NonOfficial.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
Expand Down
86 changes: 86 additions & 0 deletions .pipelines/3p-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
variables:
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
LinuxContainerImage: "mcr.microsoft.com/onebranch/cbl-mariner/build:2.0" # Docker image which is used to build the project https://aka.ms/obpipelines/containers
DEBIAN_FRONTEND: noninteractive
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/') }}:
sourceBranchName: ${{ replace(variables['Build.SourceBranch'], 'refs/heads/', '') }}
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be ${{ if startsWith(variables['System.PullRequest.SourceBranch'], 'refs/pull/') }}: instead?

sourceBranchName: ${{ replace(variables['System.PullRequest.SourceBranch'], 'refs/heads/', '') }}

resources:
repositories:
- repository: templates
type: git
name: OneBranch.Pipelines/GovernedTemplates
ref: refs/heads/main
- repository: 1P
type: git
name: IDDP/msal-javascript-1p
ref: use-lab-cert # TODO: replace with master before merging
extends:
template: v2/OneBranch.NonOfficial.CrossPlat.yml@templates # https://aka.ms/obpipelines/templates
parameters:
globalSdl:
policheck:
break: true

stages:
- stage: e2e_test
displayName: "3P E2E Tests"
jobs:
- template: .pipelines/templates/msal-browser-e2e.yml@1P
parameters:
jobName: "validate_msal_browser"
poolType: "linux"
publishFlagName: "publishMsalBrowser"
sourceBranchName: ${{ variables.sourceBranchName }}
stage: "PR"
override: true
samples:
- "client-capabilities"
- "onPageLoad"
- "pop"
- "customizable-e2e-test"
- template: .pipelines/templates/msal-node-e2e.yml@1P
parameters:
jobName: "validate_msal_node"
poolType: "windows"
publishFlagName: "publishMsalNode"
sourceBranchName: ${{ variables.sourceBranchName }}
stage: "PR"
override: true
node: [16, 18, 20, 22]
samples:
- "auth-code"
- "auth-code-cli-app"
- "client-credentials"
- "device-code"
- "silent-flow"
- "b2c-user-flows"
- template: .pipelines/templates/msal-react-e2e.yml@1P
parameters:
jobName: "validate_msal_react"
poolType: "linux"
publishFlagName: "publishMsalReact"
sourceBranchName: ${{ variables.sourceBranchName }}
stage: "PR"
override: true
samples:
- "nextjs-sample"
- "react-router-sample"
- "gatsby-sample"
- "typescript-sample"
- "b2c-sample"
- template: .pipelines/templates/msal-angular-e2e.yml@1P
parameters:
jobName: "validate_msal_angular"
poolType: "linux"
publishFlagName: "publishMsalAngular"
sourceBranchName: ${{ variables.sourceBranchName }}
stage: "PR"
override: true
samples:
- "angular15-sample-app"
- "angular16-sample-app"
- "angular-b2c-sample-app"
- "angular-standalone-sample"
hectormmg marked this conversation as resolved.
Show resolved Hide resolved
49 changes: 49 additions & 0 deletions gen_env.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Variables
$dotEnvFileName = ".env"
$tenantIdInfo = 'AZURE_TENANT_ID="72f988bf-86f1-41af-91ab-2d7cd011db47"'
$clientIdName = "AZURE_CLIENT_ID="
$clientCertPathName = "AZURE_CLIENT_CERT_PATH="
$sessionSecretName = "SESSION_SECRET="

# Create file if it doesn't exist
if (-Not (Test-Path $dotEnvFileName)) {
Write-Output "Creating $dotEnvFileName file..."
New-Item -Path . -Name $dotEnvFileName -ItemType "file"
}
else {
Write-Output "$dotEnvFileName file already exists..."
}

# Output Tenant Id to dotEnv file
$tenantIdInfo | Out-File -File $dotEnvFileName -Append
# login - you should have permission already to ready the necessary keyvault
# if not, ask your manager to help with onboarding
az login --output none

# Get the lab app id
$clientIdValue = $(az keyvault secret show --name "LabVaultAppId" --vault-name "msidlabs" --query "value")

$pfxPath = "LabCert.pfx";
$pemPath = "LabCert.pem";
# get the lab app cert
az keyvault secret download --vault-name "msidlabs" -n "LabVaultAccessCert" --file $pfxPath --encoding base64
# convert pfx file to pem
openssl pkcs12 -in $pfxPath -out $pemPath -nodes --passin pass:

$fullPemPath = (Get-Location).Path + "\" + $pemPath

# Used to secure sessions for samples that use express-session
$sessionSecret = New-Guid
$sessionSecretNameValue = "$sessionSecretName" + '"' + $sessionSecret + '"'

$clientIdNameValue = "$clientIdName$clientIdValue"
$clientCertPathNameValue = "$clientCertPathName" + '"' + $fullPemPath + '"'


$clientIdNameValue | Out-File -File $dotEnvFileName -Append
$clientCertPathNameValue | Out-File -File $dotEnvFileName -Append
$sessionSecretNameValue | Out-File -File $dotEnvFileName -Append

# Dotenv will not parse CLRF correctly, so we need to replace it with LF
(Get-Content $dotEnvFileName -Raw).Replace("`r`n", "`n") | Set-Content $dotEnvFileName -Force

29 changes: 1 addition & 28 deletions gen_env.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
#!/bin/bash

# Remember to make executable

# Variables
dotEnvFileName=".env"
tenantIdInfo="AZURE_TENANT_ID=\"72f988bf-86f1-41af-91ab-2d7cd011db47\""
clientIdName="AZURE_CLIENT_ID="
clientSecretName="AZURE_CLIENT_SECRET="

# Create file if it doesn't exist
touch $dotEnvFileName

# Output Tenant Id to dotEnv file
echo $tenantIdInfo >> $dotEnvFileName

# login - you should have permission already to ready the necessary keyvault
# if not, ask your manager to help with onboarding
az login

# Get the lab app id
clientIdValue=$(az keyvault secret show --name "LabVaultAppId" --vault-name "msidlabs" --query "value")

# get the lab app secret
clientSecretValue=$(az keyvault secret show --name "LabVaultAppSecret" --vault-name "msidlabs" --query "value")

clientIdNameValue=$clientIdName$clientIdValue
clientSecretNameValue=$clientSecretName$clientSecretValue

echo $clientIdNameValue >> $dotEnvFileName
echo $clientSecretNameValue >> $dotEnvFileName
Powershell.exe -file gen_env.ps1
Loading
Loading