Exemple #1
0
        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();
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        public void GivenNullString_ThenThrowsArgumentException()
        {
            Action act = () => VerifyBrowseTokenQuery.Create(null);

            act.Should().Throw <ArgumentException>();
        }
Exemple #4
0
        public void GivenSampleTokenValue_ThenQueryContainsGivenValue()
        {
            var query = VerifyBrowseTokenQuery.Create("sampleToken");

            query.TokenValue.Should().Be("sampleToken");
        }