public IActionResult Login(string returnUrl = null)
        {
            if (string.IsNullOrWhiteSpace(returnUrl))
            {
                return(View("Login"));
            }

            Uri returnUri = ConvertToAbsoluteUri(returnUrl);

            if (returnUri == null || _trustedDomainHelper.IsTrustedDomain(returnUri) == false)
            {
                return(BadRequest());
            }

            return(View("Login", returnUri));
        }
        public void IsTrustedDomain_WhenUriIsTrustedDomain_ReturnsTrue()
        {
            string[] trustedDomainCollection =
            {
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>()
            };
            ITrustedDomainHelper sut = CreateSut(trustedDomainCollection);

            bool result = sut.IsTrustedDomain(new Uri($"https://{trustedDomainCollection[_random.Next(0, trustedDomainCollection.Length - 1)]}/{_fixture.Create<string>()}"));

            Assert.That(result, Is.True);
        }
        public void IsTrustedDomain_WhenUriIsNotTrustedDomain_ReturnsFalse()
        {
            string[] trustedDomainCollection =
            {
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>(),
                _fixture.Create <string>()
            };
            ITrustedDomainHelper sut = CreateSut(trustedDomainCollection);

            bool result = sut.IsTrustedDomain(new Uri($"https://{_fixture.Create<string>()}/{_fixture.Create<string>()}"));

            Assert.That(result, Is.False);
        }
        public void IsTrustedDomain_WhenUriIsNull_ThrowsArgumentNullException()
        {
            ITrustedDomainHelper sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.IsTrustedDomain(null));

            Assert.That(result.ParamName, Is.EqualTo("uri"));
        }