예제 #1
0
 public TorSharpProxy(TorSharpSettings settings)
 {
     _settings = settings;
     _torPasswordHasher = new TorPasswordHasher(new RandomFactory());
     _toolRunner =
         settings.ToolRunnerType == ToolRunnerType.VirtualDesktop
             ? (IToolRunner)new VirtualDesktopToolRunner()
             : new SimpleToolRunner();
 }
예제 #2
0
        private void MatchesExpectedHashedPassword(string password, string expected)
        {
            // Arrange
            var salt = GetSalt(expected);

            var random = new Mock<IRandom>();
            random
                .Setup(x => x.GetBytes(It.IsAny<byte[]>()))
                .Callback<byte[]>(x => Buffer.BlockCopy(salt, 0, x, 0, Math.Min(salt.Length, x.Length)));

            var randomFactory = new Mock<IRandomFactory>();
            randomFactory
                .Setup(x => x.Create())
                .Returns(random.Object);

            var torPasswordHasher = new TorPasswordHasher(randomFactory.Object);

            // Act
            var actual = torPasswordHasher.HashPassword(password);

            // Assert
            Assert.Equal(expected, actual);
        }