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

Adding CIAM E2E tests and improvements to build infrastructure #2753

Merged
merged 60 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
6c5a142
Adding web app and web app call web api CIAM non CUD tests
Mar 27, 2024
7d665f2
Adding CIAM deamon test app for non CUD domain
Mar 28, 2024
23ea623
Integrating lab client apps
Mar 28, 2024
5939efe
Refactoring
Mar 29, 2024
53a5dd2
Merge branch 'master' into trwalke/AddingCiamNonCUDTests
trwalke Mar 29, 2024
9b61342
Setting ui test to headless
Apr 1, 2024
f9aa66c
Update WebAppCallsApiCallsGraphLocally.cs
trwalke Apr 3, 2024
aae0fe7
Adding CIAM CUD integration tests (#2737)
trwalke Apr 3, 2024
2be9db2
Enabling test runs with VSTest
Apr 4, 2024
243fcda
Test updates
Apr 4, 2024
57bd98b
test
Apr 4, 2024
8c170ef
Testing
Apr 4, 2024
5f2a384
Disabling test
Apr 4, 2024
c3f3d3a
Test
Apr 4, 2024
8dbf2dc
Updating the CIAM tests to use the lab API (manual testing)
jmprieur Apr 4, 2024
5df1482
Merge branch 'master' into trwalke/AddingCiamNonCUDTests
trwalke Apr 5, 2024
f9e1f0a
Merge branch 'master' into trwalke/AddingCiamNonCUDTests
trwalke Apr 9, 2024
c5cfc8d
Revert "Test"
Apr 9, 2024
5cc49e1
Revert "Disabling test"
Apr 9, 2024
0973fba
Merge branch 'master' into trwalke/UiTestingCiam
Apr 9, 2024
7484c58
Using hosted agents
Apr 9, 2024
c7fc69d
Always publish traces
Apr 9, 2024
ac0a5b5
Revert "Using hosted agents"
Apr 9, 2024
bcb274c
Updating process error
Apr 9, 2024
a97083e
Publish screenshots
Apr 10, 2024
7089ad2
Updating tests
Apr 10, 2024
f659da4
Adding additional statements
Apr 10, 2024
399685e
Updating screenshot staging
Apr 10, 2024
e734798
Fix typo
Apr 10, 2024
21dd633
Merge remote-tracking branch 'origin/trwalke/AddingCiamNonCUDTests' i…
Apr 10, 2024
2ae1e51
Updating endpoint to use Http
Apr 10, 2024
23e8591
Reconfiguring ports
Apr 10, 2024
542f7d1
hiding UI
Apr 10, 2024
dd33117
Enabling web app tests
Apr 11, 2024
5d8421b
Resolving test issue
Apr 11, 2024
e6ceeda
Fixing run time and hiding ui
Apr 11, 2024
b7622cd
Adding asp auth
Apr 11, 2024
52e3418
Enabling test
Apr 11, 2024
8790df2
Refactoring test YAML
Apr 11, 2024
4496127
Disabling restore
Apr 11, 2024
cdef625
Fixing build task
Apr 12, 2024
21963b8
Test
Apr 12, 2024
6c3a082
Test
Apr 12, 2024
a04ee0c
Fixing parameters
Apr 12, 2024
5ce9528
Unit tests
Apr 12, 2024
e7f2b36
Install test platform
Apr 12, 2024
e514e07
Changing test runner
Apr 12, 2024
e8c9de2
Updating test directories
Apr 12, 2024
ec3b986
Updating test run
Apr 12, 2024
612435f
Fix typo
Apr 12, 2024
01ca647
Updating test run
Apr 12, 2024
e6958e4
Updating check
Apr 12, 2024
9d3a79c
Refactoring process restart logic
Apr 12, 2024
6edf501
Clean up YAML
Apr 12, 2024
6ae6eb3
Revert "Adding asp auth"
Apr 12, 2024
09f4975
Refactoring
Apr 12, 2024
d2b43a1
Enabling code coverage settings
Apr 15, 2024
69bdc12
Fix indentation
Apr 15, 2024
f6656d9
Merge branch 'master' into trwalke/UiTestingCiam
trwalke Apr 16, 2024
a7cca4b
Merge branch 'master' into trwalke/UiTestingCiam
trwalke Apr 16, 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
7 changes: 7 additions & 0 deletions build/pipeline-releasebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ steps:
BuildPlatform: '$(BuildPlatform)'
BuildConfiguration: '$(BuildConfiguration)'
MsIdentityWebSemVer: $(MsIdentityWebSemVer)

# Run all tests
- template: template-run-unit-tests.yaml
parameters:
BuildPlatform: '$(BuildPlatform)'
BuildConfiguration: '$(BuildConfiguration)'
MsIdentityWebSemVer: $(MsIdentityWebSemVer)

# Run Post-build code analysis (e.g. Roslyn)
- template: template-postbuild-code-analysis.yaml
Expand Down
9 changes: 5 additions & 4 deletions build/template-restore-build-MSIdentityWeb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ steps:
- script: |
dotnet workload restore tests\DevApps\blazorwasm-b2c\blazorwasm2-b2c.csproj
displayName: 'Install wasm-tools'

- task: DotNetCoreCLI@2
displayName: 'Build solution Microsoft.Identity.Web.sln and run tests'
displayName: 'Build solution Microsoft.Identity.Web.sln'
inputs:
command: test
command: 'custom'
jmprieur marked this conversation as resolved.
Show resolved Hide resolved
custom: 'build'
projects: 'Microsoft.Identity.Web.sln'
arguments: '--collect "Code coverage" --settings "build\CodeCoverage.runsettings" --configuration ${{ parameters.BuildConfiguration }} -p:RunCodeAnalysis=true -p:MsIdentityWebSemVer=${{ parameters.MsIdentityWebSemVer }} -p:SourceLinkCreate=true'
arguments: '-p:configuration=${{ parameters.BuildConfiguration }} -p:RunCodeAnalysis=true -p:MsIdentityWebSemVer=${{ parameters.MsIdentityWebSemVer }} -p:SourceLinkCreate=true'

# This task is needed so that the 1CS Rolsyn analyzers task works.
# The previous task does the restore
Expand Down
62 changes: 55 additions & 7 deletions build/template-run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,66 @@

steps:

- task: DotNetCoreCLI@2
- task: VSTest@2
displayName: 'Run unit tests'
inputs:
command: 'test'
projects: |
Tests/**/*.csproj
!Tests/DevApps/**/*.csproj
arguments: '--collect "Code coverage" --settings "build\CodeCoverage.runsettings"'
continueOnError: 'true'
testSelector: 'testAssemblies'
testAssemblyVer2: 'tests\Microsoft.Identity.Web.Test\bin\**\Microsoft.Identity.Web.Test.dll'
searchFolder: '$(System.DefaultWorkingDirectory)'
runInParallel: true
codeCoverageEnabled: true
failOnMinTestsNotRun: true
minimumExpectedTests: '1'

- task: VSTest@2
displayName: 'Run integration tests'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: 'tests\Microsoft.Identity.Web.Test.Integration\bin\**\Microsoft.Identity.Web.Test.Integration.dll'
searchFolder: '$(System.DefaultWorkingDirectory)'
rerunFailedTests: true
rerunMaxAttempts: '3'
runInParallel: false
codeCoverageEnabled: true
failOnMinTestsNotRun: false
minimumExpectedTests: '1'

- task: VSTest@2
displayName: 'Run E2E tests'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
tests\E2E Tests\WebAppUiTests\bin\**\WebAppUiTests.dll
tests\E2E Tests\TokenAcquirerTests\bin\**\TokenAcquirerTests.dll
tests\E2E Tests\NET 7 tests\IntegrationTests\bin\**\IntegrationTests.dll
searchFolder: '$(System.DefaultWorkingDirectory)'
rerunFailedTests: true
rerunMaxAttempts: '3'
trwalke marked this conversation as resolved.
Show resolved Hide resolved
runInParallel: false
codeCoverageEnabled: true
failOnMinTestsNotRun: false
minimumExpectedTests: '1'

- task: PublishBuildArtifacts@1
displayName: 'Publish traces after test'
inputs:
PathtoPublish: '$(Build.SourcesDirectory)/tests/E2E Tests/PlaywrightTraces/'
ArtifactName: 'traces-after-tests-$(Build.BuildNumber)'
condition: failed()

# Copy all packages out to staging
- task: CopyFiles@2
displayName: 'Copy screenshots to staging directory'
inputs:
SourceFolder: '$(Build.SourcesDirectory)/tests/E2E Tests/'
Contents: '**/*screenshotFail.png'
TargetFolder: '$(Build.ArtifactStagingDirectory)\screenshots'
flattenFolders: true
condition: failed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Screenshot after test'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\screenshots'
ArtifactName: 'ScreenshotFail'
condition: failed()
7 changes: 7 additions & 0 deletions tests/DevApps/WebAppCallsMicrosoftGraph/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

// #define USE_SIGNED_ASSERTION
using System;
#if NET8_0
trwalke marked this conversation as resolved.
Show resolved Hide resolved
using Microsoft.AspNetCore.Authentication.Certificate;
#endif
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Builder;
Expand Down Expand Up @@ -37,6 +40,10 @@ public void ConfigureServices(IServiceCollection services)
#endif

int count = 0;
#if NET8_0
services.AddAuthentication(CertificateAuthenticationDefaults.AuthenticationScheme)
.AddCertificate();
#endif
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(options =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.UI\Microsoft.Identity.Web.UI.csproj" />
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate">
<Version>8.0.4</Version>
</PackageReference>
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions tests/DevApps/WebAppCallsMicrosoftGraph/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"KeyVaultUrl": "https://webappsapistests.vault.azure.net",
"KeyVaultCertificateName": "Self-Signed-5-5-22"
}
// {
// "SourceType": "ClientSecret",
// "ClientSecret": ""
// }
//{
// "SourceType": "ClientSecret",
// "ClientSecret": ""
//}
]

// Id.Web v1.0 way of declaring client credentials
Expand Down
16 changes: 8 additions & 8 deletions tests/DevApps/ciam/myWebApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
},
"profiles": {
"https": {
bgavrilMS marked this conversation as resolved.
Show resolved Hide resolved
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7082;http://localhost:5299",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7082;http://localhost:5299;",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
Expand Down
4 changes: 2 additions & 2 deletions tests/DevApps/ciam/myWebApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"AzureAd": {
"ClientId": "63e6d091-0e6d-4c8b-be67-d405e02ae3d8",
"ClientId": "634de702-3173-4a71-b336-a4fab786a479",
"Scopes": "access_as_user",
"Authority": "https://TrialTenantJmprieur.ciamlogin.com/"
"Authority": "https://MSIDLABCIAM6.ciamlogin.com"
},
"Logging": {
"LogLevel": {
Expand Down
2 changes: 1 addition & 1 deletion tests/DevApps/ciam/myWebApi/myWebApi.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-myWebApi-17be892d-3bb3-4282-92e2-301b02c86ed6</UserSecretsId>
Expand Down
4 changes: 1 addition & 3 deletions tests/DevApps/ciam/myWebApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Licensed under the MIT License.

using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
var initialScopes = builder.Configuration["DownstreamApi:Scopes"]?.Split(' ');
var initialScopes = builder.Configuration.GetSection("DownstreamApi:Scopes").Get<string[]>();

builder.Services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApp(builder.Configuration.GetSection("AzureAd"))
Expand Down
38 changes: 26 additions & 12 deletions tests/DevApps/ciam/myWebApp/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
{
"AzureAd": {
"ClientId": "4c8068d9-c00f-4908-afd7-44e4b263f66c",
"ClientSecret": "See user secrets",
"ClientCertificates": [],
"CallbackPath": "/signin-oidc",
"Authority": "https://TrialTenantJmprieur.ciamlogin.com/",
"Prompt": "login"
},
"DownstreamApi": {
"BaseUrl": "https://localhost:7082/weatherforecast",
"Scopes": [ "api://63e6d091-0e6d-4c8b-be67-d405e02ae3d8/.default" ]
},
"AzureAd": {
"ClientId": "b244c86f-ed88-45bf-abda-6b37aa482c79",
"ClientCertificates": [],
"CallbackPath": "/signin-oidc",
"Authority": "https://MSIDLABCIAM6.ciamlogin.com",
"Prompt": "login",
"ClientCredentials": [
//{
// "SourceType": "SignedAssertionFromManagedIdentity",
// "ManagedIdentityClientId": ""
//},
{
"SourceType": "KeyVault",
"KeyVaultUrl": "https://webappsapistests.vault.azure.net",
"KeyVaultCertificateName": "Self-Signed-5-5-22"
}
//{
// "SourceType": "ClientSecret",
// "ClientSecret": ""
//}
]
},
"DownstreamApi": {
"BaseUrl": "http://localhost:5299/WeatherForecast",
"Scopes": [ "api://634de702-3173-4a71-b336-a4fab786a479/.default" ]
},
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
1 change: 1 addition & 0 deletions tests/DevApps/ciam/myWebApp/myWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-myWebApp-23b8728b-775f-4796-8b63-e85cbaccc27c</UserSecretsId>
<UseWIP>true</UseWIP>
</PropertyGroup>

<ItemGroup Condition="'$(UseWIP)' == 'false' ">
Expand Down
24 changes: 24 additions & 0 deletions tests/E2E Tests/TokenAcquirerTests/TokenAcquirer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public class TokenAcquirer
"Self-Signed-5-5-22")
};

private static readonly CredentialDescription[] s_ciamClientCredentials = new[]
{
trwalke marked this conversation as resolved.
Show resolved Hide resolved
CertificateDescription.FromKeyVault(
"https://buildautomation.vault.azure.net",
"AzureADIdentityDivisionTestAgentCert")
};

public TokenAcquirer()
{
TokenAcquirerFactory.ResetDefaultInstance(); // Test only
Expand Down Expand Up @@ -92,6 +99,23 @@ public async Task AcquireToken_WithMicrosoftIdentityApplicationOptions_ClientCre
await CreateGraphClientAndAssert(tokenAcquirerFactory, services);
}

[IgnoreOnAzureDevopsFact(Skip = "https://github.com/AzureAD/microsoft-identity-web/issues/2732")]
//[Fact]
public async Task AcquireToken_WithMicrosoftIdentityApplicationOptions_ClientCredentialsCiamAsync()
{
TokenAcquirerFactory tokenAcquirerFactory = TokenAcquirerFactory.GetDefaultInstance();
IServiceCollection services = tokenAcquirerFactory.Services;

services.Configure<MicrosoftIdentityApplicationOptions>(s_optionName, option =>
{
option.Authority = "https://MSIDLABCIAM6.ciamlogin.com";
option.ClientId = "b244c86f-ed88-45bf-abda-6b37aa482c79";
option.ClientCredentials = s_clientCredentials;
});

await CreateGraphClientAndAssert(tokenAcquirerFactory, services);
}

[IgnoreOnAzureDevopsFact]
// [Fact]
public async Task AcquireToken_WithFactoryAndMicrosoftIdentityApplicationOptions_ClientCredentialsAsync()
Expand Down
Loading
Loading