Exemplo n.º 1
0
        public async Task RecommendedLearning_returns_expected_view_when_using_signposting()
        {
            // Given
            var expectedBookmarkString = $"/LearningPortal/SelfAssessment/{SelfAssessmentId}/RecommendedLearning";

            A.CallTo(() => configuration[ConfigHelper.UseSignposting]).Returns("true");

            // When
            var result = await controller.RecommendedLearning(SelfAssessmentId);

            // Then
            using (new AssertionScope())
            {
                A.CallTo(() => selfAssessmentService.SetBookmark(SelfAssessmentId, DelegateId, expectedBookmarkString))
                .MustHaveHappenedOnceExactly();
                A.CallTo(() => selfAssessmentService.UpdateLastAccessed(SelfAssessmentId, DelegateId))
                .MustHaveHappenedOnceExactly();
                A.CallTo(() => filteredApiHelperService.GetUserAccessToken <AccessToken>(A <string> ._))
                .MustNotHaveHappened();
                A.CallTo(
                    () => recommendedLearningService.GetRecommendedLearningForSelfAssessment(
                        SelfAssessmentId,
                        DelegateId
                        )
                    ).MustHaveHappenedOnceExactly();
                result.Should().BeViewResult().WithViewName("RecommendedLearning");
            }
        }
Exemplo n.º 2
0
        private async Task <string> GetFilteredToken()
        {
            var    candidateNum  = User.GetCandidateNumberKnownNotNull();
            string?filteredToken = null;

            if (Request.Cookies.ContainsKey("filtered-" + candidateNum))
            {
                filteredToken = Request.Cookies["filtered-" + candidateNum];
            }

            if (filteredToken == null)
            {
                var accessToken = await filteredApiHelperService.GetUserAccessToken <AccessToken>(candidateNum);

                filteredToken = accessToken.Jwt_access_token;
                var cookieOptions = new CookieOptions();
                cookieOptions.Expires = new DateTimeOffset(DateTime.Now.AddMinutes(15));
                Response.Cookies.Append("filtered-" + candidateNum, filteredToken, cookieOptions);
            }

            return(filteredToken);
        }