public void GetConstructedKeyAuthorization_WhenNoWellKnownChallengeTokenWasReturnedFromConfiguration_AssertGetterWasNotCalledOnConfigurationWithSecurityAcmeChallengeConstructedKeyAuthorization() { IAcmeChallengeResolver sut = CreateSut(false); sut.GetConstructedKeyAuthorization(_fixture.Create <string>()); _configurationMock.Verify(m => m["Security:AcmeChallenge:ConstructedKeyAuthorization"], Times.Never); }
public void GetConstructedKeyAuthorization_WhenNoWellKnownChallengeTokenWasReturnedFromConfiguration_ReturnsNull() { IAcmeChallengeResolver sut = CreateSut(false); string result = sut.GetConstructedKeyAuthorization(_fixture.Create <string>()); Assert.That(result, Is.Null); }
public void GetConstructedKeyAuthorization_WhenChallengeTokenIsNotNullEmptyOrWhiteSpace_AssertGetterWasCalledOnConfigurationWithSecurityAcmeChallengeWellKnownChallengeToken() { IAcmeChallengeResolver sut = CreateSut(); sut.GetConstructedKeyAuthorization(_fixture.Create <string>()); _configurationMock.Verify(m => m["Security:AcmeChallenge:WellKnownChallengeToken"], Times.Once); }
public void GetConstructedKeyAuthorization_WhenWellKnownChallengeTokenDoesNotMatchChallengeToken_AssertGetterNotCalledOnConfigurationWithSecurityAcmeChallengeConstructedKeyAuthorization() { string wellKnownChallengeToken = _fixture.Create <string>(); IAcmeChallengeResolver sut = CreateSut(wellKnownChallengeToken: wellKnownChallengeToken); sut.GetConstructedKeyAuthorization(wellKnownChallengeToken + _fixture.Create <string>()); _configurationMock.Verify(m => m["Security:AcmeChallenge:ConstructedKeyAuthorization"], Times.Never); }
public void GetConstructedKeyAuthorization_WhenWellKnownChallengeTokenMatchesChallengeTokenButWhiteSpaceWasReturnedFromConfigurationForConstructedKeyAuthorization_ReturnsNull() { string wellKnownChallengeToken = _fixture.Create <string>(); IAcmeChallengeResolver sut = CreateSut(wellKnownChallengeToken: wellKnownChallengeToken, constructedKeyAuthorization: " "); string result = sut.GetConstructedKeyAuthorization(wellKnownChallengeToken); Assert.That(result, Is.Null); }
public void GetConstructedKeyAuthorization_WhenWellKnownChallengeTokenDoesNotMatchChallengeToken_ReturnsNull() { string wellKnownChallengeToken = _fixture.Create <string>(); IAcmeChallengeResolver sut = CreateSut(wellKnownChallengeToken: wellKnownChallengeToken); string result = sut.GetConstructedKeyAuthorization(wellKnownChallengeToken + _fixture.Create <string>()); Assert.That(result, Is.Null); }
public void GetConstructedKeyAuthorization_WhenWellKnownChallengeTokenMatchesChallengeTokenAndNonNullEmptyOrWhiteSpaceWasReturnedFromConfigurationForConstructedKeyAuthorization_ReturnsValueFromConfiguration() { string wellKnownChallengeToken = _fixture.Create <string>(); string constructedKeyAuthorization = _fixture.Create <string>(); IAcmeChallengeResolver sut = CreateSut(wellKnownChallengeToken: wellKnownChallengeToken, constructedKeyAuthorization: constructedKeyAuthorization); string result = sut.GetConstructedKeyAuthorization(wellKnownChallengeToken); Assert.That(result, Is.EqualTo(constructedKeyAuthorization)); }
public IActionResult AcmeChallenge(string challengeToken) { NullGuard.NotNullOrWhiteSpace(challengeToken, nameof(challengeToken)); string constructedKeyAuthorization = _acmeChallengeResolver.GetConstructedKeyAuthorization(challengeToken); if (string.IsNullOrWhiteSpace(constructedKeyAuthorization)) { return(BadRequest()); } return(File(Encoding.UTF8.GetBytes(constructedKeyAuthorization), "application/octet-stream")); }
public IActionResult AcmeChallenge(string challengeToken) { if (string.IsNullOrWhiteSpace(challengeToken)) { throw new IntranetExceptionBuilder(ErrorCode.ValueCannotBeNullOrWhiteSpace, nameof(challengeToken)) .WithValidatingType(typeof(string)) .WithValidatingField(nameof(challengeToken)) .Build(); } string constructedKeyAuthorization = _acmeChallengeResolver.GetConstructedKeyAuthorization(challengeToken); if (string.IsNullOrWhiteSpace(constructedKeyAuthorization)) { throw new IntranetExceptionBuilder(ErrorCode.CannotRetrieveAcmeChallengeForToken).Build(); } return(File(Encoding.UTF8.GetBytes(constructedKeyAuthorization), "application/octet-stream")); }
public void GetConstructedKeyAuthorization_WhenChallengeTokenIsWhiteSpace_ThrowsArgumentNullException() { IAcmeChallengeResolver sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.GetConstructedKeyAuthorization(" ")); Assert.That(result.ParamName, Is.EqualTo("challengeToken")); }