public async Task ValidateClientCredentialsAsync_DelegatesToApplicationManager() { // Arrange var options = new IdentityServiceOptions(); var store = new Mock <IApplicationStore <IdentityServiceApplication> >(); store.Setup(s => s.FindByClientIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new IdentityServiceApplication()); store.As <IApplicationClientSecretStore <IdentityServiceApplication> >() .Setup(s => s.HasClientSecretAsync(It.IsAny <IdentityServiceApplication>(), It.IsAny <CancellationToken>())) .ReturnsAsync(false); var manager = new ApplicationManager <IdentityServiceApplication>( Options.Create(new ApplicationOptions()), store.Object, Mock.Of <IPasswordHasher <IdentityServiceApplication> >(), Array.Empty <IApplicationValidator <IdentityServiceApplication> >(), Mock.Of <ILogger <ApplicationManager <IdentityServiceApplication> > >(), new ApplicationErrorDescriber()); var clientValidator = new ClientApplicationValidator <IdentityServiceApplication>( Options.Create(options), GetSessionManager(), manager, new ProtocolErrorProvider()); // Act var validation = await clientValidator.ValidateClientCredentialsAsync("clientId", null); // Assert Assert.True(validation); }
public async Task ValidateClientIdAsync_ChecksThatTheClientIdExist(bool exists) { // Arrange var options = new IdentityServiceOptions(); var store = new Mock <IApplicationStore <IdentityServiceApplication> >(); store.Setup(s => s.FindByClientIdAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())) .ReturnsAsync(exists ? new IdentityServiceApplication() : null); var manager = new ApplicationManager <IdentityServiceApplication>( Options.Create(new ApplicationOptions()), store.Object, Mock.Of <IPasswordHasher <IdentityServiceApplication> >(), Array.Empty <IApplicationValidator <IdentityServiceApplication> >(), Mock.Of <ILogger <ApplicationManager <IdentityServiceApplication> > >(), new ApplicationErrorDescriber()); var clientValidator = new ClientApplicationValidator <IdentityServiceApplication>( Options.Create(options), GetSessionManager(), manager, new ProtocolErrorProvider()); // Act var validation = await clientValidator.ValidateClientIdAsync("clientId"); // Assert Assert.Equal(exists, validation); }