Ejemplo n.º 1
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResultWhereContentTypeIsEqualToApplicationOctetStream()
        {
            Controller sut = CreateSut();

            FileContentResult result = (FileContentResult)sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(result.ContentType, Is.EqualTo("application/octet-stream"));
        }
Ejemplo n.º 2
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResultWhereFileContentsIsNotEmpty()
        {
            Controller sut = CreateSut();

            FileContentResult result = (FileContentResult)sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(result.FileContents, Is.Not.Empty);
        }
Ejemplo n.º 3
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResult()
        {
            Controller sut = CreateSut();

            IActionResult result = sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <FileContentResult>());
        }
Ejemplo n.º 4
0
        public void AcmeChallenge_WhenConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ReturnsFileContentResultWhereFileContentsIsEqualToConstructedKeyAuthorization()
        {
            string     constructedKeyAuthorization = _fixture.Create <string>();
            Controller sut = CreateSut(constructedKeyAuthorization: constructedKeyAuthorization);

            FileContentResult result = (FileContentResult)sut.AcmeChallenge(_fixture.Create <string>());

            Assert.That(Encoding.UTF8.GetString(result.FileContents), Is.EqualTo(constructedKeyAuthorization));
        }
Ejemplo n.º 5
0
        public void AcmeChallenge_WhenChallengeTokenIsNotNullEmptyOrWhiteSpace_AssertGetConstructedKeyAuthorizationWasCalledOnAcmeChallengeResolver()
        {
            Controller sut = CreateSut();

            string challengeToken = _fixture.Create <string>();

            sut.AcmeChallenge(challengeToken);

            _acmeChallengeResolverMock.Verify(m => m.GetConstructedKeyAuthorization(It.Is <string>(value => string.IsNullOrWhiteSpace(value) == false && string.CompareOrdinal(value, challengeToken) == 0)), Times.Once);
        }
Ejemplo n.º 6
0
        public void AcmeChallenge_WhenChallengeTokenIsEmpty_ThrowsIntranetValidationExceptionWhereValidatingTypeIsTypeOfString()
        {
            Controller sut = CreateSut();

            IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(string.Empty));

            Assert.That(result.ValidatingType, Is.EqualTo(typeof(string)));
        }
Ejemplo n.º 7
0
        public void AcmeChallenge_WhenChallengeTokenIsEmpty_ThrowsIntranetValidationExceptionWhereErrorCodeIsEqualToValueCannotBeNullOrWhiteSpace()
        {
            Controller sut = CreateSut();

            IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(string.Empty));

            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ValueCannotBeNullOrWhiteSpace));
        }
Ejemplo n.º 8
0
        public void AcmeChallenge_WhenChallengeTokenIsEmpty_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut();

            Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(string.Empty));
        }
Ejemplo n.º 9
0
        public void AcmeChallenge_WhenChallengeTokenIsNull_ThrowsIntranetValidationExceptionWhereValidatingFieldIsEqualToChallengeToken()
        {
            Controller sut = CreateSut();

            IntranetValidationException result = Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(null));

            Assert.That(result.ValidatingField, Is.EqualTo("challengeToken"));
        }
Ejemplo n.º 10
0
        public void AcmeChallenge_WhenNoConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ThrowsIntranetBusinessExceptionWhereErrorCodeIsEqualToCannotRetrieveAcmeChallengeForToken()
        {
            Controller sut = CreateSut(false);

            IntranetBusinessException result = Assert.Throws <IntranetBusinessException>(() => sut.AcmeChallenge(_fixture.Create <string>()));

            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.CannotRetrieveAcmeChallengeForToken));
        }
Ejemplo n.º 11
0
        public void AcmeChallenge_WhenNoConstructedKeyAuthorizationWasReturnedFromAcmeChallengeResolver_ThrowsIntranetBusinessException()
        {
            Controller sut = CreateSut(false);

            Assert.Throws <IntranetBusinessException>(() => sut.AcmeChallenge(_fixture.Create <string>()));
        }
Ejemplo n.º 12
0
        public void AcmeChallenge_WhenChallengeTokenIsWhiteSpace_ThrowsIntranetValidationException()
        {
            Controller sut = CreateSut();

            Assert.Throws <IntranetValidationException>(() => sut.AcmeChallenge(" "));
        }