From d8a9003714306c5e1484afa7d48844b52dcd3546 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 18 Jan 2022 07:21:03 +0200 Subject: [PATCH 01/13] Updated password length min requirment in the console --- app/views/console/users/index.phtml | 2 +- app/views/home/auth/recovery/reset.phtml | 4 ++-- app/views/home/auth/signin.phtml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/console/users/index.phtml b/app/views/console/users/index.phtml index b55917eb5c..607e4d3586 100644 --- a/app/views/console/users/index.phtml +++ b/app/views/console/users/index.phtml @@ -174,7 +174,7 @@ $smtpEnabled = $this->getParam('smtpEnabled', false); - +
diff --git a/app/views/home/auth/recovery/reset.phtml b/app/views/home/auth/recovery/reset.phtml index 6ccefc419c..9d27f22e34 100644 --- a/app/views/home/auth/recovery/reset.phtml +++ b/app/views/home/auth/recovery/reset.phtml @@ -28,10 +28,10 @@ - + - + diff --git a/app/views/home/auth/signin.phtml b/app/views/home/auth/signin.phtml index fc21da1de8..7586b3ddf3 100644 --- a/app/views/home/auth/signin.phtml +++ b/app/views/home/auth/signin.phtml @@ -37,7 +37,7 @@ $root = ($this->getParam('root') !== 'disabled'); - + From 0f209f8430a2cf6112dec13ba78e758e3fe6e690 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Jan 2022 19:38:10 +1300 Subject: [PATCH 02/13] Fix function authorization exception when missing permission --- app/controllers/api/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index f56a9e3a8c..a64c47597a 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -714,7 +714,7 @@ App::post('/v1/functions/:functionId/executions') throw new Exception('Tag not found. Deploy tag before trying to execute a function', 404); } - $validator = new Authorization($function, 'execute'); + $validator = new Authorization('execute'); if (!$validator->isValid($function->getAttribute('execute'))) { // Check if user has write access to execute function throw new Exception($validator->getDescription(), 401); From 219e31483476145c89dd7bc8c9828572570cd7f1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 18 Jan 2022 20:04:36 +1300 Subject: [PATCH 03/13] Add unauthorized test --- .../Functions/FunctionsCustomClientTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 264fae0735..8a55a0ded4 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -218,6 +218,32 @@ class FunctionsCustomClientTest extends Scope ]; } + public function testCreateExecutionUnauthorized():array + { + $function = $this->client->call(Client::METHOD_POST, '/functions', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'functionId' => 'unique()', + 'name' => 'Test', + 'execute' => [], + 'runtime' => 'php-8.0', + 'timeout' => 10, + ]); + + $execution = $this->client->call(Client::METHOD_POST, '/functions/'.$function['body']['$id'].'/executions', [ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], [ + 'async' => 1, + ]); + + $this->assertEquals(401, $execution['headers']['status-code']); + + return []; + } + /** * @depends testCreateCustomExecution */ From 1a6a1498bc80c831e30db5867aa1704d3b9c4b07 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 00:45:44 +1300 Subject: [PATCH 04/13] Add fulltext index for collections collection `name` column to fix `listCollections` search --- app/config/collections.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/config/collections.php b/app/config/collections.php index abcdec9c1d..0138756177 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -102,6 +102,13 @@ $collections = [ 'lengths' => [1024], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => '_fulltext_name', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['name'], + 'lengths' => [256], + 'orders' => [Database::ORDER_ASC], + ], ], ], From 61131434cbe754a94b8b529e52b68094c4e3f6f0 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Tue, 18 Jan 2022 16:25:14 +0200 Subject: [PATCH 05/13] Updated to use minlength and fixed alt attribute --- app/views/console/users/index.phtml | 2 +- app/views/home/auth/recovery/reset.phtml | 4 ++-- app/views/home/auth/signin.phtml | 2 +- app/views/home/auth/signup.phtml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/console/users/index.phtml b/app/views/console/users/index.phtml index 607e4d3586..e0a0306f05 100644 --- a/app/views/console/users/index.phtml +++ b/app/views/console/users/index.phtml @@ -174,7 +174,7 @@ $smtpEnabled = $this->getParam('smtpEnabled', false); - +
diff --git a/app/views/home/auth/recovery/reset.phtml b/app/views/home/auth/recovery/reset.phtml index 9d27f22e34..de67823513 100644 --- a/app/views/home/auth/recovery/reset.phtml +++ b/app/views/home/auth/recovery/reset.phtml @@ -28,10 +28,10 @@ - + - + diff --git a/app/views/home/auth/signin.phtml b/app/views/home/auth/signin.phtml index 7586b3ddf3..98cb513358 100644 --- a/app/views/home/auth/signin.phtml +++ b/app/views/home/auth/signin.phtml @@ -37,7 +37,7 @@ $root = ($this->getParam('root') !== 'disabled'); - + diff --git a/app/views/home/auth/signup.phtml b/app/views/home/auth/signup.phtml index 9aecea62b5..817e1d75f1 100644 --- a/app/views/home/auth/signup.phtml +++ b/app/views/home/auth/signup.phtml @@ -46,7 +46,7 @@ $root = ($this->getParam('root') !== 'disabled'); - +
From fc99863ba649739c4d7a9a7d63598a09bb230e47 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 18 Jan 2022 23:41:51 +0100 Subject: [PATCH 06/13] ci: add github action --- .../workflows/{tests.yml.tmp => tests.yml} | 29 ++++--- .travis-ci/build.sh | 29 ------- .travis-ci/deploy.sh | 1 - .travis.yml | 87 ------------------- 4 files changed, 17 insertions(+), 129 deletions(-) rename .github/workflows/{tests.yml.tmp => tests.yml} (69%) delete mode 100644 .travis-ci/build.sh delete mode 100644 .travis-ci/deploy.sh delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml.tmp b/.github/workflows/tests.yml similarity index 69% rename from .github/workflows/tests.yml.tmp rename to .github/workflows/tests.yml index 29bd70ec83..0a81553df0 100644 --- a/.github/workflows/tests.yml.tmp +++ b/.github/workflows/tests.yml @@ -1,10 +1,9 @@ name: "Tests" - on: [pull_request] jobs: tests: name: Unit & E2E - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout repository @@ -19,16 +18,28 @@ jobs: - run: git checkout HEAD^2 if: ${{ github.event_name == 'pull_request' }} - - name: Build Appwrite - # Upstream bug causes buildkit pulls to fail so prefetch base images - # https://github.com/moby/moby/issues/41864 + - name: Prepare Docker run: | + export COMPOSE_INTERACTIVE_NO_CLI + export DOCKER_BUILDKIT=1 + export COMPOSE_DOCKER_CLI_BUILD=1 echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env docker pull composer:2.0 docker pull php:8.0-cli-alpine - docker compose build --progress=plain + docker compose pull + + - uses: satackey/action-docker-layer-caching@v0.0.11 + # Ignore the failure of a step and avoid terminating the job. + continue-on-error: true + + - name: Build Appwrite + run: docker compose build --progress=plain appwrite + + - name: Start Appwrite + run: | docker compose up -d sleep 30 + - name: Doctor run: docker compose exec -T appwrite doctor @@ -37,9 +48,3 @@ jobs: - name: Run Tests run: docker compose exec -T appwrite test --debug - - - name: Teardown - if: always() - run: | - docker compose down -v - docker ps -aq | xargs docker rm --force diff --git a/.travis-ci/build.sh b/.travis-ci/build.sh deleted file mode 100644 index 57aa5ca110..0000000000 --- a/.travis-ci/build.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash bash - -RED='\033[0;31m' -NC='\033[0m' # No Color - -if [ -z "$1" ] -then - echo "Missing tag number" - exit 1 -fi - -if [ -z "$2" ] -then - echo "Missing version number" - exit 1 -fi - -if test $(find "./app/db/DBIP/dbip-country-lite-2021-12.mmdb" -mmin +259200) -then - printf "${RED}GEO country DB has not been updated for more than 6 months. Go to https://db-ip.com/db/download/ip-to-country-lite to download a newer version${NC}\n" -fi - -echo 'Starting build...' - -docker build --build-arg VERSION="$2" --tag appwrite/appwrite:"$1" . - -echo 'Pushing build to registry...' - -docker push appwrite/appwrite:"$1" diff --git a/.travis-ci/deploy.sh b/.travis-ci/deploy.sh deleted file mode 100644 index b4c132022a..0000000000 --- a/.travis-ci/deploy.sh +++ /dev/null @@ -1 +0,0 @@ -echo 'Nothing to deploy right now.' \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da5897dec5..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,87 +0,0 @@ -dist: focal - -arch: - - amd64 - -os: linux - -vm: - size: large - -language: shell - -notifications: - email: - - team@appwrite.io - -before_install: -# Install latest Docker -- curl -fsSL https://get.docker.com | sh -# Enable Buildkit in Docker config -- echo '{"experimental":"enabled"}' | sudo tee /etc/docker/daemon.json -- mkdir -p $HOME/.docker -- echo '{"experimental":"enabled"}' | sudo tee $HOME/.docker/config.json -- sudo service docker start -# Login to increase Docker Hub ratelimit -- > - if [ ! -z "${DOCKERHUB_PULL_USERNAME:-}" ]; then - echo "${DOCKERHUB_PULL_PASSWORD}" | docker login --username "${DOCKERHUB_PULL_USERNAME}" --password-stdin - fi -- docker --version -# Install latest Compose -- sudo rm /usr/local/bin/docker-compose -- curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > docker-compose -- chmod +x docker-compose -- sudo mv docker-compose /usr/local/bin -- docker-compose --version -# Enable Buildkit -- docker buildx create --name travis_builder --use -- export COMPOSE_INTERACTIVE_NO_CLI -- export DOCKER_BUILDKIT=1 -- export COMPOSE_DOCKER_CLI_BUILD=1 -- export BUILDKIT_PROGRESS=plain -# Only pass a single runtime for CI stability -- echo "_APP_FUNCTIONS_RUNTIMES=php-8.0" >> .env -# Ensure Travis scripts are executable -- chmod -R u+x ./.travis-ci - -install: -- docker-compose pull -# Upstream bug causes buildkit pulls to fail so prefetch base images -# https://github.com/moby/moby/issues/41864 -- docker pull composer:2.0 -- docker pull php:8.0-cli-alpine -- docker-compose build -- docker-compose up -d -- sleep 60 - -script: -- docker ps -a -# Tests should fail if any container is in exited status -# - ALL_UP=`docker ps -aq --filter "status=exited"` -# - > -# if [[ "$ALL_UP" != "" ]]; then -# exit 1 -# fi -- docker-compose logs appwrite -- docker-compose logs appwrite-realtime -- docker-compose logs mariadb -- docker-compose logs appwrite-worker-functions -- docker-compose exec appwrite doctor -- docker-compose exec appwrite vars -- docker-compose exec appwrite test --debug - -after_script: -# travis re-uses their build nodes so clean them up -- docker buildx rm travis_builder - -after_failure: -- docker-compose logs appwrite - -deploy: - - provider: script - edge: true - script: ./.travis-ci/deploy.sh - on: - repo: appwrite/appwrite - branch: deploy From 7a9d477e3ea35753f01dbed613f816d192a638e4 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 18 Jan 2022 23:58:24 +0100 Subject: [PATCH 07/13] Update tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a81553df0..8507ac69f4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,7 +33,7 @@ jobs: continue-on-error: true - name: Build Appwrite - run: docker compose build --progress=plain appwrite + run: docker compose build --progress=plain - name: Start Appwrite run: | From c9d53e01341388b8f9f0f2d3d6980de13a99a185 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 19 Jan 2022 00:02:48 +0100 Subject: [PATCH 08/13] Update tests.yml --- .github/workflows/tests.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8507ac69f4..bff77612f1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,7 +28,8 @@ jobs: docker pull php:8.0-cli-alpine docker compose pull - - uses: satackey/action-docker-layer-caching@v0.0.11 + - name: Prepare Cache + uses: satackey/action-docker-layer-caching@v0.0.11 # Ignore the failure of a step and avoid terminating the job. continue-on-error: true From e45fc7c46ec4c04e18731d72a56a1fa16f229089 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Wed, 19 Jan 2022 00:23:19 +0100 Subject: [PATCH 09/13] Update Scope.php --- tests/e2e/Scopes/Scope.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index b5b5e0e775..079777be4c 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -33,7 +33,7 @@ abstract class Scope extends TestCase protected function getLastEmail():array { - sleep(5); + sleep(3); $emails = json_decode(file_get_contents('http://maildev:1080/email'), true); @@ -46,7 +46,7 @@ abstract class Scope extends TestCase protected function getLastRequest():array { - sleep(5); + sleep(2); $resquest = json_decode(file_get_contents('http://request-catcher:5000/__last_request__'), true); $resquest['data'] = json_decode($resquest['data'], true); @@ -167,4 +167,4 @@ abstract class Scope extends TestCase return self::$user[$this->getProject()['$id']]; } -} \ No newline at end of file +} From 438f80cc5a2d6457b585280fb61e0c6f69beddb7 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 20:57:18 +1300 Subject: [PATCH 10/13] Update query attribute to search, remove name index --- app/config/collections.php | 7 ------- app/controllers/api/database.php | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 0138756177..abcdec9c1d 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -102,13 +102,6 @@ $collections = [ 'lengths' => [1024], 'orders' => [Database::ORDER_ASC], ], - [ - '$id' => '_fulltext_name', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['name'], - 'lengths' => [256], - 'orders' => [Database::ORDER_ASC], - ], ], ], diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index a25e5e62ae..9d5ac716b3 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -230,7 +230,7 @@ App::get('/v1/database/collections') $queries = []; if (!empty($search)) { - $queries[] = new Query('name', Query::TYPE_SEARCH, [$search]); + $queries[] = new Query('search', Query::TYPE_SEARCH, [$search]); } $usage->setParam('database.collections.read', 1); From 06719b172cefdbbd4d15dbfcef2e7387c7c1ae7f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 19 Jan 2022 22:04:57 +1300 Subject: [PATCH 11/13] Add listCollection using `search` parameter tests --- .../Database/DatabaseCustomServerTest.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/e2e/Services/Database/DatabaseCustomServerTest.php b/tests/e2e/Services/Database/DatabaseCustomServerTest.php index 659839debe..b770b2b6c3 100644 --- a/tests/e2e/Services/Database/DatabaseCustomServerTest.php +++ b/tests/e2e/Services/Database/DatabaseCustomServerTest.php @@ -125,6 +125,39 @@ class DatabaseCustomServerTest extends Scope $this->assertCount(0, $collections['body']['collections']); $this->assertEmpty($collections['body']['collections']); + /** + * Test for Search + */ + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'first' + ]); + + $this->assertEquals(1, $collections['body']['sum']); + $this->assertEquals('first', $collections['body']['collections'][0]['$id']); + + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'Test' + ]); + + $this->assertEquals(2, $collections['body']['sum']); + $this->assertEquals('Test 1', $collections['body']['collections'][0]['name']); + $this->assertEquals('Test 2', $collections['body']['collections'][1]['name']); + + $collections = $this->client->call(Client::METHOD_GET, '/database/collections', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'search' => 'Nonexistent' + ]); + + $this->assertEquals(0, $collections['body']['sum']); + /** * Test for FAILURE */ From f5fedf05d5618bf35254c454f551760329ce5121 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Thu, 20 Jan 2022 10:55:33 +0100 Subject: [PATCH 12/13] fix: ui reset form after creating attribute --- app/views/console/database/collection.phtml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index 34b9bfa8c4..93db293ad1 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -620,6 +620,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -675,6 +676,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -739,6 +741,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -803,6 +806,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -855,6 +859,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -911,6 +916,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -963,6 +969,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> @@ -1015,6 +1022,7 @@ $logs = $this->getParam('logs', null); data-failure="alert" data-failure-param-alert-text="Failed to create attribute" data-failure-param-alert-classname="error" + @reset="array = required = false" x-data="{ array: false, required: false }"> From 6715d9a00ea90b2b62dd8666c674897aabc314fa Mon Sep 17 00:00:00 2001 From: Brandon Date: Fri, 21 Jan 2022 06:25:17 -0600 Subject: [PATCH 13/13] docs: update description for delete session endpoint --- docs/references/account/delete-session.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/references/account/delete-session.md b/docs/references/account/delete-session.md index e0ca6d29ac..cd1f22f627 100644 --- a/docs/references/account/delete-session.md +++ b/docs/references/account/delete-session.md @@ -1 +1 @@ -Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the option id argument, only the session unique ID provider will be deleted. \ No newline at end of file +Use this endpoint to log out the currently logged in user from all their account sessions across all of their different devices. When using the Session ID argument, only the unique session ID provided is deleted.