public void GivenNonexistentTokenValue_ThenReturnsFalse() { var query = VerifyBrowseTokenQuery.Create("NonexistentToken"); IRequestHandler <VerifyBrowseTokenQuery, bool> sut = new VerifyBrowseTokenQueryHandler(_authorizationContextMock.Object, _timeProviderMock.Object); var actualResult = sut.Handle(query, CancellationToken.None).Result; actualResult.Should().BeFalse(); }
public async Task <IActionResult> GetFile(string id, [FromQuery] string token) { var tokenQuery = VerifyBrowseTokenQuery.Create(token); var isTokenValid = await _mediator.Send(tokenQuery); if (!isTokenValid) { return(Unauthorized()); } var fileQuery = FileMediaQuery.Create(id, token); var result = await _mediator.Send(fileQuery); return(result); }
public void GivenNullString_ThenThrowsArgumentException() { Action act = () => VerifyBrowseTokenQuery.Create(null); act.Should().Throw <ArgumentException>(); }
public void GivenSampleTokenValue_ThenQueryContainsGivenValue() { var query = VerifyBrowseTokenQuery.Create("sampleToken"); query.TokenValue.Should().Be("sampleToken"); }