Skip to content

Commit

Permalink
SONARMSBRU-194 Allow using SonarQube tokens for authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
dbolkensteyn committed Dec 11, 2015
1 parent c3bd4e4 commit 235d185
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion SonarQube.TeamBuild.PreProcessor/WebClientDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ public WebClientDownloader(string username, string password)
// SONARMSBRU-169 Support TLS versions 1.0, 1.1 and 1.2
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;

if (password == null)
{
password = "";
}

this.client = new WebClient();
if (username != null && password != null)
if (username != null)
{
if (username.Contains(':'))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public void Credentials()
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("da39a3ee5e6b4b0d3255bfef95601890afd80709", null);
Assert.AreEqual("Basic ZGEzOWEzZWU1ZTZiNGIwZDMyNTViZmVmOTU2MDE4OTBhZmQ4MDcwOTo=", downloader.GetHeader(HttpRequestHeader.Authorization));

downloader = new WebClientDownloader(null, "password");
Assert.AreEqual(null, downloader.GetHeader(HttpRequestHeader.Authorization));
Expand Down

0 comments on commit 235d185

Please sign in to comment.