Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaw-jan Gurung <saw.jan.grg3e@gmail.com>2021-11-11 12:13:59 +0300
committerGitHub <noreply@github.com>2021-11-11 12:13:59 +0300
commit564b156e888f1396bf4303dd0ef5d904c592c517 (patch)
treeef25b42201f7ff81c07457c1e8ae5e5a37e7956b /test/gui/shared/scripts
parent48c701ef2c881794150f77209a5528daca57843d (diff)
create sync path per user (#9123)
remove inline sync path code fix tests address reviews create sync path only when the user is being added to the client fix sync test steps address reviews
Diffstat (limited to 'test/gui/shared/scripts')
-rw-r--r--test/gui/shared/scripts/bdd_hooks.py39
-rw-r--r--test/gui/shared/scripts/helpers/SetupClientHelper.py45
-rw-r--r--test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py11
-rw-r--r--test/gui/shared/scripts/pageObjects/PublicLinkDialog.py2
4 files changed, 56 insertions, 41 deletions
diff --git a/test/gui/shared/scripts/bdd_hooks.py b/test/gui/shared/scripts/bdd_hooks.py
index 77622152e..848b64580 100644
--- a/test/gui/shared/scripts/bdd_hooks.py
+++ b/test/gui/shared/scripts/bdd_hooks.py
@@ -31,8 +31,7 @@ def hook(context):
'clientSyncTimeout': 'CLIENT_SYNC_TIMEOUT',
'middlewareUrl': 'MIDDLEWARE_URL',
'clientConfigFile': 'CLIENT_LOG_FILE',
- 'clientSyncPathUser1': 'CLIENT_SYNC_PATH_USER1',
- 'clientSyncPathUser2': 'CLIENT_SYNC_PATH_USER2',
+ 'clientRootSyncPath': 'CLIENT_ROOT_SYNC_PATH',
}
DEFAULT_CONFIG = {
@@ -41,8 +40,7 @@ def hook(context):
'clientSyncTimeout': 60,
'middlewareUrl': 'http://localhost:3000/',
'clientConfigFile': '-',
- 'clientSyncPathUser1': '/tmp/client-bdd-user1/',
- 'clientSyncPathUser2': '/tmp/client-bdd-user2/',
+ 'clientRootSyncPath': '/tmp/client-bdd/',
}
# read configs from environment variables
@@ -57,8 +55,8 @@ def hook(context):
for key, value in context.userData.items():
if value == '':
context.userData[key] = cfg.get('DEFAULT', CONFIG_ENV_MAP[key])
- except:
- print("Error reading config.ini file!")
+ except Exception as err:
+ print(err)
# Set the default values if empty
for key, value in context.userData.items():
@@ -66,15 +64,17 @@ def hook(context):
context.userData[key] = DEFAULT_CONFIG[key]
elif key == 'clientSyncTimeout':
context.userData[key] = builtins.int(value)
- elif key == 'clientSyncPathUser1' or key == 'clientSyncPathUser2':
+ elif key == 'clientRootSyncPath':
# make sure there is always one trailing slash
context.userData[key] = value.rstrip('/') + '/'
- if not os.path.exists(context.userData['clientSyncPathUser1']):
- os.makedirs(context.userData['clientSyncPathUser1'])
+ # initially set user sync path to root
+ # this path will be changed according to the user added to the client
+ # e.g.: /tmp/client-bdd/Alice
+ context.userData['currentUserSyncPath'] = context.userData['clientRootSyncPath']
- if not os.path.exists(context.userData['clientSyncPathUser2']):
- os.makedirs(context.userData['clientSyncPathUser2'])
+ if not os.path.exists(context.userData['clientRootSyncPath']):
+ os.makedirs(context.userData['clientRootSyncPath'])
req = urllib.request.Request(
os.path.join(context.userData['middlewareUrl'], 'init'),
@@ -97,20 +97,9 @@ def hook(context):
snooze(5) # ToDo wait smarter till the app died
# delete local files/folders
- for filename in os.listdir(context.userData['clientSyncPathUser1']):
- test.log("Deleting :" + filename)
- file_path = os.path.join(context.userData['clientSyncPathUser1'], filename)
- try:
- if os.path.isfile(file_path) or os.path.islink(file_path):
- os.unlink(file_path)
- elif os.path.isdir(file_path):
- shutil.rmtree(file_path)
- except Exception as e:
- print('Failed to delete %s. Reason: %s' % (file_path, e))
-
- for filename in os.listdir(context.userData['clientSyncPathUser2']):
- test.log("Deleting :" + filename)
- file_path = os.path.join(context.userData['clientSyncPathUser2'], filename)
+ for filename in os.listdir(context.userData['clientRootSyncPath']):
+ test.log("Deleting: " + filename)
+ file_path = os.path.join(context.userData['clientRootSyncPath'], filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
diff --git a/test/gui/shared/scripts/helpers/SetupClientHelper.py b/test/gui/shared/scripts/helpers/SetupClientHelper.py
index ae3a60341..0d62e17b2 100644
--- a/test/gui/shared/scripts/helpers/SetupClientHelper.py
+++ b/test/gui/shared/scripts/helpers/SetupClientHelper.py
@@ -1,5 +1,7 @@
from urllib.parse import urlparse
import squish
+from os import makedirs
+from os.path import exists, join
confdir = '/tmp/bdd-tests-owncloud-client/'
@@ -12,10 +14,10 @@ def substituteInLineCodes(context, value):
'%secure_local_server%', context.userData['secureLocalBackendUrl']
)
value = value.replace(
- '%client_sync_path_user1%', context.userData['clientSyncPathUser1']
+ '%client_root_sync_path%', context.userData['clientRootSyncPath']
)
value = value.replace(
- '%client_sync_path_user2%', context.userData['clientSyncPathUser2']
+ '%current_user_sync_path%', context.userData['currentUserSyncPath']
)
value = value.replace(
'%local_server_hostname%', urlparse(context.userData['localBackendUrl']).netloc
@@ -25,7 +27,7 @@ def substituteInLineCodes(context, value):
def getClientDetails(context):
- clientDetails = {'server': '', 'user': '', 'password': '', 'localfolder': ''}
+ clientDetails = {'server': '', 'user': '', 'password': ''}
for row in context.table[0:]:
row[1] = substituteInLineCodes(context, row[1])
if row[0] == 'server':
@@ -34,15 +36,35 @@ def getClientDetails(context):
clientDetails.update({'user': row[1]})
elif row[0] == 'password':
clientDetails.update({'password': row[1]})
- elif row[0] == 'localfolder':
- clientDetails.update({'localfolder': row[1]})
- try:
- os.makedirs(localfolder, 0o0755)
- except:
- pass
return clientDetails
+def createUserSyncPath(context, username):
+ userSyncPath = join(context.userData['clientRootSyncPath'], username)
+ if not exists(userSyncPath):
+ makedirs(userSyncPath)
+
+ setCurrentUserSyncPath(context, username)
+ return userSyncPath
+
+
+def getUserSyncPath(context, username):
+ return createUserSyncPath(context, username)
+
+
+def setCurrentUserSyncPath(context, user):
+ syncPath = join(context.userData['clientRootSyncPath'], user, '')
+ context.userData['currentUserSyncPath'] = syncPath
+
+
+def getResourcePath(context, resource, user=None):
+ resource == resource.strip('/')
+ if not user == None:
+ return join(context.userData['clientRootSyncPath'], user, resource)
+ else:
+ return join(context.userData['currentUserSyncPath'], resource)
+
+
def startClient(context):
squish.startApplication(
"owncloud -s"
@@ -85,11 +107,14 @@ def setUpClient(context, username, displayName, confFilePath):
'''
userFirstName = username.split()
userSetting = userSetting + getPollingInterval()
+
+ syncPath = createUserSyncPath(context, userFirstName[0])
+
args = {
'displayUserName': displayName,
'davUserName': userFirstName[0].lower(),
'displayUserFirstName': userFirstName[0],
- 'client_sync_path': context.userData['clientSyncPathUser1'],
+ 'client_sync_path': syncPath,
'local_server': context.userData['localBackendUrl'],
}
userSetting = userSetting.format(**args)
diff --git a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py
index 4fa2f233c..aaef3decd 100644
--- a/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py
+++ b/test/gui/shared/scripts/pageObjects/AccountConnectionWizard.py
@@ -1,6 +1,6 @@
import names
import squish
-from helpers.SetupClientHelper import getClientDetails
+from helpers.SetupClientHelper import getClientDetails, createUserSyncPath
import test
@@ -87,6 +87,7 @@ class AccountConnectionWizard:
def addUserCreds(self, context):
clientDetails = getClientDetails(context)
+
squish.type(squish.waitForObject(self.USERNAME_BOX), clientDetails['user'])
squish.type(squish.waitForObject(self.USERNAME_BOX), "<Tab>")
squish.type(squish.waitForObject(self.PASSWORD_BOX), clientDetails['password'])
@@ -94,6 +95,8 @@ class AccountConnectionWizard:
def selectSyncFolder(self, context):
clientDetails = getClientDetails(context)
+ # create sync folder for user
+ syncPath = createUserSyncPath(context, clientDetails['user'])
try:
squish.clickButton(squish.waitForObject(self.ERROR_OK_BUTTON))
@@ -101,13 +104,11 @@ class AccountConnectionWizard:
pass
squish.clickButton(squish.waitForObject(self.SELECT_LOCAL_FOLDER))
squish.mouseClick(squish.waitForObject(self.DIRECTORY_NAME_BOX))
- squish.type(
- squish.waitForObject(self.DIRECTORY_NAME_BOX), clientDetails['localfolder']
- )
+ squish.type(squish.waitForObject(self.DIRECTORY_NAME_BOX), syncPath)
squish.clickButton(squish.waitForObject(self.CHOOSE_BUTTON))
test.compare(
str(squish.waitForObjectExists(self.SELECT_LOCAL_FOLDER).text),
- self.sanitizeFolderPath(clientDetails['localfolder']),
+ self.sanitizeFolderPath(syncPath),
)
def connectAccount(self):
diff --git a/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py b/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py
index f89baa171..b6e7f0768 100644
--- a/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py
+++ b/test/gui/shared/scripts/pageObjects/PublicLinkDialog.py
@@ -76,7 +76,7 @@ class PublicLinkDialog:
test.compare(
str(squish.waitForObjectExists(self.ITEM_TO_SHARE).text),
- resource.replace(context.userData['clientSyncPathUser1'], ''),
+ resource.replace(context.userData['currentUserSyncPath'], ''),
)
if radioObjectName: