public void GetExceptionWhenSecurityConfigurationIsNotSet() { var jwtClient = new Mock <IJwtTokenRequestClient>(); var configuration = new Mock <ISecurityConfiguration>(); var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwtClient.Object, configuration.Object); Assert.Catch <ApplicationException>(() => securityTokenServiceProxy.GetAccessToken()); }
public void GetExceptionWhenPartNoneServiceSecurityConfigurationSet() { var jwtClient = new Mock <IJwtTokenRequestClient>(); var configuration = new Mock <ISecurityConfiguration>(); configuration.Setup(x => x.ClientId).Returns("abc"); var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwtClient.Object, configuration.Object); Assert.Catch <ApplicationException>(() => securityTokenServiceProxy.GetAccessToken()); }
private static (HttpClientProxy httpClientProxy, Configuration configuration, RestClientWithSecurity restClient) GetHttpClientProxyConfigurationRestClient() { var securityConfiguration = new SecurityConfiguration(); var logger = new InternalLogger(securityConfiguration); var webContext = new WebContext(); var jwtTokenRequestClient = new JwtTokenRequestClient(securityConfiguration, logger, new UserProfileId(webContext, logger), new JwtTokenCache(webContext)); var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwtTokenRequestClient, securityConfiguration); var httpClientProxy = new HttpClientProxy(securityTokenServiceProxy); var configuration = new Configuration(); var restClient = new RestClientWithSecurity(configuration, httpClientProxy); return(httpClientProxy, configuration, restClient); }
public static BaseValueSegmentProxy GetBaseValueSegmentProxy() { var securityConfiguration = new SecurityConfiguration(); var logger = new InternalLogger(securityConfiguration); var webContext = new WebContext(); var jwtTokenRequestClient = new JwtTokenRequestClient(securityConfiguration, logger, new UserProfileId(webContext, logger), new JwtTokenCache(webContext)); var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwtTokenRequestClient, securityConfiguration); var httpClientProxy = new HttpClientProxy(securityTokenServiceProxy); var configuration = new Configuration(); var restClient = new RestClient(configuration, httpClientProxy); return(new BaseValueSegmentProxy(httpClientProxy, new UrlServices(restClient, configuration))); }
public static bool IsFeatureToggleEnabled(Features feature) { var securityConfiguration = new SecurityConfiguration(); var internalLogger = new InternalLogger(securityConfiguration); var webContext = new WebContext(); IUserProfileId userProfileId = new UserProfileId(webContext, internalLogger); var jwt = new JwtTokenRequestClient(securityConfiguration, internalLogger, userProfileId, new JwtTokenCache(webContext)); var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwt, securityConfiguration); var httpClientProxy = new HttpClientProxy(securityTokenServiceProxy); var configuration = new Configuration(); var restClient = new RestClient(configuration, httpClientProxy); var featureToggle = new FeatureToggle(restClient); return(featureToggle.IsEnabled(feature)); }
public void GetAccessTokenWhenAllNoneServiceSecurityConfigurationSet() { var jwtClient = new Mock <IJwtTokenRequestClient>(); var configuration = new Mock <ISecurityConfiguration>(); configuration.Setup(x => x.ClientId).Returns("abc"); configuration.Setup(x => x.ClientPassword).Returns("abc"); configuration.Setup(x => x.ClientScope).Returns("abc"); jwtClient.Setup(x => x.ProcessByUserProfileId()).Returns(new JwtTokenRequestResult { AccessToken = "bar" }); var securityTokenServiceProxy = new SecurityTokenServiceProxy(jwtClient.Object, configuration.Object); Assert.That(securityTokenServiceProxy.GetAccessToken(), Is.EqualTo("bar")); }