本文整理汇总了C#中JabbR.Services.ChatService.AuthenticateUser方法的典型用法代码示例。如果您正苦于以下问题:C# ChatService.AuthenticateUser方法的具体用法?C# ChatService.AuthenticateUser怎么用?C# ChatService.AuthenticateUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JabbR.Services.ChatService
的用法示例。
在下文中一共展示了ChatService.AuthenticateUser方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowsIfUserPasswordNotSet
public void ThrowsIfUserPasswordNotSet()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "foo"
});
var service = new ChatService(repository);
Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", null));
}
示例2: ThrowsIfUserDoesNotExist
public void ThrowsIfUserDoesNotExist()
{
var repository = new InMemoryRepository();
var service = new ChatService(repository);
Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", "foo"));
}
示例3: ThrowsIfUserPasswordDoesNotMatch
public void ThrowsIfUserPasswordDoesNotMatch()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "foo",
HashedPassword = "passwords".ToSha256()
});
var service = new ChatService(repository);
Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", "foo"));
}
示例4: ThrowsIfUserPasswordNotSet
public void ThrowsIfUserPasswordNotSet()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "SomeUser"
});
var service = new ChatService(repository, new Mock<ICryptoService>().Object);
Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", "password"));
}
示例5: DoesNotThrowIfPasswordsMatch
public void DoesNotThrowIfPasswordsMatch()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "foo",
HashedPassword = "passwords".ToSha256()
});
var service = new ChatService(repository);
service.AuthenticateUser("foo", "passwords");
}
示例6: EnsuresStoredPasswordIsSalted
public void EnsuresStoredPasswordIsSalted()
{
var crypto = new Mock<ICryptoService>();
crypto.Setup(c => c.CreateSalt()).Returns("salted");
var repository = new InMemoryRepository();
var user = new ChatUser
{
Name = "foo",
HashedPassword = "3049a1f8327e0215ea924b9e4e04cd4b0ff1800c74a536d9b81d3d8ced9994d3"
};
repository.Add(user);
var service = new ChatService(repository, crypto.Object);
service.AuthenticateUser("foo", "passwords");
Assert.Equal("salted", user.Salt);
Assert.Equal("9ce70d2ab42c9a9012ed6f80f85ab400ef1483f70e227a42b6d77faea204db26", user.HashedPassword);
}
示例7: DoesNotThrowIfSaltedPasswordsMatch
public void DoesNotThrowIfSaltedPasswordsMatch()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "foo",
Salt = "salted",
HashedPassword = "8f5793009fe15c2227e3528d0507413a83dff10635d3a6acf1ba3229a03380d8"
});
var service = new ChatService(repository, new Mock<ICryptoService>().Object);
service.AuthenticateUser("foo", "password");
}
示例8: DoesNotThrowIfPasswordsMatch
public void DoesNotThrowIfPasswordsMatch()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "foo",
HashedPassword = "3049a1f8327e0215ea924b9e4e04cd4b0ff1800c74a536d9b81d3d8ced9994d3"
});
var service = new ChatService(repository, new Mock<ICryptoService>().Object);
service.AuthenticateUser("foo", "passwords");
}
示例9: ThrowsIfUserPasswordDoesNotMatch
public void ThrowsIfUserPasswordDoesNotMatch()
{
var repository = new InMemoryRepository();
repository.Add(new ChatUser
{
Name = "SomeUser",
Salt = "salt",
HashedPassword = "passwords".ToSha256("salt")
});
var service = new ChatService(new Mock<ICache>().Object, repository, new Mock<ICryptoService>().Object);
Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", "foo"));
}
示例10: ThrowsIfUserDoesNotExist
public void ThrowsIfUserDoesNotExist()
{
var repository = new InMemoryRepository();
var service = new ChatService(new Mock<ICache>().Object, repository, new Mock<ICryptoService>().Object);
Assert.Throws<InvalidOperationException>(() => service.AuthenticateUser("SomeUser", "foo"));
}