diff options
Diffstat (limited to 'apps/files_external')
-rw-r--r-- | apps/files_external/lib/smb.php | 19 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-amazons3-ceph.sh | 17 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-ftp-morrisjobke.sh | 12 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-sftp-atmoz.sh | 13 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-smb-silvershell.sh | 12 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-smb-windows.sh | 5 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-swift-ceph.sh | 94 | ||||
-rwxr-xr-x | apps/files_external/tests/env/start-webdav-ownCloud.sh | 15 | ||||
-rwxr-xr-x | apps/files_external/tests/env/stop-amazons3-ceph.sh | 1 | ||||
-rwxr-xr-x | apps/files_external/tests/env/stop-swift-ceph.sh | 39 | ||||
-rwxr-xr-x | apps/files_external/tests/env/wait-for-connection | 45 |
11 files changed, 248 insertions, 24 deletions
diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index 3db25d477dd..fee34692a02 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -30,6 +30,7 @@ namespace OC\Files\Storage; use Icewind\SMB\Exception\Exception; +use Icewind\SMB\Exception\ForbiddenException; use Icewind\SMB\Exception\NotFoundException; use Icewind\SMB\NativeServer; use Icewind\SMB\Server; @@ -159,6 +160,8 @@ class SMB extends Common { } } catch (NotFoundException $e) { return false; + } catch (ForbiddenException $e) { + return false; } } @@ -235,6 +238,8 @@ class SMB extends Common { return false; } catch (NotFoundException $e) { return false; + } catch (ForbiddenException $e) { + return false; } } @@ -253,6 +258,8 @@ class SMB extends Common { return true; } catch (NotFoundException $e) { return false; + } catch (ForbiddenException $e) { + return false; } } @@ -266,7 +273,13 @@ class SMB extends Common { } public function opendir($path) { - $files = $this->getFolderContents($path); + try { + $files = $this->getFolderContents($path); + } catch (NotFoundException $e) { + return false; + } catch (ForbiddenException $e) { + return false; + } $names = array_map(function ($info) { /** @var \Icewind\SMB\IFileInfo $info */ return $info->getName(); @@ -279,6 +292,8 @@ class SMB extends Common { return $this->getFileInfo($path)->isDirectory() ? 'dir' : 'file'; } catch (NotFoundException $e) { return false; + } catch (ForbiddenException $e) { + return false; } } @@ -298,6 +313,8 @@ class SMB extends Common { return true; } catch (NotFoundException $e) { return false; + } catch (ForbiddenException $e) { + return false; } } diff --git a/apps/files_external/tests/env/start-amazons3-ceph.sh b/apps/files_external/tests/env/start-amazons3-ceph.sh index ad0fedba989..d36980fdd11 100755 --- a/apps/files_external/tests/env/start-amazons3-ceph.sh +++ b/apps/files_external/tests/env/start-amazons3-ceph.sh @@ -31,6 +31,10 @@ if [ -z "$thisFolder" ]; then thisFolder="." fi; +# create readiness notification socket +notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3.sock) +mkfifo "$notify_sock" + user=test accesskey=aaabbbccc secretkey=cccbbbaaa @@ -39,9 +43,10 @@ port=80 container=`docker run -d \ -e RGW_CIVETWEB_PORT=$port \ + -v "$notify_sock":/run/notifyme.sock \ ${docker_image}` -host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4` +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` echo "${docker_image} container: $container" @@ -49,9 +54,13 @@ echo "${docker_image} container: $container" # put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host) echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3 -# TODO find a way to determine the successful initialization inside the docker container -echo "Waiting 20 seconds for ceph initialization ... " -sleep 20 +echo -n "Waiting for ceph initialization" +ready=$(timeout 60 cat "$notify_sock") +if [[ $ready != 'READY=1' ]]; then + echo "[ERROR] Waited 60 seconds, no response" >&2 + exit 1 +fi +sleep 1 echo "Create ceph user" docker exec $container radosgw-admin user create \ diff --git a/apps/files_external/tests/env/start-ftp-morrisjobke.sh b/apps/files_external/tests/env/start-ftp-morrisjobke.sh index 14112d7f803..3a5f6ffcb67 100755 --- a/apps/files_external/tests/env/start-ftp-morrisjobke.sh +++ b/apps/files_external/tests/env/start-ftp-morrisjobke.sh @@ -34,7 +34,7 @@ password=12345 container=`docker run -d -e USERNAME=$user -e PASSWORD=$password morrisjobke/docker-proftpd` -host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4` +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` cat > $thisFolder/config.ftp.php <<DELIM <?php @@ -54,12 +54,16 @@ echo "ftp container: $container" # put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host) echo $container >> $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp +echo -n "Waiting for ftp initialization" +if ! "$thisFolder"/env/wait-for-connection ${host} 21 60; then + echo "[ERROR] Waited 60 seconds, no response" >&2 + exit 1 +fi +sleep 1 + if [ -n "$DEBUG" ]; then cat $thisFolder/config.ftp.php cat $thisFolder/dockerContainerMorrisJobke.$EXECUTOR_NUMBER.ftp fi -# TODO find a way to determine the successful initialization inside the docker container -echo "Waiting 5 seconds for ftp initialization ... " -sleep 5 diff --git a/apps/files_external/tests/env/start-sftp-atmoz.sh b/apps/files_external/tests/env/start-sftp-atmoz.sh index 91eb5747c54..0fc0c5c427f 100755 --- a/apps/files_external/tests/env/start-sftp-atmoz.sh +++ b/apps/files_external/tests/env/start-sftp-atmoz.sh @@ -34,7 +34,7 @@ password=12345 container=`docker run -d atmoz/sftp $user:$password:1001` -host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4` +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` cat > $thisFolder/config.sftp.php <<DELIM <?php @@ -54,15 +54,18 @@ echo "sftp container: $container" # put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host) echo $container >> $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp +echo -n "Waiting for sftp initialization" +if ! "$thisFolder"/env/wait-for-connection ${host} 22 60; then + echo "[ERROR] Waited 60 seconds, no response" >&2 + exit 1 +fi +sleep 1 + if [ -n "$DEBUG" ]; then cat $thisFolder/config.sftp.php cat $thisFolder/dockerContainerAtmoz.$EXECUTOR_NUMBER.sftp fi -# TODO find a way to determine the successful initialization inside the docker container -echo "Waiting 5 seconds for sftp initialization ... " -sleep 5 - # create folder "upload" with correct permissions docker exec $container bash -c "mkdir /home/$user/upload && chown $user:users /home/$user/upload" diff --git a/apps/files_external/tests/env/start-smb-silvershell.sh b/apps/files_external/tests/env/start-smb-silvershell.sh index c45807cc4c8..a7ff3f71eb1 100755 --- a/apps/files_external/tests/env/start-smb-silvershell.sh +++ b/apps/files_external/tests/env/start-smb-silvershell.sh @@ -31,7 +31,7 @@ fi; container=`docker run -d -e SMB_USER=test -e SMB_PWD=test silvershell/samba` -host=`docker inspect $container | grep IPAddress | cut -d '"' -f 4` +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` cat > $thisFolder/config.smb.php <<DELIM <?php @@ -52,12 +52,16 @@ echo "samba container: $container" # put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host) echo $container >> $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb +echo -n "Waiting for samba initialization" +if ! "$thisFolder"/env/wait-for-connection ${host} 445 60; then + echo "[ERROR] Waited 60 seconds, no response" >&2 + exit 1 +fi +sleep 1 + if [ -n "$DEBUG" ]; then cat $thisFolder/config.smb.php cat $thisFolder/dockerContainerSilvershell.$EXECUTOR_NUMBER.smb fi -# TODO find a way to determine the successful initialization inside the docker container -echo "Waiting 5 seconds for smbd initialization ... " -sleep 5 diff --git a/apps/files_external/tests/env/start-smb-windows.sh b/apps/files_external/tests/env/start-smb-windows.sh index 2143d7e7499..a23c879dd96 100755 --- a/apps/files_external/tests/env/start-smb-windows.sh +++ b/apps/files_external/tests/env/start-smb-windows.sh @@ -19,6 +19,11 @@ user=smb-test password=!owncloud123 host=WIN-9GTFAS08C15 +if ! "$thisFolder"/env/wait-for-connection ${host} 445; then + echo "[ERROR] Server not reachable" >&2 + exit 1 +fi + cat > $thisFolder/config.smb.php <<DELIM <?php diff --git a/apps/files_external/tests/env/start-swift-ceph.sh b/apps/files_external/tests/env/start-swift-ceph.sh new file mode 100755 index 00000000000..357512ae4d6 --- /dev/null +++ b/apps/files_external/tests/env/start-swift-ceph.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# +# ownCloud +# +# This script start a docker container to test the files_external tests +# against. It will also change the files_external config to use the docker +# container as testing environment. This is reverted in the stop step.W +# +# Set environment variable DEBUG to print config file +# +# @author Morris Jobke +# @author Robin McCorkell +# @copyright 2015 ownCloud + +if ! command -v docker >/dev/null 2>&1; then + echo "No docker executable found - skipped docker setup" + exit 0; +fi + +echo "Docker executable found - setup docker" + +docker_image=xenopathic/ceph-keystone + +echo "Fetch recent ${docker_image} docker image" +docker pull ${docker_image} + +# retrieve current folder to place the config in the parent folder +thisFolder=`echo $0 | sed 's#env/start-swift-ceph\.sh##'` + +if [ -z "$thisFolder" ]; then + thisFolder="." +fi; + +# create readiness notification socket +notify_sock=$(readlink -f "$thisFolder"/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock) +mkfifo "$notify_sock" + +port=5001 + +user=test +pass=testing +tenant=testenant +region=testregion +service=testceph + +container=`docker run -d \ + -e KEYSTONE_PUBLIC_PORT=${port} \ + -e KEYSTONE_ADMIN_USER=${user} \ + -e KEYSTONE_ADMIN_PASS=${pass} \ + -e KEYSTONE_ADMIN_TENANT=${tenant} \ + -e KEYSTONE_ENDPOINT_REGION=${region} \ + -e KEYSTONE_SERVICE=${service} \ + -e OSD_SIZE=300 \ + --privileged \ + -v "$notify_sock":/run/notifyme.sock \ + ${docker_image}` + +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` + + +echo "${docker_image} container: $container" + +# put container IDs into a file to drop them after the test run (keep in mind that multiple tests run in parallel on the same host) +echo $container >> $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift + +echo -n "Waiting for ceph initialization" +ready=$(timeout 600 cat "$notify_sock") +if [[ $ready != 'READY=1' ]]; then + echo "[ERROR] Waited 600 seconds, no response" >&2 + docker logs $container + exit 1 +fi +sleep 1 + +cat > $thisFolder/config.swift.php <<DELIM +<?php + +return array( + 'run'=>true, + 'url'=>'http://$host:$port/v2.0', + 'user'=>'$user', + 'tenant'=>'$tenant', + 'password'=>'$pass', + 'service_name'=>'$service', + 'bucket'=>'swift', + 'region' => '$region', +); + +DELIM + +if [ -n "$DEBUG" ]; then + cat $thisFolder/config.swift.php + cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift +fi diff --git a/apps/files_external/tests/env/start-webdav-ownCloud.sh b/apps/files_external/tests/env/start-webdav-ownCloud.sh index 6bf9142ee53..d992516d7b1 100755 --- a/apps/files_external/tests/env/start-webdav-ownCloud.sh +++ b/apps/files_external/tests/env/start-webdav-ownCloud.sh @@ -46,20 +46,23 @@ fi container=`docker run -P $parameter -d -e ADMINLOGIN=test -e ADMINPWD=test morrisjobke/owncloud` -# TODO find a way to determine the successful initialization inside the docker container -echo "Waiting 30 seconds for ownCloud initialization ... " -sleep 30 +host=`docker inspect --format="{{.NetworkSettings.IPAddress}}" $container` -# get mapped port on host for internal port 80 - output is IP:PORT - we need to extract the port with 'cut' -port=`docker port $container 80 | cut -f 2 -d :` +echo -n "Waiting for ownCloud initialization" +if ! "$thisFolder"/env/wait-for-connection ${host} 80 60; then + echo "[ERROR] Waited 60 seconds, no response" >&2 + exit 1 +fi +# wait at least 5 more seconds - sometimes the webserver still needs some additional time +sleep 5 cat > $thisFolder/config.webdav.php <<DELIM <?php return array( 'run'=>true, - 'host'=>'localhost:$port/owncloud/remote.php/webdav/', + 'host'=>'${host}:80/owncloud/remote.php/webdav/', 'user'=>'test', 'password'=>'test', 'root'=>'', diff --git a/apps/files_external/tests/env/stop-amazons3-ceph.sh b/apps/files_external/tests/env/stop-amazons3-ceph.sh index 3f56a6f1e5d..dcf30d8c515 100755 --- a/apps/files_external/tests/env/stop-amazons3-ceph.sh +++ b/apps/files_external/tests/env/stop-amazons3-ceph.sh @@ -33,4 +33,5 @@ done; # cleanup rm $thisFolder/config.amazons3.php rm $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3 +rm $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.amazons3.sock diff --git a/apps/files_external/tests/env/stop-swift-ceph.sh b/apps/files_external/tests/env/stop-swift-ceph.sh new file mode 100755 index 00000000000..9f15fb05a7d --- /dev/null +++ b/apps/files_external/tests/env/stop-swift-ceph.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# ownCloud +# +# This script stops the docker container the files_external tests were run +# against. It will also revert the config changes done in start step. +# +# @author Morris Jobke +# @author Robin McCorkell +# @copyright 2015 ownCloud + +if ! command -v docker >/dev/null 2>&1; then + echo "No docker executable found - skipped docker stop" + exit 0; +fi + +echo "Docker executable found - stop and remove docker containers" + +# retrieve current folder to remove the config from the parent folder +thisFolder=`echo $0 | replace "env/stop-swift-ceph.sh" ""` + +if [ -z "$thisFolder" ]; then + thisFolder="." +fi; + +# stopping and removing docker containers +for container in `cat $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift`; do + docker logs $container + + echo "Stopping and removing docker container $container" + # kills running container and removes it + docker rm -f $container +done; + +# cleanup +rm $thisFolder/config.swift.php +rm $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift +rm $thisFolder/dockerContainerCeph.$EXECUTOR_NUMBER.swift.sock + diff --git a/apps/files_external/tests/env/wait-for-connection b/apps/files_external/tests/env/wait-for-connection new file mode 100755 index 00000000000..2c480fb733e --- /dev/null +++ b/apps/files_external/tests/env/wait-for-connection @@ -0,0 +1,45 @@ +#!/usr/bin/php +<?php + +$timeout = 60; + +switch ($argc) { +case 4: + $timeout = (float)$argv[3]; +case 3: + $host = $argv[1]; + $port = (int)$argv[2]; + break; +default: + fwrite(STDERR, 'Usage: '.$argv[0].' host port [timeout]'."\n"); + exit(2); +} + +if ($timeout < 0) { + fwrite(STDERR, 'Timeout must be greater than zero'."\n"); + exit(2); +} +if ($port < 1) { + fwrite(STDERR, 'Port must be an integer greater than zero'."\n"); + exit(2); +} + +$socketTimeout = (float)ini_get('default_socket_timeout'); +if ($socketTimeout > $timeout) { + $socketTimeout = $timeout; +} + +$stopTime = time() + $timeout; +do { + $sock = @fsockopen($host, $port, $errno, $errstr, $socketTimeout); + if ($sock !== false) { + fclose($sock); + fwrite(STDOUT, "\n"); + exit(0); + } + sleep(1); + fwrite(STDOUT, '.'); +} while (time() < $stopTime); + +fwrite(STDOUT, "\n"); +exit(1); |