Пример #1
0
        public static SSOSettings CreateSSOSettings()
        {
            var settings = new SSOSettings
            {
                Apps = new List <SSOTargetSettings>
                {
                    new SSOTargetSettings
                    {
                        AppName = "App1",
                        AuthenticationUrlTemplate = "Url1-{0}",
                        ExpireInSeconds           = 5,
                        TokenProviderSettings     = new TokenProviderSettings()
                    },
                    new SSOTargetSettings
                    {
                        AppName = "App2",
                        AuthenticationUrlTemplate = "Url2-{0}",
                        ExpireInSeconds           = 10,
                        TokenProviderSettings     = new TokenProviderSettings()
                    }
                }
            };

            return(settings);
        }
Пример #2
0
        public void CreatesSSOManager()
        {
            // Arrange
            var targetSettings = new SSOSettings();

            targetSettings.Apps.Add(new SSOTargetSettings
            {
                AppName = "App1",
                AuthenticationUrlTemplate = "Url1",
                ExpireInSeconds           = 1,
                TokenProviderSettings     = new TokenProviderSettings()
            });
            targetSettings.Apps.Add(new SSOTargetSettings
            {
                AppName = "App2",
                AuthenticationUrlTemplate = "Url2",
                ExpireInSeconds           = 2,
                TokenProviderSettings     = new TokenProviderSettings()
            });

            var factoryMock = new Mock <ITokenProviderFactory>();
            var optionsMock = new Mock <IOptions <SSOSettings> >();

            optionsMock.Setup(x => x.Value).Returns(targetSettings);

            // Act
            var target = new SSOManager(factoryMock.Object, optionsMock.Object);

            // Assert
            factoryMock.Verify(x => x.Create(It.IsAny <TokenProviderSettings>()), Times.Exactly(targetSettings.Apps.Count));
        }
Пример #3
0
 public SSOController(
     UserStore userStore,
     UserManager userManager,
     PortunusSSOService ssoService,
     SSOSettings settings)
 {
     this.userStore   = userStore;
     this.userManager = userManager;
     this.ssoService  = ssoService;
     this.settings    = settings;
 }
Пример #4
0
        public SSOManager(ITokenProviderFactory factory, IOptions <SSOSettings> options)
        {
            factory.ThrowIfNull(nameof(factory));
            settings = options.ThrowIfNull(nameof(options)).Value;
            settings.ThrowIfNull(nameof(settings));

            ssoServices = new Dictionary <string, SSOService>();

            foreach (var app in settings.Apps)
            {
                var ssoService = new SSOService(factory, app);
                ssoServices.Add(app.AppName.ToLower(), ssoService);
            }
        }
Пример #5
0
        public void ThrowsIfSSOTargetSettingsAreInvalid(
            SSOTargetSettings settings,
            Type exceptionType,
            string expectedParamName)
        {
            // Arrange
            var targetSettings = new SSOSettings();

            targetSettings.Apps.Add(settings);

            var factoryMock = new Mock <ITokenProviderFactory>();
            var optionsMock = new Mock <IOptions <SSOSettings> >();

            optionsMock.Setup(x => x.Value).Returns(targetSettings);

            // Act/Assert
            var ex = Assert.Throws(exceptionType, () => new SSOManager(factoryMock.Object, optionsMock.Object));

            Assert.Equal(expectedParamName, ((ArgumentException)ex).ParamName);
        }
Пример #6
0
 public PortalUserHelper(SSOSettings _settings) : base(_settings)
 {
 }
Пример #7
0
 public ERPUserHelper(SSOSettings _settings) : base(_settings)
 {
 }
Пример #8
0
        public static (Mock <ITokenProviderFactory> factoryMock, Mock <IOptions <SSOSettings> > optionsMock) CreateMocks(SSOSettings settings)
        {
            var factoryMock = new Mock <ITokenProviderFactory>();

            factoryMock.Setup(x => x.Create(It.IsAny <TokenProviderSettings>())).Returns(() => new Mock <ITokenProvider>().Object);
            var optionsMock = new Mock <IOptions <SSOSettings> >();

            optionsMock.Setup(x => x.Value).Returns(settings);

            return(factoryMock, optionsMock);
        }
Пример #9
0
 public ThreadUserHelper(SSOSettings _settings) : base(_settings)
 {
 }
Пример #10
0
 public UserHelper(SSOSettings _settings)
 {
     settings = _settings;
 }
Пример #11
0
 public ServiceUserHelper(SSOSettings _settings) : base(_settings)
 {
 }