mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 06:48:16 +08:00
hacked together load balancing reroutes in fileconfig (#211)
* hacked together load balancing reroutes in fileconfig * some renaming and refactoring * more renames * hacked away the old config json * test for issue 213 * renamed key * dont share ports * oops * updated docs * mvoed docs around * port being used
This commit is contained in:
@ -1,76 +1,76 @@
|
||||
using Ocelot.Configuration.Authentication;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
public class HashMatcherTests
|
||||
{
|
||||
private string _password;
|
||||
private string _hash;
|
||||
private string _salt;
|
||||
private bool _result;
|
||||
private HashMatcher _hashMatcher;
|
||||
|
||||
public HashMatcherTests()
|
||||
{
|
||||
_hashMatcher = new HashMatcher();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_match_hash()
|
||||
{
|
||||
var hash = "kE/mxd1hO9h9Sl2VhGhwJUd9xZEv4NP6qXoN39nIqM4=";
|
||||
var salt = "zzWITpnDximUNKYLiUam/w==";
|
||||
var password = "secret";
|
||||
|
||||
this.Given(x => GivenThePassword(password))
|
||||
.And(x => GivenTheHash(hash))
|
||||
.And(x => GivenTheSalt(salt))
|
||||
.When(x => WhenIMatch())
|
||||
.Then(x => ThenTheResultIs(true))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_not_match_hash()
|
||||
{
|
||||
var hash = "kE/mxd1hO9h9Sl2VhGhwJUd9xZEv4NP6qXoN39nIqM4=";
|
||||
var salt = "zzWITpnDximUNKYLiUam/w==";
|
||||
var password = "secret1";
|
||||
|
||||
this.Given(x => GivenThePassword(password))
|
||||
.And(x => GivenTheHash(hash))
|
||||
.And(x => GivenTheSalt(salt))
|
||||
.When(x => WhenIMatch())
|
||||
.Then(x => ThenTheResultIs(false))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenThePassword(string password)
|
||||
{
|
||||
_password = password;
|
||||
}
|
||||
|
||||
private void GivenTheHash(string hash)
|
||||
{
|
||||
_hash = hash;
|
||||
}
|
||||
|
||||
private void GivenTheSalt(string salt)
|
||||
{
|
||||
_salt = salt;
|
||||
}
|
||||
|
||||
private void WhenIMatch()
|
||||
{
|
||||
_result = _hashMatcher.Match(_password, _salt, _hash);
|
||||
}
|
||||
|
||||
private void ThenTheResultIs(bool expected)
|
||||
{
|
||||
_result.ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
using Ocelot.Configuration.Authentication;
|
||||
using Shouldly;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
|
||||
namespace Ocelot.UnitTests.Configuration
|
||||
{
|
||||
public class HashMatcherTests
|
||||
{
|
||||
private string _password;
|
||||
private string _hash;
|
||||
private string _salt;
|
||||
private bool _result;
|
||||
private HashMatcher _hashMatcher;
|
||||
|
||||
public HashMatcherTests()
|
||||
{
|
||||
_hashMatcher = new HashMatcher();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_match_hash()
|
||||
{
|
||||
var hash = "kE/mxd1hO9h9Sl2VhGhwJUd9xZEv4NP6qXoN39nIqM4=";
|
||||
var salt = "zzWITpnDximUNKYLiUam/w==";
|
||||
var password = "secret";
|
||||
|
||||
this.Given(x => GivenThePassword(password))
|
||||
.And(x => GivenTheHash(hash))
|
||||
.And(x => GivenTheSalt(salt))
|
||||
.When(x => WhenIMatch())
|
||||
.Then(x => ThenTheResultIs(true))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void should_not_match_hash()
|
||||
{
|
||||
var hash = "kE/mxd1hO9h9Sl2VhGhwJUd9xZEv4NP6qXoN39nIqM4=";
|
||||
var salt = "zzWITpnDximUNKYLiUam/w==";
|
||||
var password = "secret1";
|
||||
|
||||
this.Given(x => GivenThePassword(password))
|
||||
.And(x => GivenTheHash(hash))
|
||||
.And(x => GivenTheSalt(salt))
|
||||
.When(x => WhenIMatch())
|
||||
.Then(x => ThenTheResultIs(false))
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void GivenThePassword(string password)
|
||||
{
|
||||
_password = password;
|
||||
}
|
||||
|
||||
private void GivenTheHash(string hash)
|
||||
{
|
||||
_hash = hash;
|
||||
}
|
||||
|
||||
private void GivenTheSalt(string salt)
|
||||
{
|
||||
_salt = salt;
|
||||
}
|
||||
|
||||
private void WhenIMatch()
|
||||
{
|
||||
_result = _hashMatcher.Match(_password, _salt, _hash);
|
||||
}
|
||||
|
||||
private void ThenTheResultIs(bool expected)
|
||||
{
|
||||
_result.ShouldBe(expected);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user