Ejemplo n.º 1
0
        public async Task GetLoginServerInformation_ReturnsLoginInfoResponse_WhenRequestsSucceed()
        {
            Exception thrownException = null;

            Assert.IsTrue(_fakeBasicInfoJsonResponse.Contains(_fakeLoginAddress));

            var fakeLoginServerInfo = new LoginInfoResponse
            {
                Prompts = new System.Collections.Generic.Dictionary <string, string[]>
                {
                    { "username", new[] { "text", "Email" } },
                    { "password", new[] { "password", "Password" } },
                }
            };

            MockedRequest cfBasicInfoRequest = _mockHttp.Expect(_fakeCfApiAddress + "/")
                                               .Respond("application/json", _fakeBasicInfoJsonResponse);

            MockedRequest loginServerInfoRequest = _mockHttp.Expect(_fakeLoginAddress + "/login")
                                                   .Respond("application/json", JsonConvert.SerializeObject(fakeLoginServerInfo));

            try
            {
                var result = await _sut.GetLoginServerInformation(_fakeCfApiAddress);
            }
            catch (Exception ex)
            {
                thrownException = ex;
            }

            Assert.IsNull(thrownException);

            Assert.AreEqual(1, _mockHttp.GetMatchCount(cfBasicInfoRequest));
            Assert.AreEqual(1, _mockHttp.GetMatchCount(loginServerInfoRequest));
        }
Ejemplo n.º 2
0
        public async Task <LoginInfoResponse> GetInfo()
        {
            LoginInfoResponse info = new LoginInfoResponse();

            byte[] isLogged = VerifyLogin();
            if (isLogged == null)
            {
                info.Islogged    = false;
                info.Username    = "";
                info.Displayname = "";
            }
            else
            {
                info.Islogged    = true;
                info.Username    = _httpContextAccessor.HttpContext.User.Identity.Name;
                info.Displayname = _httpContextAccessor.HttpContext.User.FindFirst("FullName").Value;
            }
            return(info);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> GetInfo()
        {
            LoginInfoResponse result = await LoginService.GetInfo();

            return(new OkObjectResult(result));
        }