Skip to content

Commit

Permalink
integrating Lab Api package
Browse files Browse the repository at this point in the history
  • Loading branch information
trwalke committed Jul 27, 2023
1 parent 68bf457 commit 1988005
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 21 deletions.
7 changes: 0 additions & 7 deletions Microsoft.Identity.Web.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{B4E72F1C
tests\Directory.Build.props = tests\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test.LabInfrastructure", "tests\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj", "{65D4033E-70D4-4399-BBEB-18A629BC67D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test.Common", "tests\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj", "{28D01B8A-CD4C-4886-BD5E-4BF1B6C0A4C1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Identity.Web.Test", "tests\Microsoft.Identity.Web.Test\Microsoft.Identity.Web.Test.csproj", "{2B1E8B69-D74F-4D0C-B80B-78ACA1DD4E77}"
Expand Down Expand Up @@ -216,10 +214,6 @@ Global
{20535D28-C2F4-4975-9982-A18E7141DA53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20535D28-C2F4-4975-9982-A18E7141DA53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{20535D28-C2F4-4975-9982-A18E7141DA53}.Release|Any CPU.Build.0 = Release|Any CPU
{65D4033E-70D4-4399-BBEB-18A629BC67D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65D4033E-70D4-4399-BBEB-18A629BC67D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65D4033E-70D4-4399-BBEB-18A629BC67D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65D4033E-70D4-4399-BBEB-18A629BC67D9}.Release|Any CPU.Build.0 = Release|Any CPU
{28D01B8A-CD4C-4886-BD5E-4BF1B6C0A4C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28D01B8A-CD4C-4886-BD5E-4BF1B6C0A4C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28D01B8A-CD4C-4886-BD5E-4BF1B6C0A4C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -406,7 +400,6 @@ Global
{A423DCA3-BEB8-4D1B-8A4D-63B21950F388} = {1DDE1AAC-5AE6-4725-94B6-A26C58D3423F}
{2467D9A0-045B-4B45-8CCB-1AA229093F9F} = {1DDE1AAC-5AE6-4725-94B6-A26C58D3423F}
{20535D28-C2F4-4975-9982-A18E7141DA53} = {1DDE1AAC-5AE6-4725-94B6-A26C58D3423F}
{65D4033E-70D4-4399-BBEB-18A629BC67D9} = {B4E72F1C-603F-437C-AAA1-153A604CD34A}
{28D01B8A-CD4C-4886-BD5E-4BF1B6C0A4C1} = {B4E72F1C-603F-437C-AAA1-153A604CD34A}
{2B1E8B69-D74F-4D0C-B80B-78ACA1DD4E77} = {B4E72F1C-603F-437C-AAA1-153A604CD34A}
{E664F890-8EB7-4CB6-8469-17CF8E3D3F33} = {B4E72F1C-603F-437C-AAA1-153A604CD34A}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Identity.Client" Version="$(MicrosoftIdentityClientVersion)" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.54.1" />
<PackageReference Include="Microsoft.Identity.Lab.Api" Version="0.11.0" />
<PackageReference Include="System.Drawing.Common" Version="$(SystemDrawingCommon)" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web.MicrosoftGraph\Microsoft.Identity.Web.MicrosoftGraph.csproj" />
<ProjectReference Include="..\..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj" />
<PackageReference Include="Microsoft.Identity.Lab.Api" Version="0.11.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions tests/IntegrationTests/IntegrationTestService/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.LabInfrastructure;
using Microsoft.Identity.Lab.Api;

namespace IntegrationTestService
{
Expand All @@ -31,7 +31,7 @@ public Startup(IConfiguration configuration)
public void ConfigureServices(IServiceCollection services)
{
KeyVaultSecretsProvider keyVaultSecretsProvider = new();
string secret = keyVaultSecretsProvider.GetMsidLabSecret(TestConstants.OBOClientKeyVaultUri).Value;
string secret = keyVaultSecretsProvider.GetSecretByName(TestConstants.OBOClientKeyVaultUri).Value;

services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(Configuration, jwtBearerScheme: JwtBearerDefaults.AuthenticationScheme, subscribeToJwtBearerMiddlewareDiagnosticsEvents: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using System;
using Microsoft.Identity.Web.Test.LabInfrastructure;
using Microsoft.Identity.Lab.Api;
using Microsoft.Identity.Web.Test.Common;
using OpenQA.Selenium.Edge;
using System.IO;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
using System.Globalization;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.Identity.Lab.Api;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.LabInfrastructure;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
Expand Down Expand Up @@ -50,7 +50,7 @@ internal static void PerformLogin(
IWebDriver driver,
LabUser user)
{
UserInformationFieldIds fields = new UserInformationFieldIds();
UserInformationFieldIds fields = new UserInformationFieldIds(user);

EnterUsername(driver, user, fields);
EnterPassword(driver, user, fields);
Expand Down
4 changes: 3 additions & 1 deletion tests/IntegrationTests/WebAppUiTests/WebAppUiTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCoreMvcTestingVersion)" />
<PackageReference Include="Microsoft.Identity.Lab.Api" Version="0.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNetTestSdkVersion)" />
<PackageReference Include="Selenium.WebDriver" Version="$(SeleniumWebDriverVersion)" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="$(SeleniumWebDriverChromeDriverVersion)" />
Expand All @@ -25,7 +26,8 @@

<ItemGroup>
<ProjectReference Include="..\..\DevApps\WebAppCallsMicrosoftGraph\WebAppCallsMicrosoftGraph.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test\Microsoft.Identity.Web.Test.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Identity.Lab.Api;

namespace Microsoft.Identity.Web.Test.Common
{
public class UserInformationFieldIds
{
private readonly LabUser _user;

private string _passwordInputId;

private string _passwordSignInButtonId;

public string AADSignInButtonId => "idSIButton9";

public string AADUsernameInputId => "i0116";

public UserInformationFieldIds(LabUser user)

Check warning on line 20 in tests/Microsoft.Identity.Web.Test.Common/UserInformationFieldIds.cs

View workflow job for this annotation

GitHub Actions / IdWeb GitHub Action Test

Non-nullable field '_passwordInputId' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 20 in tests/Microsoft.Identity.Web.Test.Common/UserInformationFieldIds.cs

View workflow job for this annotation

GitHub Actions / IdWeb GitHub Action Test

Non-nullable field '_passwordSignInButtonId' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 20 in tests/Microsoft.Identity.Web.Test.Common/UserInformationFieldIds.cs

View workflow job for this annotation

GitHub Actions / IdWeb GitHub Action Test

Non-nullable field '_passwordInputId' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 20 in tests/Microsoft.Identity.Web.Test.Common/UserInformationFieldIds.cs

View workflow job for this annotation

GitHub Actions / IdWeb GitHub Action Test

Non-nullable field '_passwordSignInButtonId' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 20 in tests/Microsoft.Identity.Web.Test.Common/UserInformationFieldIds.cs

View workflow job for this annotation

GitHub Actions / Analyse

Non-nullable field '_passwordInputId' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 20 in tests/Microsoft.Identity.Web.Test.Common/UserInformationFieldIds.cs

View workflow job for this annotation

GitHub Actions / Analyse

Non-nullable field '_passwordSignInButtonId' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
_user = user;
}

public string GetPasswordInputId()
{
if (string.IsNullOrWhiteSpace(_passwordInputId))
{
DetermineFieldIds();
}

return _passwordInputId;
}

public string GetPasswordSignInButtonId()
{
if (string.IsNullOrWhiteSpace(_passwordSignInButtonId))
{
DetermineFieldIds();
}

return _passwordSignInButtonId;
}

private void DetermineFieldIds()
{
if (_user.UserType == UserType.Federated)
{
if (_user.FederationProvider == FederationProvider.AdfsV2)
{
_passwordInputId = "ContentPlaceHolder1_PasswordTextBox";
_passwordSignInButtonId = "ContentPlaceHolder1_SubmitButton";
}
else
{
_passwordInputId = "passwordInput";
_passwordSignInButtonId = "submitButton";
}
}
else if (_user.UserType == UserType.B2C)
{
DetermineB2CFieldIds();
}
else
{
_passwordInputId = "i0118";
_passwordSignInButtonId = "idSIButton9";
}
}

private void DetermineB2CFieldIds()
{
switch (_user.B2cProvider)
{
case B2CIdentityProvider.Local:
_passwordInputId = "password";
_passwordSignInButtonId = "next";
break;
case B2CIdentityProvider.Facebook:
_passwordInputId = "m_login_password";
_passwordSignInButtonId = "u_0_5";
break;
case B2CIdentityProvider.Google:
_passwordInputId = "Passwd";
_passwordSignInButtonId = "signIn";
break;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.Common.Mocks;
using Microsoft.Identity.Web.Test.Common.TestHelpers;
using Microsoft.Identity.Web.Test.LabInfrastructure;
using Microsoft.Identity.Lab.Api;
using Microsoft.Identity.Web.TokenCacheProviders.InMemory;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -47,7 +47,7 @@ public AcquireTokenForAppIntegrationTests(ITestOutputHelper output) // test set-
_output = output;

KeyVaultSecretsProvider keyVaultSecretsProvider = new();
_ccaSecret = keyVaultSecretsProvider.GetKeyVaultSecret().Value;
_ccaSecret = keyVaultSecretsProvider.GetSecretByName(TestConstants.BuildAutomationKeyVaultName).Value;

// Need the secret before building the services
if (!string.IsNullOrEmpty(_ccaSecret))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Identity.Client;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.LabInfrastructure;
using Microsoft.Identity.Lab.Api;
using Microsoft.Identity.Web.TokenCacheProviders.Distributed;
using Microsoft.Identity.Web.TokenCacheProviders.InMemory;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCoreMvcTestingVersion)" />
<PackageReference Include="Microsoft.Identity.Lab.Api" Version="0.11.0" />
<PackageReference Include="NSubstitute" Version="$(NSubstituteVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitRunnerVisualStudioVersion)">
Expand All @@ -33,7 +34,6 @@
<ProjectReference Include="..\..\src\Microsoft.Identity.Web\Microsoft.Identity.Web.csproj" />
<ProjectReference Include="..\IntegrationTests\IntegrationTestService\IntegrationTestService.csproj" />
<ProjectReference Include="..\Microsoft.Identity.Web.Test.Common\Microsoft.Identity.Web.Test.Common.csproj" />
<ProjectReference Include="..\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="$(BenchmarkDotNetVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="$(MicrosoftAspNetCoreMvcTestingVersion)" />
<PackageReference Include="Microsoft.Identity.Lab.Api" Version="0.11.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\IntegrationTests\IntegrationTestService\IntegrationTestService.csproj" />
<ProjectReference Include="..\..\Microsoft.Identity.Web.Test.LabInfrastructure\Microsoft.Identity.Web.Test.LabInfrastructure.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Identity.Client;
using Microsoft.Identity.Web.Test.Common;
using Microsoft.Identity.Web.Test.LabInfrastructure;
using Microsoft.Identity.Lab.Api;

namespace Microsoft.Identity.Web.Perf.Benchmark
{
Expand Down

0 comments on commit 1988005

Please sign in to comment.