public void UserAgent_OnSubsequentCalls() { // Arrange var expectedUserAgent = string.Format("ScannerMSBuild/{0}", typeof(WebClientDownloaderTest).Assembly.GetName().Version.ToDisplayString()); var downloader = new WebClientDownloader(null, null, null, new TestLogger()); // Act & Assert var userAgent = downloader.GetHeader(HttpRequestHeader.UserAgent); userAgent.Should().Be(expectedUserAgent); try { downloader.Download("http://DoesntMatterThisMayNotExistAndItsFine.com"); } catch (Exception) { // It doesn't matter if the request is successful or not. } // Check if the user agent is still present after the request. userAgent = downloader.GetHeader(HttpRequestHeader.UserAgent); userAgent.Should().Be(expectedUserAgent); }
public void UserAgent() { // Arrange var downloader = new WebClientDownloader(null, null, new TestLogger()); // Act var userAgent = downloader.GetHeader(HttpRequestHeader.UserAgent); // Assert var scannerVersion = typeof(WebClientDownloaderTest).Assembly.GetName().Version.ToDisplayString(); Assert.AreEqual($"ScannerMSBuild/{scannerVersion}", userAgent); }
public void Credentials() { WebClientDownloader downloader; downloader = new WebClientDownloader(null, null); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader("da39a3ee5e6b4b0d3255bfef95601890afd80709", null); Assert.AreEqual("Basic ZGEzOWEzZWU1ZTZiNGIwZDMyNTViZmVmOTU2MDE4OTBhZmQ4MDcwOTo=", downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader(null, "password"); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader("admin", "password"); Assert.AreEqual("Basic YWRtaW46cGFzc3dvcmQ=", downloader.GetHeader(HttpRequestHeader.Authorization)); }
public void Credentials() { WebClientDownloader downloader; downloader = new WebClientDownloader(null, null); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader("admin", null); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader(null, "password"); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader("admin", "password"); Assert.AreEqual("Basic YWRtaW46cGFzc3dvcmQ=", downloader.GetHeader(HttpRequestHeader.Authorization)); }
public void Credentials() { ILogger logger = new TestLogger(); WebClientDownloader downloader; downloader = new WebClientDownloader(null, null, logger); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader("da39a3ee5e6b4b0d3255bfef95601890afd80709", null, logger); Assert.AreEqual("Basic ZGEzOWEzZWU1ZTZiNGIwZDMyNTViZmVmOTU2MDE4OTBhZmQ4MDcwOTo=", downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader(null, "password", logger); Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization)); downloader = new WebClientDownloader("admin", "password", logger); Assert.AreEqual("Basic YWRtaW46cGFzc3dvcmQ=", downloader.GetHeader(HttpRequestHeader.Authorization)); }