From d1442a108e70c50cbd100581ed66ed7b6c195141 Mon Sep 17 00:00:00 2001 From: bjansen Date: Tue, 17 Sep 2024 19:30:07 +0200 Subject: [PATCH] Fixed `GetLiveContextAsync` to not use the PnP Management Shell app anymore --- src/sdk/PnP.Core.Test.Common/Utilities/TestCommonBase.cs | 4 +++- src/sdk/PnP.Core.Test/Utilities/TestCommon.cs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sdk/PnP.Core.Test.Common/Utilities/TestCommonBase.cs b/src/sdk/PnP.Core.Test.Common/Utilities/TestCommonBase.cs index 6d1746baf7..0a8d50bb45 100644 --- a/src/sdk/PnP.Core.Test.Common/Utilities/TestCommonBase.cs +++ b/src/sdk/PnP.Core.Test.Common/Utilities/TestCommonBase.cs @@ -23,6 +23,7 @@ public class TestCommonBase protected const string PnPCoreSDKTestSite = "pnpcoresdktestsite"; protected const string PnPCoreSDKTestUser = "pnpcoresdktestuser"; protected const string PnPCoreSDKTestUserPassword = "pnpcoresdktestuserpassword"; + protected const string PnPCoreSDKTestClientId = "pnpcoresdktestclientid"; protected IPnPTestContextFactory pnpContextFactoryCache; protected static readonly SemaphoreSlim semaphoreSlimFactory = new SemaphoreSlim(1); @@ -224,10 +225,11 @@ internal async Task GetLiveContextAsync() var pnpCoreSDKTestUserPassword = Environment.GetEnvironmentVariable(PnPCoreSDKTestUserPassword); var pnpCoreSDKTestUser = Environment.GetEnvironmentVariable(PnPCoreSDKTestUser); var pnpCoreSDKTestSite = Environment.GetEnvironmentVariable(PnPCoreSDKTestSite); + var pnpCoreSDKTestClientId = Environment.GetEnvironmentVariable(PnPCoreSDKTestClientId); var pwd = new NetworkCredential(null, pnpCoreSDKTestUserPassword).SecurePassword; - var context = await factory.CreateLiveAsync(new Uri(pnpCoreSDKTestSite), new UsernamePasswordAuthenticationProvider(null, null, pnpCoreSDKTestUser, pwd)).ConfigureAwait(false); + var context = await factory.CreateLiveAsync(new Uri(pnpCoreSDKTestSite), new UsernamePasswordAuthenticationProvider(pnpCoreSDKTestClientId, null, pnpCoreSDKTestUser, pwd)).ConfigureAwait(false); return context; } diff --git a/src/sdk/PnP.Core.Test/Utilities/TestCommon.cs b/src/sdk/PnP.Core.Test/Utilities/TestCommon.cs index 89d33860d0..2f5964ff8b 100644 --- a/src/sdk/PnP.Core.Test/Utilities/TestCommon.cs +++ b/src/sdk/PnP.Core.Test/Utilities/TestCommon.cs @@ -33,9 +33,10 @@ internal static void PnPCoreSDKTestUserSetup() var pnpCoreSDKTestUserPassword = Environment.GetEnvironmentVariable(PnPCoreSDKTestUserPassword); var pnpCoreSDKTestUser = Environment.GetEnvironmentVariable(PnPCoreSDKTestUser); var pnpCoreSDKTestSite = Environment.GetEnvironmentVariable(PnPCoreSDKTestSite); - if (string.IsNullOrEmpty(pnpCoreSDKTestUser) || string.IsNullOrEmpty(pnpCoreSDKTestUserPassword) || string.IsNullOrEmpty(pnpCoreSDKTestSite)) + var pnpCoreSDKTestClientId = Environment.GetEnvironmentVariable(PnPCoreSDKTestClientId); + if (string.IsNullOrEmpty(pnpCoreSDKTestUser) || string.IsNullOrEmpty(pnpCoreSDKTestUserPassword) || string.IsNullOrEmpty(pnpCoreSDKTestSite) || string.IsNullOrEmpty(pnpCoreSDKTestClientId)) { - Assert.Inconclusive("Skipping test because 'live' tests are not configured. Add pnpcoresdktestsite, pnpcoresdktestuser and pnpcoresdktestuserpassword environment variables"); + Assert.Inconclusive("Skipping test because 'live' tests are not configured. Add pnpcoresdktestsite, pnpcoresdktestuser, pnpcoresdktestuserpassword and pnpCoreSDKTestClientId environment variables"); } }