Skip to content

Commit

Permalink
Fixed GetLiveContextAsync to not use the PnP Management Shell app a…
Browse files Browse the repository at this point in the history
…nymore
  • Loading branch information
bjansen committed Sep 17, 2024
1 parent f03ffe7 commit d1442a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/sdk/PnP.Core.Test.Common/Utilities/TestCommonBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -224,10 +225,11 @@ internal async Task<PnPContext> 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;
}
Expand Down
5 changes: 3 additions & 2 deletions src/sdk/PnP.Core.Test/Utilities/TestCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down

0 comments on commit d1442a1

Please sign in to comment.