Skip to content

Commit

Permalink
Fixes #2716 by moving almost all tests to the Lab (#2755) (#2757)
Browse files Browse the repository at this point in the history
* Fixes #2716 by moving almost all tests to the Lab

* Disabling the graph service client aspects until admin consent
  • Loading branch information
jmprieur authored Apr 13, 2024
1 parent 9a576f7 commit 5e89be2
Show file tree
Hide file tree
Showing 31 changed files with 133 additions and 138 deletions.
4 changes: 2 additions & 2 deletions benchmark/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "msidentitysamplestesting.onmicrosoft.com",
"ClientId": "6af093f3-b445-4b7a-beae-046864468ad6",
"TenantId": "msidlab4.onmicrosoft.com",
"ClientId": "f6b698c0-140c-448f-8155-4aa9bf77ceba",
"ClientCredentials": [
{
"SourceType": "KeyVault",
Expand Down
3 changes: 2 additions & 1 deletion build/template-restore-build-MSIdentityWeb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ steps:
inputs:
command: run
projects: 'tests\DevApps\daemon-app\Daemon-app\Daemon-app.csproj'
arguments: '-f net7.0'
arguments: '-f net7.0'
enabled: false

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
displayName: 'Component Detection'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitytesting.onmicrosofonline.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "56c9a633-236e-45ee-9af1-a53d9811fbd6",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "9a192b78-6580-4f8a-aace-f36ffea4f7be",
// To call an API
"ClientSecret": "[secret-from-portal]",
"CallbackPath": "/signin-oidc"
Expand Down
42 changes: 21 additions & 21 deletions tests/DevApps/ContosoWorker/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "msidentitysamplestesting.onmicrosoft.com",
"ClientId": "6af093f3-b445-4b7a-beae-046864468ad6",
"ClientCredentials": [
{
"SourceType": "KeyVault",
"KeyVaultUrl": "https://webappsapistests.vault.azure.net",
"KeyVaultCertificateName": "Self-Signed-5-5-22"
}
]
"Instance": "https://login.microsoftonline.com/",
"TenantId": "msidlab4.onmicrosoft.com",
"ClientId": "f6b698c0-140c-448f-8155-4aa9bf77ceba",
"ClientCredentials": [
{
"SourceType": "KeyVault",
"KeyVaultUrl": "https://webappsapistests.vault.azure.net",
"KeyVaultCertificateName": "Self-Signed-5-5-22"
}
]
},

"MyWebApi": {
"BaseUrl": "https://graph.microsoft.com/v1.0",
"RelativePath": "/users",
"RequestAppToken": true,
"Scopes": [ "https://graph.microsoft.com/.default" ]
},
"MyWebApi": {
"BaseUrl": "https://graph.microsoft.com/v1.0",
"RelativePath": "/users",
"RequestAppToken": true,
"Scopes": [ "https://graph.microsoft.com/.default" ]
},

"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
}
6 changes: 3 additions & 3 deletions tests/DevApps/MultipleAuthSchemes/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
},
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "86699d80-dd21-476a-bcd1-7c1a3d471f75",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "9a192b78-6580-4f8a-aace-f36ffea4f7be",
//"ClientSecret": "",
"ClientCertificates": [
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebAppCallsMicrosoftGraph": {
"commandName": "Project",
"launchBrowser": true,
Expand Down
6 changes: 3 additions & 3 deletions tests/DevApps/WebAppCallsMicrosoftGraph/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitytesting.onmicrosofonline.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "56c9a633-236e-45ee-9af1-a53d9811fbd6",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "9a192b78-6580-4f8a-aace-f36ffea4f7be",
// To call an API
//"EnablePiiLogging": true,
"CallbackPath": "/signin-oidc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<ActionResult> SayHello()
var channel = GrpcChannel.ForAddress("https://localhost:5001");
var client = new Greeter.GreeterClient(channel);

string token = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/access_as_user" }).ConfigureAwait(false);
string token = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user" }).ConfigureAwait(false);

var headers = new Metadata();
headers.Add("Authorization", $"Bearer {token}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "86699d80-dd21-476a-bcd1-7c1a3d471f75",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "9a192b78-6580-4f8a-aace-f36ffea4f7be",
"CallbackPath": "/signin-oidc",
"SignedOutCallbackPath ": "/signout-callback-oidc",
"EnablePiiLogging": true,
Expand All @@ -14,29 +14,29 @@
{
"SourceType": "KeyVault",
"KeyVaultUrl": "https://webappsapistests.vault.azure.net",
"KeyVaultCertificateName": "Self-Signed-5-5-22",
"KeyVaultCertificateName": "Self-Signed-5-5-22"
}
]
},
"TodoList": {
// TodoListScope is the scope of the Web API you want to call.
"Scopes": [ "api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/access_as_user" ],
"Scopes": [ "api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user" ],
"BaseUrl": "http://localhost:44350"

},
"SayHello": {
// Scope for the web API set up w/gRPC
"Scopes": [ "api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/access_as_user" ],
"Scopes": [ "api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user" ],
"BaseUrl": "https://localhost:5001"
},
"AzureFunction": {
// Scope for the web API set up Azure function
"Scopes": [ "api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/access_as_user" ],
"Scopes": [ "api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user" ],
"BaseUrl": "http://localhost:7071/api/SampleFunc"
},
"TodoListJwe": {
// Scope for the web API used with the token decryption certificates.
"Scopes": [ "api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/access_as_user" ],
"Scopes": [ "api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user" ],
"BaseUrl": "https://localhost:44350"
},
"Logging": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task<IEnumerable<Todo>> GetAsync()

await RegisterPeriodicCallbackForLongProcessing(null);

// string token1 = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "user.read" }, "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab").ConfigureAwait(false);
// string token1 = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "user.read" }, "f645ad92-e38d-4d1a-b510-d1b09a74a8ca").ConfigureAwait(false);
// string token2 = await _tokenAcquisition.GetAccessTokenForUserAsync(new string[] { "user.read" }, "3ebb7dbb-24a5-4083-b60c-5a5977aabf3d").ConfigureAwait(false);

await Task.FromResult(0); // fix CS1998 while the lines about the 2 tokens are commented out.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "556d438d-2f4b-4add-9713-ede4e5f5d7da", //"712ae8d7-548a-4306-95b6-ee9117ee86f0", JWE clientID

// Or instead of Instance + TenantId, you can use the Authority
// "Authority": "https://login.microsoftonline.com/7f58f645-c190-4ce5-9de4-e2b7acd2a6ab/",
// "Authority": "https://login.microsoftonline.com/f645ad92-e38d-4d1a-b510-d1b09a74a8ca/",

// To exercise the signing-key issuer:
// - uncomment the following line (Authority)
Expand All @@ -15,7 +16,6 @@
// - WebAppsCallsWebApiCallGraph\\TodoListClient,
// - Navigate to the todo list. this provokes a 401.
// "Authority": "https://localhost:1234/v2.0",
"ClientId": "1e2fb196-50ce-4652-a4f9-26c1bf2e826b", //"712ae8d7-548a-4306-95b6-ee9117ee86f0", JWE clientID
//"ClientSecret": null,
"ClientCertificates": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "1e2fb196-50ce-4652-a4f9-26c1bf2e826b",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "556d438d-2f4b-4add-9713-ede4e5f5d7da",
"ClientCertificates": [
{
"SourceType": "KeyVault",
Expand Down
6 changes: 3 additions & 3 deletions tests/DevApps/aspnet-mvc/OwinWebApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "1e2fb196-50ce-4652-a4f9-26c1bf2e826b", //"712ae8d7-548a-4306-95b6-ee9117ee86f0", JWE clientID
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "556d438d-2f4b-4add-9713-ede4e5f5d7da", //"712ae8d7-548a-4306-95b6-ee9117ee86f0", JWE clientID
// "ClientSecret": "",
"Scopes": "access_as_user",
"EnableCacheSynchronization": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/DevApps/aspnet-mvc/OwinWebApp/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<add key="webpages:Enabled" value="false"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
<!--<add key="ida:ClientId" value="4cb8c23b-0612-4b84-ae0f-03a0ff654e1f"/>
<!--<add key="ida:ClientId" value="556d438d-2f4b-4add-9713-ede4e5f5d7da"/>
<add key="ida:AADInstance" value="https://login.microsoftonline.com/"/>
<add key="ida:Domain" value="msidentitysamplestesting.onmicrosoft.com"/>
<add key="ida:TenantId" value="7f58f645-c190-4ce5-9de4-e2b7acd2a6ab"/>
<add key="ida:Domain" value="msidlab4.onmicrosoft.com"/>
<add key="ida:TenantId" value="f645ad92-e38d-4d1a-b510-d1b09a74a8ca"/>
<add key="ida:PostLogoutRedirectUri" value="https://localhost:44386/signin-oidc"/>-->
</appSettings>
<system.web>
Expand Down
6 changes: 3 additions & 3 deletions tests/DevApps/aspnet-mvc/OwinWebApp/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "4cb8c23b-0612-4b84-ae0f-03a0ff654e1f",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "9a192b78-6580-4f8a-aace-f36ffea4f7be",
"RedirectUri": "https://localhost:44386/",
// "ClientSecret": "",
"EnableCacheSynchronization": false,
Expand Down
16 changes: 11 additions & 5 deletions tests/DevApps/blazorserver-calls-api/Client/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "10a6c31a-0700-4713-be2d-16bbffe71c1e",
"ClientSecret": "secret",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "9a192b78-6580-4f8a-aace-f36ffea4f7be",
"ClientCertificates": [
{
"SourceType": "KeyVault",
"KeyVaultUrl": "https://webappsapistests.vault.azure.net",
"KeyVaultCertificateName": "Self-Signed-5-5-22"
}
],
"CallbackPath": "/signin-oidc"
},
"TodoList": {
Expand All @@ -14,7 +20,7 @@
- a scope corresponding to a V1 application (for instance <GUID>/user_impersonation, where <GUID> is the
clientId of a V1 application, created in the https://portal.azure.com portal.
*/
"Scopes": [ "api://279c4566-de39-415a-b73c-960aad9517f3/access_as_user" ],
"Scopes": [ "api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user" ],
"BaseUrl": "https://localhost:44351",
"RelativePath": "/api/todolist"

Expand Down
6 changes: 3 additions & 3 deletions tests/DevApps/blazorserver-calls-api/Service/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "279c4566-de39-415a-b73c-960aad9517f3"
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "556d438d-2f4b-4add-9713-ede4e5f5d7da"
},
"Kestrel": {
"Endpoints": {
Expand Down
2 changes: 1 addition & 1 deletion tests/DevApps/blazorwasm2/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static async Task Main(string[] args)
builder.Services.AddMsalAuthentication(options =>
{
builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
options.ProviderOptions.DefaultAccessTokenScopes.Add("api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/access_as_user");
options.ProviderOptions.DefaultAccessTokenScopes.Add("api://556d438d-2f4b-4add-9713-ede4e5f5d7da/access_as_user");
});

await builder.Build().RunAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"blazorwasm2-singleOrg-hosted4": {
"commandName": "Project",
"launchBrowser": true,
Expand Down
4 changes: 2 additions & 2 deletions tests/DevApps/blazorwasm2/Client/wwwroot/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"AzureAd": {
"Authority": "https://login.microsoftonline.com/7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "7def8ed6-ce6c-4111-97a6-e73daa39a8c3",
"Authority": "https://login.microsoftonline.com/f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "c651397c-8579-44ad-a9ed-a62b2a75a475",
"ValidateAuthority": true
}
}
6 changes: 3 additions & 3 deletions tests/DevApps/blazorwasm2/Server/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "msidentitysamplestesting.onmicrosoft.com",
"TenantId": "7f58f645-c190-4ce5-9de4-e2b7acd2a6ab",
"ClientId": "1e2fb196-50ce-4652-a4f9-26c1bf2e826b",
"Domain": "msidlab4.onmicrosoft.com",
"TenantId": "f645ad92-e38d-4d1a-b510-d1b09a74a8ca",
"ClientId": "556d438d-2f4b-4add-9713-ede4e5f5d7da",
"CallbackPath": "/signin-oidc"
},
// },
Expand Down
8 changes: 4 additions & 4 deletions tests/DevApps/daemon-app/Daemon-app/Program - SDK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ static async Task Main(string[] args)
/*
var tokenAcquirer = tokenAcquirerFactory.GetTokenAcquirer(new MicrosoftIdentityApplicationOptions
{
ClientId = "6af093f3-b445-4b7a-beae-046864468ad6",
Authority = "https://login.microsoftonline.com/msidentitysamplestesting.onmicrosoft.com",
ClientId = "f6b698c0-140c-448f-8155-4aa9bf77ceba",
Authority = "https://login.microsoftonline.com/msidlab4.onmicrosoft.com",
ClientCredentials = new[]
{
new CredentialDescription()
Expand All @@ -42,8 +42,8 @@ static async Task Main(string[] args)
*/
// Or
var tokenAcquirer = tokenAcquirerFactory.GetTokenAcquirer(
authority: "https://login.microsoftonline.com/msidentitysamplestesting.onmicrosoft.com",
clientId: "6af093f3-b445-4b7a-beae-046864468ad6",
authority: "https://login.microsoftonline.com/msidlab4.onmicrosoft.com",
clientId: "f6b698c0-140c-448f-8155-4aa9bf77ceba",
clientCredentials: new[]
{
new CredentialDescription()
Expand Down
2 changes: 1 addition & 1 deletion tests/DevApps/daemon-app/Daemon-app/Program-net60.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static async Task Main(string[] args)
// Get the token acquisition service
ITokenAcquirerFactory tokenAcquirerFactory = app.Services.GetRequiredService<ITokenAcquirerFactory>();
var tokenAcquirer = tokenAcquirerFactory.GetTokenAcquirer();
var result = await tokenAcquirer.GetTokenForAppAsync("api://1e2fb196-50ce-4652-a4f9-26c1bf2e826b/.default");
var result = await tokenAcquirer.GetTokenForAppAsync("api://556d438d-2f4b-4add-9713-ede4e5f5d7da/.default");
Console.WriteLine($"Token expires on {result.ExpiresOn}");

#endif
Expand Down
4 changes: 2 additions & 2 deletions tests/DevApps/daemon-app/Daemon-app/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "msidentitysamplestesting.onmicrosoft.com",
"ClientId": "6af093f3-b445-4b7a-beae-046864468ad6",
"TenantId": "msidlab4.onmicrosoft.com",
"ClientId": "f6b698c0-140c-448f-8155-4aa9bf77ceba",
"ClientCredentials": [
{
"SourceType": "KeyVault",
Expand Down
Loading

0 comments on commit 5e89be2

Please sign in to comment.