public async Task CurrentUserIsAdminAsync() { await CreateUserAndMockingHttpContextToReturnAccessToken(); var requestUrl = string.Format(_stringConstant.FirstAndSecondIndexStringFormat, _stringConstant.UserIsAdmin, _stringConstant.StringIdForTest); _mockHttpClient.Setup(x => x.GetAsync(_stringConstant.ProjectUserUrl, requestUrl, _stringConstant.AccessTokenForTest, _stringConstant.Bearer)).Returns(Task.FromResult("true")); var result = await _oauthCallHttpContextRepository.CurrentUserIsAdminAsync(); Assert.Equal(true, result); }
public async Task <IHttpActionResult> CurrentUserIsAdminOrNot() { UserAdminBasicDetailsAC userDetails = new UserAdminBasicDetailsAC(); userDetails.FirstName = (await _oauthCallRepository.GetUserByEmployeeIdAsync(GetUserId(User.Identity))).FirstName; userDetails.IsAdmin = await _oauthCallRepository.CurrentUserIsAdminAsync(); return(Ok(userDetails)); }