{"action":"created","comment":{"url":"https://api.github.com/repos/linagora/james-project/pulls/comments/231875198","pull_request_review_id":172936481,"id":231875198,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTg3NTE5OA==","diff_hunk":"@@ -0,0 +1,267 @@\n+/****************************************************************\n+ * Licensed to the Apache Software Foundation (ASF) under one   *\n+ * or more contributor license agreements.  See the NOTICE file *\n+ * distributed with this work for additional information        *\n+ * regarding copyright ownership.  The ASF licenses this file   *\n+ * to you under the Apache License, Version 2.0 (the            *\n+ * \"License\"); you may not use this file except in compliance   *\n+ * with the License.  You may obtain a copy of the License at   *\n+ *                                                              *\n+ *   http://www.apache.org/licenses/LICENSE-2.0                 *\n+ *                                                              *\n+ * Unless required by applicable law or agreed to in writing,   *\n+ * software distributed under the License is distributed on an  *\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *\n+ * KIND, either express or implied.  See the License for the    *\n+ * specific language governing permissions and limitations      *\n+ * under the License.                                           *\n+ ****************************************************************/\n+\n+package org.apache.james.webadmin.routes;\n+\n+import static io.restassured.RestAssured.given;\n+import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;\n+import static org.apache.james.webadmin.WebAdminServer.NO_CONFIGURATION;\n+import static org.assertj.core.api.Assertions.assertThat;\n+import static org.assertj.core.api.Assertions.assertThatThrownBy;\n+import static org.hamcrest.Matchers.equalTo;\n+\n+import java.io.File;\n+import java.io.FileInputStream;\n+import java.io.FileNotFoundException;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.net.URL;\n+import java.nio.charset.StandardCharsets;\n+\n+import org.apache.commons.configuration.ConfigurationException;\n+import org.apache.commons.io.FileUtils;\n+import org.apache.commons.io.IOUtils;\n+import org.apache.james.core.User;\n+import org.apache.james.filesystem.api.FileSystem;\n+import org.apache.james.metrics.logger.DefaultMetricFactory;\n+import org.apache.james.sieverepository.api.ScriptContent;\n+import org.apache.james.sieverepository.api.ScriptName;\n+import org.apache.james.sieverepository.api.SieveRepository;\n+import org.apache.james.sieverepository.api.exception.ScriptNotFoundException;\n+import org.apache.james.sieverepository.api.exception.StorageException;\n+import org.apache.james.sieverepository.file.SieveFileRepository;\n+import org.apache.james.user.api.UsersRepository;\n+import org.apache.james.user.api.UsersRepositoryException;\n+import org.apache.james.user.memory.MemoryUsersRepository;\n+import org.apache.james.webadmin.WebAdminServer;\n+import org.apache.james.webadmin.WebAdminUtils;\n+import org.eclipse.jetty.http.HttpStatus;\n+import org.junit.jupiter.api.AfterEach;\n+import org.junit.jupiter.api.BeforeEach;\n+import org.junit.jupiter.api.Test;\n+\n+import io.restassured.RestAssured;\n+\n+public class SieveScriptRoutesTest {\n+\n+    private static final String SIEVE_ROOT = FileSystem.FILE_PROTOCOL + \"sieve\";\n+\n+    private FileSystem fileSystem;\n+\n+    private WebAdminServer webAdminServer;\n+    private SieveRepository sieveRepository;\n+    private UsersRepository usersRepository;\n+    private String sieveContent;\n+\n+    @BeforeEach\n+    public void setUp() throws ConfigurationException, IOException, UsersRepositoryException {\n+        this.fileSystem = new FileSystem() {\n+            @Override\n+            public File getBasedir() throws FileNotFoundException {\n+                return new File(System.getProperty(\"java.io.tmpdir\"));\n+            }\n+\n+            @Override\n+            public InputStream getResource(String url) throws IOException {\n+                return new FileInputStream(getFile(url));\n+            }\n+\n+            @Override\n+            public File getFile(String fileURL) throws FileNotFoundException {\n+                return new File(getBasedir(), fileURL.substring(FileSystem.FILE_PROTOCOL.length()));\n+            }\n+        };\n+\n+        sieveRepository = new SieveFileRepository(fileSystem);\n+        usersRepository = MemoryUsersRepository.withoutVirtualHosting();\n+        usersRepository.addUser(\"userA\", \"password\");\n+\n+        URL sieveResource = ClassLoader.getSystemResource(\"sieve/my_sieve\");\n+        sieveContent = IOUtils.toString(sieveResource, StandardCharsets.UTF_8);\n+\n+        webAdminServer = WebAdminUtils.createWebAdminServer(\n+            new DefaultMetricFactory(),\n+            new SieveScriptRoutes(sieveRepository, usersRepository));\n+        webAdminServer.configure(NO_CONFIGURATION);\n+        webAdminServer.await();\n+\n+        RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)\n+            .build();\n+    }\n+\n+    @AfterEach\n+    public void tearDown() throws IOException {\n+        File root = fileSystem.getFile(SIEVE_ROOT);\n+        // Remove files from the previous test, if any\n+        if (root.exists()) {\n+            FileUtils.forceDelete(root);","path":"server/protocols/webadmin/webadmin-data/src/test/java/org/apache/james/webadmin/routes/SieveScriptRoutesTest.java","position":113,"original_position":113,"commit_id":"2e68d542ae3854f9ec3241d61441ef6f063c6fe3","original_commit_id":"2e68d542ae3854f9ec3241d61441ef6f063c6fe3","user":{"login":"mbaechler","id":708318,"node_id":"MDQ6VXNlcjcwODMxOA==","avatar_url":"https://avatars2.githubusercontent.com/u/708318?v=4","gravatar_id":"","url":"https://api.github.com/users/mbaechler","html_url":"https://github.com/mbaechler","followers_url":"https://api.github.com/users/mbaechler/followers","following_url":"https://api.github.com/users/mbaechler/following{/other_user}","gists_url":"https://api.github.com/users/mbaechler/gists{/gist_id}","starred_url":"https://api.github.com/users/mbaechler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbaechler/subscriptions","organizations_url":"https://api.github.com/users/mbaechler/orgs","repos_url":"https://api.github.com/users/mbaechler/repos","events_url":"https://api.github.com/users/mbaechler/events{/privacy}","received_events_url":"https://api.github.com/users/mbaechler/received_events","type":"User","site_admin":false},"body":"there's a @TestRule for that.\r\nAnyway, I don't see why we should use files for that","created_at":"2018-11-08T12:52:52Z","updated_at":"2018-11-08T12:53:58Z","html_url":"https://github.com/linagora/james-project/pull/1893#discussion_r231875198","pull_request_url":"https://api.github.com/repos/linagora/james-project/pulls/1893","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments/231875198"},"html":{"href":"https://github.com/linagora/james-project/pull/1893#discussion_r231875198"},"pull_request":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1893"}}},"pull_request":{"url":"https://api.github.com/repos/linagora/james-project/pulls/1893","id":228993430,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI4OTkzNDMw","html_url":"https://github.com/linagora/james-project/pull/1893","diff_url":"https://github.com/linagora/james-project/pull/1893.diff","patch_url":"https://github.com/linagora/james-project/pull/1893.patch","issue_url":"https://api.github.com/repos/linagora/james-project/issues/1893","number":1893,"state":"open","locked":false,"title":"JAMES-2585 Add activate sieve script","user":{"login":"hoangdat","id":6462404,"node_id":"MDQ6VXNlcjY0NjI0MDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6462404?v=4","gravatar_id":"","url":"https://api.github.com/users/hoangdat","html_url":"https://github.com/hoangdat","followers_url":"https://api.github.com/users/hoangdat/followers","following_url":"https://api.github.com/users/hoangdat/following{/other_user}","gists_url":"https://api.github.com/users/hoangdat/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangdat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangdat/subscriptions","organizations_url":"https://api.github.com/users/hoangdat/orgs","repos_url":"https://api.github.com/users/hoangdat/repos","events_url":"https://api.github.com/users/hoangdat/events{/privacy}","received_events_url":"https://api.github.com/users/hoangdat/received_events","type":"User","site_admin":false},"body":"JIRA: https://issues.apache.org/jira/browse/JAMES-2585?jql=project%20%3D%20JAMES","created_at":"2018-11-07T11:12:08Z","updated_at":"2018-11-08T12:53:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a30dab973e00abe16437a751f88e35d86c6dca33","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":937092296,"node_id":"MDU6TGFiZWw5MzcwOTIyOTY=","url":"https://api.github.com/repos/linagora/james-project/labels/newcomer","name":"newcomer","color":"16f4aa","default":false}],"milestone":{"url":"https://api.github.com/repos/linagora/james-project/milestones/11","html_url":"https://github.com/linagora/james-project/milestone/11","labels_url":"https://api.github.com/repos/linagora/james-project/milestones/11/labels","id":3783849,"node_id":"MDk6TWlsZXN0b25lMzc4Mzg0OQ==","number":11,"title":"Sprint 42","description":"","creator":{"login":"chibenwa","id":6928740,"node_id":"MDQ6VXNlcjY5Mjg3NDA=","avatar_url":"https://avatars1.githubusercontent.com/u/6928740?v=4","gravatar_id":"","url":"https://api.github.com/users/chibenwa","html_url":"https://github.com/chibenwa","followers_url":"https://api.github.com/users/chibenwa/followers","following_url":"https://api.github.com/users/chibenwa/following{/other_user}","gists_url":"https://api.github.com/users/chibenwa/gists{/gist_id}","starred_url":"https://api.github.com/users/chibenwa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chibenwa/subscriptions","organizations_url":"https://api.github.com/users/chibenwa/orgs","repos_url":"https://api.github.com/users/chibenwa/repos","events_url":"https://api.github.com/users/chibenwa/events{/privacy}","received_events_url":"https://api.github.com/users/chibenwa/received_events","type":"User","site_admin":false},"open_issues":16,"closed_issues":23,"state":"open","created_at":"2018-10-31T01:58:12Z","updated_at":"2018-11-08T10:58:35Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/linagora/james-project/pulls/1893/commits","review_comments_url":"https://api.github.com/repos/linagora/james-project/pulls/1893/comments","review_comment_url":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linagora/james-project/issues/1893/comments","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/2e68d542ae3854f9ec3241d61441ef6f063c6fe3","head":{"label":"hoangdat:JAMES-2585-add-activate-sieve-script","ref":"JAMES-2585-add-activate-sieve-script","sha":"2e68d542ae3854f9ec3241d61441ef6f063c6fe3","user":{"login":"hoangdat","id":6462404,"node_id":"MDQ6VXNlcjY0NjI0MDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6462404?v=4","gravatar_id":"","url":"https://api.github.com/users/hoangdat","html_url":"https://github.com/hoangdat","followers_url":"https://api.github.com/users/hoangdat/followers","following_url":"https://api.github.com/users/hoangdat/following{/other_user}","gists_url":"https://api.github.com/users/hoangdat/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangdat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangdat/subscriptions","organizations_url":"https://api.github.com/users/hoangdat/orgs","repos_url":"https://api.github.com/users/hoangdat/repos","events_url":"https://api.github.com/users/hoangdat/events{/privacy}","received_events_url":"https://api.github.com/users/hoangdat/received_events","type":"User","site_admin":false},"repo":{"id":155144672,"node_id":"MDEwOlJlcG9zaXRvcnkxNTUxNDQ2NzI=","name":"james-project","full_name":"hoangdat/james-project","private":false,"owner":{"login":"hoangdat","id":6462404,"node_id":"MDQ6VXNlcjY0NjI0MDQ=","avatar_url":"https://avatars2.githubusercontent.com/u/6462404?v=4","gravatar_id":"","url":"https://api.github.com/users/hoangdat","html_url":"https://github.com/hoangdat","followers_url":"https://api.github.com/users/hoangdat/followers","following_url":"https://api.github.com/users/hoangdat/following{/other_user}","gists_url":"https://api.github.com/users/hoangdat/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangdat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangdat/subscriptions","organizations_url":"https://api.github.com/users/hoangdat/orgs","repos_url":"https://api.github.com/users/hoangdat/repos","events_url":"https://api.github.com/users/hoangdat/events{/privacy}","received_events_url":"https://api.github.com/users/hoangdat/received_events","type":"User","site_admin":false},"html_url":"https://github.com/hoangdat/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/hoangdat/james-project","forks_url":"https://api.github.com/repos/hoangdat/james-project/forks","keys_url":"https://api.github.com/repos/hoangdat/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hoangdat/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hoangdat/james-project/teams","hooks_url":"https://api.github.com/repos/hoangdat/james-project/hooks","issue_events_url":"https://api.github.com/repos/hoangdat/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/hoangdat/james-project/events","assignees_url":"https://api.github.com/repos/hoangdat/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/hoangdat/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/hoangdat/james-project/tags","blobs_url":"https://api.github.com/repos/hoangdat/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hoangdat/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hoangdat/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/hoangdat/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hoangdat/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/hoangdat/james-project/languages","stargazers_url":"https://api.github.com/repos/hoangdat/james-project/stargazers","contributors_url":"https://api.github.com/repos/hoangdat/james-project/contributors","subscribers_url":"https://api.github.com/repos/hoangdat/james-project/subscribers","subscription_url":"https://api.github.com/repos/hoangdat/james-project/subscription","commits_url":"https://api.github.com/repos/hoangdat/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/hoangdat/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/hoangdat/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/hoangdat/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/hoangdat/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/hoangdat/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hoangdat/james-project/merges","archive_url":"https://api.github.com/repos/hoangdat/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hoangdat/james-project/downloads","issues_url":"https://api.github.com/repos/hoangdat/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/hoangdat/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/hoangdat/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/hoangdat/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hoangdat/james-project/labels{/name}","releases_url":"https://api.github.com/repos/hoangdat/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/hoangdat/james-project/deployments","created_at":"2018-10-29T03:11:30Z","updated_at":"2018-10-29T03:11:48Z","pushed_at":"2018-11-08T11:39:04Z","git_url":"git://github.com/hoangdat/james-project.git","ssh_url":"git@github.com:hoangdat/james-project.git","clone_url":"https://github.com/hoangdat/james-project.git","svn_url":"https://github.com/hoangdat/james-project","homepage":null,"size":37507,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"linagora:master","ref":"master","sha":"1c7c2fe7a0f077c6fce16f8ef70990ffbbba5514","user":{"login":"linagora","id":1230365,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMzAzNjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1230365?v=4","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"repo":{"id":39182136,"node_id":"MDEwOlJlcG9zaXRvcnkzOTE4MjEzNg==","name":"james-project","full_name":"linagora/james-project","private":false,"owner":{"login":"linagora","id":1230365,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMzAzNjU=","avatar_url":"https://avatars3.githubusercontent.com/u/1230365?v=4","gravatar_id":"","url":"https://api.github.com/users/linagora","html_url":"https://github.com/linagora","followers_url":"https://api.github.com/users/linagora/followers","following_url":"https://api.github.com/users/linagora/following{/other_user}","gists_url":"https://api.github.com/users/linagora/gists{/gist_id}","starred_url":"https://api.github.com/users/linagora/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linagora/subscriptions","organizations_url":"https://api.github.com/users/linagora/orgs","repos_url":"https://api.github.com/users/linagora/repos","events_url":"https://api.github.com/users/linagora/events{/privacy}","received_events_url":"https://api.github.com/users/linagora/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/linagora/james-project","description":"Mirror of Apache James Project","fork":true,"url":"https://api.github.com/repos/linagora/james-project","forks_url":"https://api.github.com/repos/linagora/james-project/forks","keys_url":"https://api.github.com/repos/linagora/james-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linagora/james-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linagora/james-project/teams","hooks_url":"https://api.github.com/repos/linagora/james-project/hooks","issue_events_url":"https://api.github.com/repos/linagora/james-project/issues/events{/number}","events_url":"https://api.github.com/repos/linagora/james-project/events","assignees_url":"https://api.github.com/repos/linagora/james-project/assignees{/user}","branches_url":"https://api.github.com/repos/linagora/james-project/branches{/branch}","tags_url":"https://api.github.com/repos/linagora/james-project/tags","blobs_url":"https://api.github.com/repos/linagora/james-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linagora/james-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linagora/james-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/linagora/james-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linagora/james-project/statuses/{sha}","languages_url":"https://api.github.com/repos/linagora/james-project/languages","stargazers_url":"https://api.github.com/repos/linagora/james-project/stargazers","contributors_url":"https://api.github.com/repos/linagora/james-project/contributors","subscribers_url":"https://api.github.com/repos/linagora/james-project/subscribers","subscription_url":"https://api.github.com/repos/linagora/james-project/subscription","commits_url":"https://api.github.com/repos/linagora/james-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/linagora/james-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/linagora/james-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/linagora/james-project/issues/comments{/number}","contents_url":"https://api.github.com/repos/linagora/james-project/contents/{+path}","compare_url":"https://api.github.com/repos/linagora/james-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linagora/james-project/merges","archive_url":"https://api.github.com/repos/linagora/james-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linagora/james-project/downloads","issues_url":"https://api.github.com/repos/linagora/james-project/issues{/number}","pulls_url":"https://api.github.com/repos/linagora/james-project/pulls{/number}","milestones_url":"https://api.github.com/repos/linagora/james-project/milestones{/number}","notifications_url":"https://api.github.com/repos/linagora/james-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linagora/james-project/labels{/name}","releases_url":"https://api.github.com/repos/linagora/james-project/releases{/id}","deployments_url":"https://api.github.com/repos/linagora/james-project/deployments","created_at":"2015-07-16T07:04:59Z","updated_at":"2018-11-08T10:58:16Z","pushed_at":"2018-11-08T11:39:06Z","git_url":"git://github.com/linagora/james-project.git","ssh_url":"git@github.com:linagora/james-project.git","clone_url":"https://github.com/linagora/james-project.git","svn_url":"https://github.com/linagora/james-project","homepage":null,"size":37627,"stargazers_count":23,"watchers_count":23,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":33,"mirror_url":null,"archived":false,"open_issues_count":86,"license":null,"forks":33,"open_issues":86,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1893"},"html":{"href":"https://github.com/linagora/james-project/pull/1893"},"issue":{"href":"https://api.github.com/repos/linagora/james-project/issues/1893"},"comments":{"href":"https://api.github.com/repos/linagora/james-project/issues/1893/comments"},"review_comments":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1893/comments"},"review_comment":{"href":"https://api.github.com/repos/linagora/james-project/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linagora/james-project/pulls/1893/commits"},"statuses":{"href":"https://api.github.com/repos/linagora/james-project/statuses/2e68d542ae3854f9ec3241d61441ef6f063c6fe3"}},"author_association":"NONE"}}
{"actor":{"display_login":"mbaechler"}}