/
with_internal_authentication_provider.cs
60 lines (51 loc) · 1.86 KB
/
with_internal_authentication_provider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Security.Principal;
using EventStore.Core.Authentication;
using EventStore.Core.Helpers;
using EventStore.Core.Messaging;
using EventStore.Core.Tests.Helpers;
namespace EventStore.Core.Tests.Authentication {
public class with_internal_authentication_provider : TestFixtureWithExistingEvents {
protected new IODispatcher _ioDispatcher;
protected InternalAuthenticationProvider _internalAuthenticationProvider;
protected void SetUpProvider() {
_ioDispatcher = new IODispatcher(_bus, new PublishEnvelope(_bus));
_bus.Subscribe(_ioDispatcher.BackwardReader);
_bus.Subscribe(_ioDispatcher.ForwardReader);
_bus.Subscribe(_ioDispatcher.Writer);
_bus.Subscribe(_ioDispatcher.StreamDeleter);
_bus.Subscribe(_ioDispatcher.Awaker);
_bus.Subscribe(_ioDispatcher);
PasswordHashAlgorithm passwordHashAlgorithm = new StubPasswordHashAlgorithm();
_internalAuthenticationProvider =
new InternalAuthenticationProvider(_ioDispatcher, passwordHashAlgorithm, 1000, false);
_bus.Subscribe(_internalAuthenticationProvider);
}
}
class TestAuthenticationRequest : AuthenticationRequest {
private readonly Action _unauthorized;
private readonly Action<IPrincipal> _authenticated;
private readonly Action _error;
private readonly Action _notReady;
public TestAuthenticationRequest(string name, string suppliedPassword, Action unauthorized,
Action<IPrincipal> authenticated, Action error, Action notReady)
: base("test", name, suppliedPassword) {
_unauthorized = unauthorized;
_authenticated = authenticated;
_error = error;
_notReady = notReady;
}
public override void Unauthorized() {
_unauthorized();
}
public override void Authenticated(IPrincipal principal) {
_authenticated(principal);
}
public override void Error() {
_error();
}
public override void NotReady() {
_notReady();
}
}
}