01/01: improve auth service and make logout works
This is an automated email from the git hooks/post-receive script. unknown user pushed a commit to branch devel in repository Pollen. commit 19ae4642cd2bfb90f2ad1f7dd589d22786b6dcf5 Author: Tony CHEMIT <chemit@codelutin.com> Date: Wed May 21 12:03:22 2014 +0200 improve auth service and make logout works --- .../org/chorem/pollen/rest/api/AuthApiTest.java | 31 ++++++++++++++++++++-- .../services/service/security/SecurityService.java | 8 +++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AuthApiTest.java b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AuthApiTest.java index cebcedc..94bb6af 100644 --- a/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AuthApiTest.java +++ b/pollen-rest-api/src/test/java/org/chorem/pollen/rest/api/AuthApiTest.java @@ -2,13 +2,14 @@ package org.chorem.pollen.rest.api; import org.apache.http.client.fluent.Request; import org.apache.http.client.fluent.Response; +import org.chorem.pollen.rest.api.converter.JsonConverter; +import org.chorem.pollen.services.bean.CreateBeanRef; import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.net.URISyntaxException; -import static org.junit.Assert.assertNotNull; /** * Created on 5/20/14. @@ -28,7 +29,33 @@ public class AuthApiTest extends AbstractPollenRestApiTest { String content = request.execute().returnContent().asString(); showTestResult(content); - assertNotNull(content); + Assert.assertNotNull(content); + + } + + @Test + public void loginThenLogout() throws URISyntaxException, IOException { + + Request login = createRequest("/v1/login") + .addParameter("login", "admin") + .addParameter("password", "admin") + .Post(); + + String loginContent = login.execute().returnContent().asString(); + showTestResult(loginContent); + Assert.assertNotNull(loginContent); + + JsonConverter<CreateBeanRef> jsonConverter = JsonConverter.newConverter(CreateBeanRef.class); + CreateBeanRef createBeanRef = jsonConverter.convert(CreateBeanRef.class, loginContent); + Assert.assertNotNull(createBeanRef); + + Request logout = createRequest("/v1/logout").Get(); + logout.addHeader(PollenRestApiRequestFilter.REQUEST_HEADER_SESSION_TOKEN, createBeanRef.getPermission()); + + String logoutContent = logout.execute().returnContent().asString(); + showTestResult(logoutContent); + Assert.assertNotNull(logoutContent); + } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java index bc1b27c..46799f8 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/security/SecurityService.java @@ -78,7 +78,7 @@ public class SecurityService extends PollenServiceSupport { } PollenUser user = getPollenUserDao().forLoginEquals(login).findUnique(); - return copy(user); + return user; } @@ -91,7 +91,7 @@ public class SecurityService extends PollenServiceSupport { subject.logout(); } - return copy(sessionToken); + return sessionToken; } @@ -135,7 +135,7 @@ public class SecurityService extends PollenServiceSupport { throw new PollenInvalidSessionTokenException(); } } - return copy(sessionToken); + return sessionToken; } @@ -145,7 +145,7 @@ public class SecurityService extends PollenServiceSupport { if (principalId != null) { principal = getPollenPrincipalDao().findByPermissionToken(principalId); } - return copy(principal); + return principal; } -- To stop receiving notification emails like this one, please contact Chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
Chorem.org scm