Exemplo n.º 1
0
        public void Authenticate_WithGoodUserId_ReturnsAccessToken()
        {
            var apiHelper = CreateApiHelper(GetValidResponse());
            var authenticationEndpoint = new AuthenticationEndpoint(apiHelper);

            var sut = authenticationEndpoint.Authenticate(_authenticatedUser.UserId).Result;

            Assert.IsNotNull(sut);
            Assert.AreEqual(_authenticatedUser.Username, sut.Username);
            Assert.IsTrue(sut.Authenticated, "Returned user is not authenticated.");
            Assert.IsNotNull(sut.AccessToken, "Access token was not returned.");
        }
Exemplo n.º 2
0
        public void Authenticate_WithBadCredentials_ReturnsNullAccessToken()
        {
            var response = new HttpResponseMessage {
                StatusCode = HttpStatusCode.BadRequest
            };
            var apiHelper = CreateApiHelper(response);
            var authenticationEndpoint = new AuthenticationEndpoint(apiHelper);

            var sut = authenticationEndpoint.Authenticate((UserCredentials)null).Result;

            Assert.IsNotNull(sut);
            Assert.IsFalse(sut.Authenticated, "Returned user is authenticated.");
            Assert.IsNull(sut.AccessToken, "Access token was returned.");
            Assert.AreEqual("Bad Request", sut.FailedReason);
        }