本文整理汇总了C#中IAuthenticationService.Authenticate方法的典型用法代码示例。如果您正苦于以下问题:C# IAuthenticationService.Authenticate方法的具体用法?C# IAuthenticationService.Authenticate怎么用?C# IAuthenticationService.Authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAuthenticationService
的用法示例。
在下文中一共展示了IAuthenticationService.Authenticate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: verify_receive_appropriate_error_message_when_user_provides_a_bad_user_name_or_password
public void verify_receive_appropriate_error_message_when_user_provides_a_bad_user_name_or_password()
{
AuthenticationStatus authStatus = null;
Story authenticateUserStory = new Story("Authenticate User");
authenticateUserStory.AsA("Unauthenticated user")
.IWant("supply my user name and password to the login form")
.SoThat("I can authenticate to the application");
authenticateUserStory
.WithScenario("User provides an invalid user name")
.Given("My user name and password are ", "Big Daddy", "Gobldegook", delegate(string userName, string password) { UserRepositoryFactory factory = _mock.DynamicMock<UserRepositoryFactory>();
using (_mock.Record())
{
Expect.Call(factory.Create(userName, password))
.Return(_mock.DynamicMock<IUserRepository>());
}
_user = factory.Create(userName, password); })
.When("I authenticate the user", delegate {_service = _mock.DynamicMock<IAuthenticationService>();
using (_mock.Record())
{
Expect.Call(_service.Authenticate(_user))
.Return(new AuthenticationStatus(new Exception("Bad Username or Password")));
}
authStatus = _service.Authenticate(_user);})
.Then("I should receive an Authentication status of", Status.Failed, delegate(Status expectedStatus) {Assert.AreEqual(expectedStatus, authStatus.Status);});
}
示例2: SecurityModule
public SecurityModule(IContainer container, IAuthenticationService authenticationService)
{
logger.Debug("Instantiate SecurityModule.");
Post[RouterPattern.Security.VerifyToken] = (parameters =>
{
return parameters;
});
Get[RouterPattern.Security.Authenticate] = (parameters =>
{
return "test";
});
Post[RouterPattern.Security.Authenticate] = parameters =>
{
try
{
var authenticationBody = new StreamReader(this.Request.Body).ReadToEnd();
logger.Debug("DeserializeObject IAuthenticationRequest.");
var authenticationRequest = JsonIocConvert.DeserializeObject<IAuthenticationRequest>(authenticationBody, container);
// check whether the request is valid
if (authenticationRequest.IsValid)
{
logger.Debug("IAuthenticationRequest is valid.");
// authenticate the user
var authenticatonResult = authenticationService.Authenticate(authenticationRequest.Username, authenticationRequest.Password);
// return authentication results as JSON
return Response.AsJson<IAuthenticationResult>(authenticatonResult);
}
else
{
logger.Warn("IAuthenticationRequest is not valid.");
return BadRequest(authenticationService.InvalidRequest());
}
}
catch (Exception e)
{
logger.Error(e);
// TODO move this away from authentication service (inner method call)
return BadRequest(authenticationService.ErrorRequest());
}
};
}
示例3: verify_receive_appropriate_success_message_when_user_provides_a_good_user_name_and_password
public void verify_receive_appropriate_success_message_when_user_provides_a_good_user_name_and_password()
{
Story authenticateUserStory = new Story("Authenticate User");
authenticateUserStory.AsA("USer with a valid user name and password")
.IWant("supply my user name and password to the login form")
.SoThat("I can authenticate to the application");
authenticateUserStory
.WithScenario("User provides a valid user name and password")
.Given("My user name and password are ", "mmann", "validpassword_1", delegate(string userName, string password) { UserRepositoryFactory factory = _mock.DynamicMock<UserRepositoryFactory>();
using (_mock.Record())
{
Expect.Call(factory.Create(userName, password))
.Return(_mock.DynamicMock<IUserRepository>());
}
_user = factory.Create(userName, password); })
.When("I authenticate the user", delegate {_service = _mock.DynamicMock<IAuthenticationService>();
using (_mock.Record())
{
Expect.Call(_service.Authenticate(_user))
.Return(new AuthenticationStatus());
}
_authStatus = _service.Authenticate(_user);})
.Then("I should receive an Authentication status of", Status.Success, delegate(Status expectedStatus) {Assert.AreEqual(expectedStatus, _authStatus.Status);});
}
示例4: ResolveDependencies
private void ResolveDependencies(Veyron.App app)
{
PaletteManager.ThemesJSon = "[]";
var loggerMock = Mock.Create<IClientLogger>();
var communicationServiceMock = Mock.Create<ICommunicationService>();
_authenticateServiceMock = Mock.Create<IAuthenticationService>();
Mock.Arrange(() => _authenticateServiceMock.Authenticate(Arg.IsAny<string>()))
.Returns((new TaskCompletionSource<object>()).Task);
var clientInfoMock = Mock.Create<IClientInfoService>();
_eventAggregatorMock = Mock.Create<IEventAggregator>();
var mainViewModelMock = Mock.Create<IShell>();
app.Logger = loggerMock;
app.CommunicationService = communicationServiceMock;
app.AuthenticationService = _authenticateServiceMock;
app.ClientInfoService = clientInfoMock;
app.TheEventAggregator = _eventAggregatorMock;
app.MainViewModel = mainViewModelMock;
}