public void RpcAuthenticationLegacyFormatTest() { IPmp = new Mock<IPmp>(); IPmp.Setup(i => i.Authenticate("xunit", "xunit")).Returns(true); var RpcAuthenticationHandler = new InitHandler().initRpcAuthenticationHandler(IPmp.Object, null, "username=xunit&sharedSecret=xunit", true); var response = RpcAuthenticationHandler.Content.ReadAsAsync<RpcAuthenticationResponse>().Result; Assert.Empty(response.Data.Errors); }
public void ProviderAuthenticationEnabledFlagTest() { IProviderRepository = new Mock<IProviderRepository>(); IPmp = new Mock<IPmp>(); ICSSProviders = new Mock<ICSSProviders>(); IProviderRepository.Setup(i => i.SelectByProviderId("xunit")).Returns(new ProviderObject() { Enabled = false }); IPmp.Setup(i => i.Authenticate("xunit", "xunit")).Returns(true); IPmp.Setup(i => i.Authorize("xunit", ConfigurationManager.AppSettings["WS_USER_RESOURCE"])).Returns(false); var ProviderAuthenticationHandler = new InitHandler().initProviderAuthenticationHandler(IProviderRepository.Object, IPmp.Object, ICSSProviders.Object, null, "LSR-DIGEST apiuser=xunit, sharedSecret=xunit"); var response = ProviderAuthenticationHandler.Content.ReadAsAsync<ProviderAuthenticationResponse>().Result; Assert.True(response.Data.Errors.Exists(i => i.Code == 2001)); }
public void RpcAuthenticationNoAuthenticationHeaderFailureTest() { IPmp = new Mock<IPmp>(); IPmp.Setup(i => i.Authenticate("xunit", "xunit")).Returns(false); var RpcAuthenticationHandler = new InitHandler().initRpcAuthenticationHandler(IPmp.Object); var response = RpcAuthenticationHandler.Content.ReadAsAsync<RpcAuthenticationResponse>().Result; Assert.True(response.Data.Errors.Exists(i => i.Code == 7)); }
public void RpcInvalidAuthenticationTypeFailureTest() { IPmp = new Mock<IPmp>(); IPmp.Setup(i => i.Authenticate("xunit", "xunit")).Returns(true); var RpcAuthenticationHandler = new InitHandler().initRpcAuthenticationHandler(IPmp.Object, null, "LSR2-DIGEST apiuser=xunit, sharedSecret=xunit"); var response = RpcAuthenticationHandler.Content.ReadAsAsync<RpcAuthenticationResponse>().Result; Assert.True(response.Data.Errors.Exists(i => i.Code == 7)); }
public void RpcAuthenticationSuccessTest() { IPmp = new Mock<IPmp>(); IPmp.Setup(i => i.Authenticate("xunit", "xunit")).Returns(true); var RpcAuthenticationHandler = new InitHandler().initRpcAuthenticationHandler(IPmp.Object, null, "LSR-DIGEST apiuser=xunit, sharedSecret=xunit"); var response = RpcAuthenticationHandler.Content.ReadAsAsync<RpcAuthenticationResponse>().Result; Assert.Empty(response.Data.Errors); }
public void ProviderAuthenticationProviderNotUpToDateServiceReturnedProviderWithNoWelcomeUrlTest() { var interval = Convert.ToInt32(ConfigurationManager.AppSettings["PROVIDER_MANAGEMENT_CHECK_INTERVAL"]); IProviderRepository = new Mock<IProviderRepository>(); IPmp = new Mock<IPmp>(); ICSSProviders = new Mock<ICSSProviders>(); IProviderRepository.Setup(i => i.SelectByProviderId("xunit")).Returns(new ProviderObject() { Update_Date = DateTime.Now.AddMinutes(interval * -2) }); IPmp.Setup(i => i.Authenticate("xunit", "xunit")).Returns(true); IPmp.Setup(i => i.Authorize("xunit", ConfigurationManager.AppSettings["WS_USER_RESOURCE"])).Returns(true); ICSSProviders.Setup(i => i.GetMainstreamProviderInfo("xunit")).Returns(new MainstreamProviderResponseObject() { Errors = null, MainstreamProviderObject = new List<MainstreamProviderObject>() { new MainstreamProviderObject() { WelcomeUrlCode = null } } }); var ProviderAuthenticationHandler = new InitHandler().initProviderAuthenticationHandler(IProviderRepository.Object, IPmp.Object, ICSSProviders.Object, null, "LSR-DIGEST apiuser=xunit, sharedSecret=xunit"); var response = ProviderAuthenticationHandler.Content.ReadAsAsync<ProviderAuthenticationResponse>().Result; Assert.True(response.Data.Errors.Exists(i => i.Code == 2005)); }
public void ProviderAuthenticationNoAuthenticationHeaderFailureTest() { IProviderRepository = new Mock<IProviderRepository>(); IPmp = new Mock<IPmp>(); ICSSProviders = new Mock<ICSSProviders>(); var ProviderAuthenticationHandler = new InitHandler().initProviderAuthenticationHandler(IProviderRepository.Object, IPmp.Object, ICSSProviders.Object); var response = ProviderAuthenticationHandler.Content.ReadAsAsync<ProviderAuthenticationResponse>().Result; Assert.True(response.Data.Errors.Exists(i => i.Code == 2000)); }