You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by wi...@apache.org on 2017/05/10 08:11:44 UTC

[1/4] marmotta git commit: MARMOTTA-534: temporally removed the users' uri resolution for fixing the multiple web service resolution issue

Repository: marmotta
Updated Branches:
  refs/heads/MARMOTTA-534_fix_login [created] 8718475c8


MARMOTTA-534: temporally removed the users' uri resolution for fixing the multiple web service resolution issue


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/2b2a803e
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/2b2a803e
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/2b2a803e

Branch: refs/heads/MARMOTTA-534_fix_login
Commit: 2b2a803ede39f17fb60b1c1a91edad467090eadd
Parents: f7b3350
Author: Sergio Fernández <wi...@apache.org>
Authored: Wed May 10 08:35:53 2017 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Wed May 10 08:48:17 2017 +0200

----------------------------------------------------------------------
 .../marmotta/platform/user/webservices/UserWebService.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/2b2a803e/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
index a83ed36..730b54c 100644
--- a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
+++ b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
@@ -233,8 +233,8 @@ public class UserWebService {
      * @HTTP 400 if no valid resource uri could be built with the login
      * @HTTP 500 on other exceptions
      */
-    @GET
-    @Path("/{login:[^#?]+}")
+    //@GET
+    //@Path("/{login:[^#?]+}")
     public Response getUser(@PathParam("login") String login, @HeaderParam("Accept") String types) {
         if(login.equals("me")) {
             return get();
@@ -301,7 +301,7 @@ public class UserWebService {
      *
      */
     static class AccountPoJo {
-        private String              login, uri, roles[];
+        private String login, uri, roles[];
         private Map<String, String> foaf;
 
         public AccountPoJo(String login, String uri) {
@@ -346,5 +346,7 @@ public class UserWebService {
         public Map<String, String> getFoaf() {
             return foaf;
         }
+
     }
+
 }


[3/4] marmotta git commit: MARMOTTA-534: applied some TDD for helping to find the root cause of the issue

Posted by wi...@apache.org.
MARMOTTA-534: applied some TDD for helping to find the root cause of the issue


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/958a79ee
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/958a79ee
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/958a79ee

Branch: refs/heads/MARMOTTA-534_fix_login
Commit: 958a79ee161430be8eb499b9f783f79c052c0f2c
Parents: 0b13c66
Author: Sergio Fernández <wi...@apache.org>
Authored: Wed May 10 09:50:19 2017 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Wed May 10 10:00:32 2017 +0200

----------------------------------------------------------------------
 platform/marmotta-user/pom.xml                  | 57 ++++++++++++++++++++
 .../user/webservices/UserWebService.java        |  4 +-
 .../user/webservices/UserWebServiceTest.java    | 52 ++++++++++++++++++
 3 files changed, 111 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/958a79ee/platform/marmotta-user/pom.xml
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/pom.xml b/platform/marmotta-user/pom.xml
index f519650..573cd61 100644
--- a/platform/marmotta-user/pom.xml
+++ b/platform/marmotta-user/pom.xml
@@ -157,5 +157,62 @@
             <groupId>commons-codec</groupId>
             <artifactId>commons-codec</artifactId>
         </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>marmotta-core</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-server</artifactId>
+            <version>${jetty.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-servlet</artifactId>
+            <version>${jetty.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.jboss.weld.se</groupId>
+            <artifactId>weld-se-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>javax.el-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jayway.restassured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/958a79ee/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
index 730b54c..63d4c22 100644
--- a/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
+++ b/platform/marmotta-user/src/main/java/org/apache/marmotta/platform/user/webservices/UserWebService.java
@@ -263,8 +263,8 @@ public class UserWebService {
     }
 
     /**
-     * Throws a {@link AccessDeniedException} if currently no user is logged in (aka: current user
-     * is anonymous).
+     * Throws a {@link AccessDeniedException} if currently no user is logged in
+     * (aka: current user is anonymous).
      *
      * @param ref the referer to redirect to
      * @param logout set to true to log out (does currently nothing)

http://git-wip-us.apache.org/repos/asf/marmotta/blob/958a79ee/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java
new file mode 100644
index 0000000..a55055d
--- /dev/null
+++ b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/webservices/UserWebServiceTest.java
@@ -0,0 +1,52 @@
+package org.apache.marmotta.platform.user.webservices;
+
+import com.jayway.restassured.RestAssured;
+import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import static com.jayway.restassured.RestAssured.expect;
+
+/**
+ * UserWebService Test
+ *
+ * @author Sergio Fernández
+ */
+public class UserWebServiceTest {
+
+    private static Logger log = LoggerFactory.getLogger(UserWebServiceTest.class);
+
+    private static JettyMarmotta marmotta;
+
+    @BeforeClass
+    public static void setUp() throws MarmottaImportException, URISyntaxException {
+        marmotta = new JettyMarmotta("/marmotta", UserWebService.class);
+        RestAssured.baseURI = "http://localhost";
+        RestAssured.port = marmotta.getPort();
+        RestAssured.basePath = marmotta.getContext();
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        marmotta.shutdown();
+    }
+
+    @Test
+    public void testLogin() throws IOException, InterruptedException {
+        expect().
+            log().ifError().
+            statusCode(200).
+        given().
+            auth(). preemptive().basic("admin", "pass123").
+        when().
+            get("/user/login");
+    }
+
+}


[2/4] marmotta git commit: MARMOTTA-534: fixed realm name

Posted by wi...@apache.org.
MARMOTTA-534: fixed realm name


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/0b13c66c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/0b13c66c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/0b13c66c

Branch: refs/heads/MARMOTTA-534_fix_login
Commit: 0b13c66c33fc50ff201050c6185858d487ce7cde
Parents: 2b2a803
Author: Sergio Fernández <wi...@apache.org>
Authored: Wed May 10 09:38:46 2017 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Wed May 10 09:38:46 2017 +0200

----------------------------------------------------------------------
 .../marmotta-user/src/main/resources/config-defaults.properties    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/0b13c66c/platform/marmotta-user/src/main/resources/config-defaults.properties
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/main/resources/config-defaults.properties b/platform/marmotta-user/src/main/resources/config-defaults.properties
index 8dd4125..b192992 100644
--- a/platform/marmotta-user/src/main/resources/config-defaults.properties
+++ b/platform/marmotta-user/src/main/resources/config-defaults.properties
@@ -24,7 +24,7 @@
 security.method=BASIC
 
 # the realm to use for HTTP authentication
-security.realm=Linked Media Framework
+security.realm=Apache Marmotta
 
 user.admin.password=pass123
 user.admin.roles=manager,editor,user


[4/4] marmotta git commit: MARMOTTA-534: found the source!

Posted by wi...@apache.org.
MARMOTTA-534: found the source!


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/8718475c
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/8718475c
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/8718475c

Branch: refs/heads/MARMOTTA-534_fix_login
Commit: 8718475c81b370232ffd6158eb076069744ac7ff
Parents: 958a79e
Author: Sergio Fernández <wi...@apache.org>
Authored: Wed May 10 10:10:58 2017 +0200
Committer: Sergio Fernández <wi...@apache.org>
Committed: Wed May 10 10:10:58 2017 +0200

----------------------------------------------------------------------
 .../user/services/AccountServiceTest.java       | 66 ++++++++++++++++++++
 1 file changed, 66 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/8718475c/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java
new file mode 100644
index 0000000..28de609
--- /dev/null
+++ b/platform/marmotta-user/src/test/java/org/apache/marmotta/platform/user/services/AccountServiceTest.java
@@ -0,0 +1,66 @@
+package org.apache.marmotta.platform.user.services;
+
+import com.jayway.restassured.RestAssured;
+import org.apache.marmotta.platform.core.exception.io.MarmottaImportException;
+import org.apache.marmotta.platform.core.test.base.JettyMarmotta;
+import org.apache.marmotta.platform.user.api.AccountService;
+import org.apache.marmotta.platform.user.model.UserAccount;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Set;
+
+import static org.hamcrest.CoreMatchers.hasItems;
+
+/**
+ * AccountService Test
+ *
+ * @author Sergio Fernández
+ */
+public class AccountServiceTest {
+
+    private static Logger log = LoggerFactory.getLogger(AccountServiceTest.class);
+
+    private static JettyMarmotta marmotta;
+
+    @BeforeClass
+    public static void setUp() throws MarmottaImportException, URISyntaxException {
+        marmotta = new JettyMarmotta("/marmotta", AccountService.class);
+        RestAssured.baseURI = "http://localhost";
+        RestAssured.port = marmotta.getPort();
+        RestAssured.basePath = marmotta.getContext();
+    }
+
+    @AfterClass
+    public static void tearDown() {
+        marmotta.shutdown();
+    }
+
+    @Test
+    public void testDefaultAccounts() {
+        final AccountService accountService = marmotta.getService(AccountService.class);
+
+        final List<UserAccount> accounts = accountService.listAccounts();
+        Assert.assertEquals(2, accounts.size());
+        Assert.assertEquals("anonymous", accounts.get(0).getLogin());
+        Assert.assertEquals("admin", accounts.get(1).getLogin());
+    }
+
+    @Test
+    public void testAdminDefaults() {
+        final AccountService accountService = marmotta.getService(AccountService.class);
+
+        final UserAccount admin = accountService.getAccount("admin");
+        final Set<String> roles = admin.getRoles();
+        Assert.assertEquals(3, roles.size());
+        Assert.assertThat(roles, hasItems("user", "editor", "manager"));
+        Assert.assertTrue(admin.checkPasswd("pass123"));
+    }
+
+}