Skip to content

Commit 36eb3fa

Browse files
committed
Sync IEngine.SetDownloadSource with native side.
Fixes wixtoolset/issues#9018
1 parent ed19d16 commit 36eb3fa

File tree

7 files changed

+67
-8
lines changed

7 files changed

+67
-8
lines changed

src/api/burn/WixToolset.BootstrapperApplicationApi/Engine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,9 @@ public void SetLocalSource(string packageOrContainerId, string payloadId, string
271271
}
272272

273273
/// <inheritdoc/>
274-
public void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password)
274+
public void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password, string authorizationHeader)
275275
{
276-
this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password);
276+
this.engine.SetDownloadSource(packageOrContainerId, payloadId, url, user, password, authorizationHeader);
277277
}
278278

279279
/// <inheritdoc/>

src/api/burn/WixToolset.BootstrapperApplicationApi/IBootstrapperEngine.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,15 @@ void SetLocalSource(
129129
);
130130

131131
/// <summary>
132-
/// See <see cref="IEngine.SetDownloadSource(string, string, string, string, string)"/>.
132+
/// See <see cref="IEngine.SetDownloadSource(string, string, string, string, string, string)"/>.
133133
/// </summary>
134134
void SetDownloadSource(
135135
[MarshalAs(UnmanagedType.LPWStr)] string wzPackageOrContainerId,
136136
[MarshalAs(UnmanagedType.LPWStr)] string wzPayloadId,
137137
[MarshalAs(UnmanagedType.LPWStr)] string wzUrl,
138138
[MarshalAs(UnmanagedType.LPWStr)] string wzUser,
139-
[MarshalAs(UnmanagedType.LPWStr)] string wzPassword
139+
[MarshalAs(UnmanagedType.LPWStr)] string wzPassword,
140+
[MarshalAs(UnmanagedType.LPWStr)] string wzAuthorizationHeader
140141
);
141142

142143
/// <summary>

src/api/burn/WixToolset.BootstrapperApplicationApi/IDefaultBootstrapperApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public interface IDefaultBootstrapperApplication : IBootstrapperApplication
3737
/// <summary>
3838
/// Fired when the engine has begun acquiring the payload or container.
3939
/// The BA can change the source using <see cref="IEngine.SetLocalSource(String, String, String)"/>
40-
/// or <see cref="IEngine.SetDownloadSource(String, String, String, String, String)"/>.
40+
/// or <see cref="IEngine.SetDownloadSource(String, String, String, String, String, String)"/>.
4141
/// </summary>
4242
event EventHandler<CacheAcquireBeginEventArgs> CacheAcquireBegin;
4343

4444
/// <summary>
4545
/// Fired when the engine has completed the acquisition of the payload or container.
4646
/// The BA can change the source using <see cref="IEngine.SetLocalSource(String, String, String)"/>
47-
/// or <see cref="IEngine.SetDownloadSource(String, String, String, String, String)"/>.
47+
/// or <see cref="IEngine.SetDownloadSource(String, String, String, String, String, String)"/>.
4848
/// </summary>
4949
event EventHandler<CacheAcquireCompleteEventArgs> CacheAcquireComplete;
5050

src/api/burn/WixToolset.BootstrapperApplicationApi/IEngine.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ public interface IEngine
174174
/// <param name="url">The new url.</param>
175175
/// <param name="user">The user name for proxy authentication.</param>
176176
/// <param name="password">The password for proxy authentication.</param>
177-
void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password);
177+
/// <param name="authorizationHeader">Additional proxy authentication header. Not currently used.</param>
178+
void SetDownloadSource(string packageOrContainerId, string payloadId, string url, string user, string password, string authorizationHeader);
178179

179180
/// <summary>
180181
/// Sets numeric variables for the engine.

src/test/burn/TestBA/TestBA.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class TestBA : BootstrapperApplication
4141
private int cancelOnProgressAtProgress;
4242
private int retryExecuteFilesInUse;
4343
private bool rollingBack;
44+
private string forceDownloadSource;
4445

4546
private IBootstrapperCommand Command { get; set; }
4647

@@ -375,6 +376,12 @@ protected override void OnCachePackageBegin(CachePackageBeginEventArgs args)
375376
{
376377
this.Log(" CancelCacheAtProgress: {0}", this.cancelCacheAtProgress);
377378
}
379+
380+
this.forceDownloadSource = this.ReadPackageAction(args.PackageId, "ForceDownloadSource");
381+
if (!String.IsNullOrEmpty(this.forceDownloadSource))
382+
{
383+
this.Log(" ForceDownloadSource: {0}", this.forceDownloadSource);
384+
}
378385
}
379386

380387
protected override void OnCachePackageNonVitalValidationFailure(CachePackageNonVitalValidationFailureEventArgs args)
@@ -387,6 +394,29 @@ protected override void OnCachePackageNonVitalValidationFailure(CachePackageNonV
387394
this.Log("OnCachePackageNonVitalValidationFailure() - id: {0}, default: {1}, requested: {2}", args.PackageId, args.Recommendation, args.Action);
388395
}
389396

397+
protected override void OnCacheAcquireResolving(CacheAcquireResolvingEventArgs args)
398+
{
399+
if (!String.IsNullOrEmpty(this.forceDownloadSource))
400+
{
401+
args.Action = CacheResolveOperation.Download;
402+
var url = String.Format(this.forceDownloadSource, args.PayloadId);
403+
404+
this.Log("OnCacheAcquireResolving: {0} => {1}", this.forceDownloadSource, url);
405+
406+
this.engine.SetDownloadSource(
407+
String.Empty,
408+
args.PayloadId,
409+
url,
410+
String.Empty,
411+
String.Empty,
412+
String.Empty);
413+
}
414+
else
415+
{
416+
this.Log("OnCacheAcquireResolving not forcing download");
417+
}
418+
}
419+
390420
protected override void OnCacheAcquireProgress(CacheAcquireProgressEventArgs args)
391421
{
392422
this.Log("OnCacheAcquireProgress() - container/package: {0}, payload: {1}, progress: {2}, total: {3}, overall progress: {4}%", args.PackageOrContainerId, args.PayloadId, args.Progress, args.Total, args.OverallPercentage);

src/test/burn/WixToolsetTest.BurnE2E/FailureTests.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace WixToolsetTest.BurnE2E
44
{
5-
using System.Threading;
65
using WixTestTools;
76
using WixToolset.BootstrapperApplicationApi;
87
using Xunit;
@@ -12,6 +11,24 @@ public class FailureTests : BurnE2ETests
1211
{
1312
public FailureTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { }
1413

14+
[RuntimeFact]
15+
public void CanSetDownloadSourceAndForceDownload()
16+
{
17+
var packageA = this.CreatePackageInstaller("PackageA");
18+
var bundleA = this.CreateBundleInstaller("BundleA");
19+
var testBAController = this.CreateTestBAController();
20+
21+
testBAController.SetPackageForceDownloadSource("PackageA", "https://1e1bf2be1c384fd1a0c4c0500eef971b/downloads/payloads/{0}");
22+
23+
packageA.VerifyInstalled(false);
24+
25+
bundleA.VerifyUnregisteredAndRemovedFromPackageCache();
26+
27+
bundleA.Install(0x2ee7/*ERROR_INTERNET_NAME_NOT_RESOLVED*/);
28+
29+
packageA.VerifyInstalled(false);
30+
}
31+
1532
[RuntimeFact]
1633
public void CanCancelExePackageAndAbandonIt()
1734
{

src/test/burn/WixToolsetTest.BurnE2E/Utilities/TestBAController.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ public void SetPackageCancelExecuteAtProgress(string packageId, int? cancelPoint
107107
this.SetPackageState(packageId, "CancelExecuteAtProgress", cancelPoint.HasValue ? cancelPoint.ToString() : null);
108108
}
109109

110+
/// <summary>
111+
/// Forces a download action and sets the download source.
112+
/// </summary>
113+
/// <param name="packageId">Package identity.</param>
114+
/// <param name="actionName">The URL format string.</param>
115+
public void SetPackageForceDownloadSource(string packageId, string url)
116+
{
117+
this.SetPackageState(packageId, "ForceDownloadSource", url);
118+
}
119+
110120
/// <summary>
111121
/// Cancels the execute of a package at the next progess after the specified MSI action start.
112122
/// </summary>

0 commit comments

Comments
 (0)