コード例 #1
0
            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);
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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);
            }
コード例 #4
0
            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);
            }
コード例 #5
0
            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);
            }