public void DownloadFile_WhenUnsecureConnectionType_TrySecureDownloadFirst() { secureFilePayloadServiceMock.IsSecureConnection(filePayload).Returns(false); systemUnderTest.DownloadFile(filePayload); Received.InOrder(() => { secureFilePayloadServiceMock.EnableSecureFilePayload(filePayload); downloadServiceMock.DownloadFile(filePayload); }); }
public void EnableSecureFilePayload(FilePayload filePayload) { if (testHarnessSettingsService.IsSecureFilePayloadDisabled()) { return; } secureFilePayloadService.EnableSecureFilePayload(filePayload); }
public void EnableSecureFilePayload_WhenHttpConnection_ChangesToHttps() { filePayload.DownloadUri = new Uri("http://localhost/"); systemUnderTest.EnableSecureFilePayload(filePayload); Assert.That(filePayload.DownloadUri.Scheme, Is.EqualTo(Uri.UriSchemeHttps)); loggingServiceMock.Received() .LogVerbose( $"Changing scheme http to https{Environment.NewLine}Old Uri: http://localhost/{Environment.NewLine}New Uri: https://localhost/"); }
public void DownloadFile(FilePayload filePayload) { bool originalWasNotSecure = !secureFilePayloadService.IsSecureConnection(filePayload); try { secureFilePayloadService.EnableSecureFilePayload(filePayload); downloadService.DownloadFile(filePayload); } catch (WebException webException) { loggingService.LogException(webException); if (originalWasNotSecure) { secureFilePayloadService.DisableSecureFilePayload(filePayload); downloadService.DownloadFile(filePayload); } else { throw; } } }