Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 00df7ada authored by Tobias Kaminsky's avatar Tobias Kaminsky Committed by GitHub
Browse files

Merge pull request #358 from nextcloud/directEditing

Add direct endpoint api
parents 1b57251e 1c603f3d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ services:
      - su www-data -c "php /var/www/html/occ group:adduser users user2"
      - su www-data -c "git clone -b master https://github.com/nextcloud/activity.git /var/www/html/apps/activity/"
      - su www-data -c "php /var/www/html/occ app:enable activity"
      - su www-data -c "git clone -b master https://github.com/nextcloud/text.git /var/www/html/apps/text/"
      - su www-data -c "php /var/www/html/occ app:enable text"
      - /run.sh

trigger:
+1 −1
Original line number Diff line number Diff line
168
 No newline at end of file
144
+4 −1
Original line number Diff line number Diff line
@@ -8,8 +8,11 @@
    <Match>
        <Class name="~.*\.R\$.*" />
    </Match>
    <Match>
        <Class name="~.*\$\$Parcelable.*" />
    </Match>
    <Bug pattern="PATH_TRAVERSAL_IN" />
    <Bug pattern="ANDROID_EXTERNAL_FILE_ACCESS" />
    <Bug pattern="BAS_BLOATED_ASSIGNMENT_SCOPE" />
    <Bug pattern="SECHPP" />
    <Bug pattern="HTTP_PARAMETER_POLLUTION" />
</FindBugsFilter>
+65 −0
Original line number Diff line number Diff line
/* Nextcloud Android Library is available under MIT license
 *
 *   @author Tobias Kaminsky
 *   Copyright (C) 2019 Tobias Kaminsky
 *   Copyright (C) 2019 Nextcloud GmbH
 *
 *   Permission is hereby granted, free of charge, to any person obtaining a copy
 *   of this software and associated documentation files (the "Software"), to deal
 *   in the Software without restriction, including without limitation the rights
 *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *   copies of the Software, and to permit persons to whom the Software is
 *   furnished to do so, subject to the following conditions:
 *
 *   The above copyright notice and this permission notice shall be included in
 *   all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *   THE SOFTWARE.
 *
 */

package com.nextcloud.android.lib.resources.directediting;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class DirectEditingCreateFileRemoteOperationTest extends AbstractIT {
    @Test
    public void createEmptyFile() {
        RemoteOperationResult result = new DirectEditingCreateFileRemoteOperation("/test.md",
                                                                                  "text",
                "textdocument")
                .execute(client);
        assertTrue(result.isSuccess());

        String url = (String) result.getSingleData();

        assertFalse(url.isEmpty());
    }

    @Test
    public void createFileFromTemplate() {
        RemoteOperationResult result = new DirectEditingCreateFileRemoteOperation("/test.md",
                                                                                  "text",
                "textdocument",
                                                                                  "1")
                .execute(client);
        assertTrue(result.isSuccess());

        String url = (String) result.getSingleData();

        assertFalse(url.isEmpty());
    }
}
+53 −0
Original line number Diff line number Diff line
/* Nextcloud Android Library is available under MIT license
 *
 *   @author Tobias Kaminsky
 *   Copyright (C) 2019 Tobias Kaminsky
 *   Copyright (C) 2019 Nextcloud GmbH
 *
 *   Permission is hereby granted, free of charge, to any person obtaining a copy
 *   of this software and associated documentation files (the "Software"), to deal
 *   in the Software without restriction, including without limitation the rights
 *   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *   copies of the Software, and to permit persons to whom the Software is
 *   furnished to do so, subject to the following conditions:
 *
 *   The above copyright notice and this permission notice shall be included in
 *   all copies or substantial portions of the Software.
 *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 *   BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 *   ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 *   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *   THE SOFTWARE.
 *
 */

package com.nextcloud.android.lib.resources.directediting;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.TemplateList;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class DirectEditingObtainListOfTemplatesRemoteOperationTest extends AbstractIT {

    @Test
    public void testGetAll() {
        RemoteOperationResult result = new DirectEditingObtainListOfTemplatesRemoteOperation("text",
                "textdocument")
                .execute(client);
        assertTrue(result.isSuccess());

        TemplateList templateList = (TemplateList) result.getSingleData();

        assertEquals("Empty file", templateList.templates.get("empty").title);
        assertEquals("md", templateList.templates.get("empty").extension);
    }
}
Loading