Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from AutomatedArchitecture/feature/invalid-pa…
…ssword-tfs Feature: invalid password tfs
- Loading branch information
Showing
109 changed files
with
161 additions
and
375,841 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,3 +108,5 @@ Desktop.ini | |
|
||
Releases/Updates | ||
/SirenOfShame.Extruder/Services/MySosOnlineService.cs | ||
.vs/ | ||
packages/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
SirenOfShame.Test.Unit/TfsRestServices/TfsRestWatcherTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using Moq; | ||
using NUnit.Framework; | ||
using SirenOfShame.Lib.Exceptions; | ||
using SirenOfShame.Lib.Settings; | ||
using SirenOfShame.Lib.Watcher; | ||
using TfsRestServices; | ||
|
||
namespace SirenOfShame.Test.Unit.TfsRestServices | ||
{ | ||
public class MyTfsRestWatcher : TfsRestWatcher | ||
{ | ||
private readonly IEnumerable<BuildDefinitionSetting> _buildDefinitions; | ||
|
||
public MyTfsRestWatcher(TfsRestService tfsRestService, IEnumerable<BuildDefinitionSetting> buildDefinitions, CiEntryPointSetting ciEntryPointSetting) : base(null, null) | ||
{ | ||
_buildDefinitions = buildDefinitions; | ||
_service = tfsRestService; | ||
CiEntryPointSetting = ciEntryPointSetting; | ||
} | ||
|
||
protected override IEnumerable<BuildDefinitionSetting> GetAllWatchedBuildDefinitions() | ||
{ | ||
return _buildDefinitions; | ||
} | ||
|
||
public IList<BuildStatus> MyGetBuildStatus() | ||
{ | ||
return GetBuildStatus(); | ||
} | ||
} | ||
|
||
[TestFixture] | ||
public class TfsRestWatcherTest | ||
{ | ||
[Test] | ||
public void GivenNullUrlInCiEntryPointSetting_WhenGettingBuildStatus_ThenSosException() | ||
{ | ||
// arrange | ||
var ciEntryPointSetting = new CiEntryPointSetting(); | ||
var tfsRestWatcher = new MyTfsRestWatcher(null, new BuildDefinitionSetting[] { }, ciEntryPointSetting); | ||
|
||
// act | ||
Assert.Throws<SosException>(() => tfsRestWatcher.MyGetBuildStatus(), "TFS URL is null or empty") | ||
; | ||
} | ||
|
||
[Test] | ||
public void GivenWebExceptionRemoteNameCouldNotBeResolved_WhenGettingBuildStatus_ThenServerUnavailableException() | ||
{ | ||
// arrange | ||
var buildDefinitionSettings = new[] {new BuildDefinitionSetting()}; | ||
var tfsRestService = new Mock<TfsRestService>(); | ||
var ciEntryPointSetting = new CiEntryPointSetting { Url = "url" }; | ||
tfsRestService.Setup(i => i.GetBuildsStatuses(ciEntryPointSetting, buildDefinitionSettings)) | ||
.ThrowsAsync(new WebException("The remote name could not be resolved:")); | ||
var tfsRestWatcher = new MyTfsRestWatcher(tfsRestService.Object, buildDefinitionSettings, ciEntryPointSetting); | ||
|
||
// assert & act | ||
Assert.Throws<ServerUnavailableException>(() => | ||
tfsRestWatcher.MyGetBuildStatus() | ||
); | ||
} | ||
|
||
[Test] | ||
public void GivenWebExceptionUnableConnectRemoteServer_WhenGettingBuildStatus_ThenServerUnavailableException() | ||
{ | ||
// arrange | ||
var buildDefinitionSettings = new[] {new BuildDefinitionSetting()}; | ||
var tfsRestService = new Mock<TfsRestService>(); | ||
var ciEntryPointSetting = new CiEntryPointSetting { Url = "url" }; | ||
tfsRestService.Setup(i => i.GetBuildsStatuses(ciEntryPointSetting, buildDefinitionSettings)) | ||
.ThrowsAsync(new WebException("Unable to connect to the remote server")); | ||
var tfsRestWatcher = new MyTfsRestWatcher(tfsRestService.Object, buildDefinitionSettings, ciEntryPointSetting); | ||
|
||
// assert & act | ||
Assert.Throws<ServerUnavailableException>(() => | ||
tfsRestWatcher.MyGetBuildStatus() | ||
); | ||
} | ||
|
||
[Test] | ||
public void GivenHttpRequestException_WhenGettingBuildStatus_ThenServerUnavailableException() | ||
{ | ||
// arrange | ||
var buildDefinitionSettings = new[] {new BuildDefinitionSetting()}; | ||
var tfsRestService = new Mock<TfsRestService>(); | ||
var ciEntryPointSetting = new CiEntryPointSetting { Url = "url" }; | ||
tfsRestService.Setup(i => i.GetBuildsStatuses(ciEntryPointSetting, buildDefinitionSettings)) | ||
.ThrowsAsync(new System.Net.Http.HttpRequestException("Unable to connect to the remote server")); | ||
var tfsRestWatcher = new MyTfsRestWatcher(tfsRestService.Object, buildDefinitionSettings, ciEntryPointSetting); | ||
|
||
// assert & act | ||
Assert.Throws<ServerUnavailableException>(() => | ||
tfsRestWatcher.MyGetBuildStatus() | ||
); | ||
} | ||
|
||
[Test] | ||
public void GivenHttpRequestExceptionWith401InMessage_WhenGettingBuildStatus_ThenInvalidCredentialsException() | ||
{ | ||
// arrange | ||
var buildDefinitionSettings = new[] { new BuildDefinitionSetting() }; | ||
var tfsRestService = new Mock<TfsRestService>(); | ||
var ciEntryPointSetting = new CiEntryPointSetting { Url = "url" }; | ||
tfsRestService.Setup(i => i.GetBuildsStatuses(ciEntryPointSetting, buildDefinitionSettings)) | ||
.ThrowsAsync(new System.Net.Http.HttpRequestException("Response status code does not indicate success: 401 (Unauthorized).")); | ||
var tfsRestWatcher = new MyTfsRestWatcher(tfsRestService.Object, buildDefinitionSettings, ciEntryPointSetting); | ||
|
||
// assert & act | ||
Assert.Throws<InvalidCredentialsException>(() => | ||
tfsRestWatcher.MyGetBuildStatus() | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Castle.Core" version="4.2.1" targetFramework="net45" /> | ||
<package id="log4net" version="2.0.3" targetFramework="net45" /> | ||
<package id="Moq" version="4.0.10827" targetFramework="net40" /> | ||
<package id="Moq" version="4.7.145" targetFramework="net45" /> | ||
<package id="Newtonsoft.Json" version="6.0.5" targetFramework="net45" /> | ||
<package id="NUnit" version="2.6.3" targetFramework="net40" /> | ||
<package id="NUnit" version="3.9.0" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-190 KB
packages/Microsoft.AspNet.SignalR.Client.2.1.0/Microsoft.AspNet.SignalR.Client.2.1.0.nupkg
Binary file not shown.
Oops, something went wrong.