public void DefaultsConfigurationToDisabled() { var auther = new ATestAuthenticator(); Assert.NotNull(auther.BaseConfig); Assert.False(auther.BaseConfig.Enabled); Assert.Null(auther.BaseConfig.AuthenticationType); }
public async Task LoadsConfigFromConfigurationService() { // Arrange var authConfig = new AuthenticatorConfiguration(); var auther = new ATestAuthenticator(); // Act await auther.Startup(Get <IGalleryConfigurationService>(), Get <IAppBuilder>()); // Assert Assert.Equal(authConfig.Enabled, auther.BaseConfig.Enabled); Assert.Equal(authConfig.AuthenticationType, auther.BaseConfig.AuthenticationType); }
public void LoadsConfigFromConfigurationService() { // Arrange var authConfig = new AuthenticatorConfiguration(); GetMock <ConfigurationService>() .Setup(c => c.ResolveConfigObject(It.IsAny <AuthenticatorConfiguration>(), "Auth.ATest.")) .Returns(authConfig); var auther = new ATestAuthenticator(); // Act auther.Startup(Get <ConfigurationService>(), Get <IAppBuilder>()); // Assert Assert.Same(authConfig, auther.BaseConfig); }
public async Task AttachesToOwinAppIfEnabled() { // Arrange var auther = new ATestAuthenticator(); var tempAuthConfig = new AuthenticatorConfiguration(); var mockConfiguration = GetConfigurationService(); mockConfiguration.Settings[$"{Authenticator.AuthPrefix}{auther.Name}.{nameof(tempAuthConfig.Enabled)}"] = "true"; // Act await auther.Startup(mockConfiguration, Get <IAppBuilder>()); // Assert Assert.Same(Get <IAppBuilder>(), auther.AttachedTo); }
public async Task DoesNotAttachToOwinAppIfDisabled() { // Arrange var auther = new ATestAuthenticator(); var tempAuthConfig = new AuthenticatorConfiguration(); var mockConfiguration = (TestGalleryConfigurationService)Get <IGalleryConfigurationService>(); mockConfiguration.Settings[$"{Authenticator.AuthPrefix}{auther.Name}.{nameof(tempAuthConfig.Enabled)}"] = "false"; // Act await auther.Startup(Get <IGalleryConfigurationService>(), Get <IAppBuilder>()); // Assert Assert.Null(auther.AttachedTo); }
public void AttachesToOwinAppIfEnabled() { // Arrange var authConfig = new AuthenticatorConfiguration() { Enabled = true }; GetMock <ConfigurationService>() .Setup(c => c.ResolveConfigObject(It.IsAny <AuthenticatorConfiguration>(), "Auth.ATest.")) .Returns(authConfig); var auther = new ATestAuthenticator(); // Act auther.Startup(Get <ConfigurationService>(), Get <IAppBuilder>()); // Assert Assert.Same(Get <IAppBuilder>(), auther.AttachedTo); }