From d9b7372f7998f614a358dc09e0987d7e83c4a03d Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 12 Nov 2020 11:57:26 +0545 Subject: [PATCH] Add apiBasic suite with default accounts_hash_difficulty --- .drone.star | 33 +++++++++++-------- ocis/tests/acceptance/config/behat.yml | 20 +++++++++-- .../features/apiBasic/addUser.feature | 18 ++++++++++ .../createShareToSharesFolder.feature | 18 ++++++++++ .../features/apiBasic/uploadFile.feature | 18 ++++++++++ .../apiBasic/webDavPUTAuthInvalid.feature | 26 +++++++++++++++ 6 files changed, 117 insertions(+), 16 deletions(-) create mode 100644 ocis/tests/acceptance/features/apiBasic/addUser.feature create mode 100644 ocis/tests/acceptance/features/apiBasic/createShareToSharesFolder.feature create mode 100644 ocis/tests/acceptance/features/apiBasic/uploadFile.feature create mode 100644 ocis/tests/acceptance/features/apiBasic/webDavPUTAuthInvalid.feature diff --git a/.drone.star b/.drone.star index c28378d00..0acabed2e 100644 --- a/.drone.star +++ b/.drone.star @@ -96,8 +96,10 @@ def getCoreApiTestPipelineNames(): def getDependsOnAllTestPipelines(ctx): dependencies = getTestSuiteNames() + [ 'upload-coverage', - 'localApiTests-owncloud-storage', - 'localApiTests-ocis-storage', + 'localApiTests-apiOcisSpecific-owncloud', + 'localApiTests-apiOcisSpecific-ocis', + 'localApiTests-apiBasic-owncloud', + 'localApiTests-apiBasic-ocis', ] + getCoreApiTestPipelineNames() + getUITestSuiteNames() + ['accountsUITests'] return dependencies @@ -148,8 +150,10 @@ def testPipelines(ctx): pipelines += [ uploadCoverage(ctx), - localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'owncloud'), - localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'ocis') + localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'owncloud', 'apiOcisSpecific'), + localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'ocis', 'apiOcisSpecific'), + localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'owncloud', 'apiBasic', 'default'), + localApiTests(ctx, config['apiTests']['coreBranch'], config['apiTests']['coreCommit'], 'ocis', 'apiBasic', 'default') ] for runPart in range(1, config['apiTests']['numberOfParts'] + 1): @@ -336,11 +340,11 @@ def uploadCoverage(ctx): 'depends_on': getTestSuiteNames(), } -def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'owncloud'): +def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'owncloud', suite = 'apiOcisSpecific', accounts_hash_difficulty = 4): return { 'kind': 'pipeline', 'type': 'docker', - 'name': 'localApiTests-%s-storage' % (storage), + 'name': 'localApiTests-%s-%s' % (suite, storage), 'platform': { 'os': 'linux', 'arch': 'amd64', @@ -348,10 +352,10 @@ def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'ownclo 'steps': generate('ocis') + build() + - ocisServer(storage) + + ocisServer(storage, accounts_hash_difficulty) + cloneCoreRepos(coreBranch, coreCommit) + [ { - 'name': 'localApiTests-%s-storage' % (storage), + 'name': 'localApiTests-%s-%s' % (suite, storage), 'image': 'owncloudci/php:7.4', 'pull': 'always', 'environment' : { @@ -361,6 +365,7 @@ def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'ownclo 'SKELETON_DIR': '/srv/app/tmp/testing/data/apiSkeleton', 'OCIS_SKELETON_STRATEGY': '%s' % ('copy' if storage == 'owncloud' else 'upload'), 'TEST_OCIS':'true', + 'BEHAT_SUITE': suite, 'BEHAT_FILTER_TAGS': '~@skipOnOcis-%s-Storage' % ('OC' if storage == 'owncloud' else 'OCIS'), 'PATH_TO_CORE': '/srv/app/testrunner', }, @@ -391,7 +396,7 @@ def localApiTests(ctx, coreBranch = 'master', coreCommit = '', storage = 'ownclo }, } -def coreApiTests(ctx, coreBranch = 'master', coreCommit = '', part_number = 1, number_of_parts = 1, storage = 'owncloud'): +def coreApiTests(ctx, coreBranch = 'master', coreCommit = '', part_number = 1, number_of_parts = 1, storage = 'owncloud', accounts_hash_difficulty = 4): return { 'kind': 'pipeline', 'type': 'docker', @@ -403,7 +408,7 @@ def coreApiTests(ctx, coreBranch = 'master', coreCommit = '', part_number = 1, n 'steps': generate('ocis') + build() + - ocisServer(storage) + + ocisServer(storage, accounts_hash_difficulty) + cloneCoreRepos(coreBranch, coreCommit) + [ { 'name': 'oC10ApiTests-%s-storage-%s' % (storage, part_number), @@ -452,7 +457,7 @@ def uiTests(ctx, phoenixBranch, phoenixCommit): suiteNames = getUITestSuiteNames() return [uiTestPipeline(suiteName, phoenixBranch, phoenixCommit) for suiteName in suiteNames] -def uiTestPipeline(suiteName, phoenixBranch = 'master', phoenixCommit = '', storage = 'owncloud'): +def uiTestPipeline(suiteName, phoenixBranch = 'master', phoenixCommit = '', storage = 'owncloud', accounts_hash_difficulty = 4): suites = getUITestSuites() paths = "" for path in suites[suiteName]: @@ -469,7 +474,7 @@ def uiTestPipeline(suiteName, phoenixBranch = 'master', phoenixCommit = '', stor 'steps': generate('ocis') + build() + - ocisServer(storage) + [ + ocisServer(storage, accounts_hash_difficulty) + [ { 'name': 'webUITests', 'image': 'owncloudci/nodejs:11', @@ -529,7 +534,7 @@ def uiTestPipeline(suiteName, phoenixBranch = 'master', phoenixCommit = '', stor }, } -def accountsUITests(ctx, phoenixBranch, phoenixCommit, storage = 'owncloud'): +def accountsUITests(ctx, phoenixBranch, phoenixCommit, storage = 'owncloud', accounts_hash_difficulty = 4): return { 'kind': 'pipeline', 'type': 'docker', @@ -541,7 +546,7 @@ def accountsUITests(ctx, phoenixBranch, phoenixCommit, storage = 'owncloud'): 'steps': generate('ocis') + build() + - ocisServer(storage) + [ + ocisServer(storage, accounts_hash_difficulty) + [ { 'name': 'WebUIAcceptanceTests', 'image': 'owncloudci/nodejs:11', diff --git a/ocis/tests/acceptance/config/behat.yml b/ocis/tests/acceptance/config/behat.yml index 1e3eb2229..e7e2025b7 100644 --- a/ocis/tests/acceptance/config/behat.yml +++ b/ocis/tests/acceptance/config/behat.yml @@ -3,9 +3,9 @@ default: '': '%paths.base%/../features/bootstrap' suites: - apiOcisSpecific: + apiBasic: paths: - - '%paths.base%/../features/apiOcisSpecific' + - '%paths.base%/../features/apiBasic' context: &common_ldap_suite_context parameters: ldapAdminPassword: admin @@ -29,6 +29,22 @@ default: - TrashbinContext: - WebDavPropertiesContext: + apiOcisSpecific: + paths: + - '%paths.base%/../features/apiOcisSpecific' + context: *common_ldap_suite_context + contexts: + - RevaContext: + - OccContext: + - FeatureContext: *common_feature_context_params + - CapabilitiesContext: + - ChecksumContext: + - FavoritesContext: + - FilesVersionsContext: + - PublicWebDavContext: + - TrashbinContext: + - WebDavPropertiesContext: + extensions: jarnaiz\JUnitFormatter\JUnitFormatterExtension: filename: report.xml diff --git a/ocis/tests/acceptance/features/apiBasic/addUser.feature b/ocis/tests/acceptance/features/apiBasic/addUser.feature new file mode 100644 index 000000000..c98b81c4b --- /dev/null +++ b/ocis/tests/acceptance/features/apiBasic/addUser.feature @@ -0,0 +1,18 @@ +@api @provisioning_api-app-required @skipOnLDAP +Feature: add user + As an admin + I want to be able to add users + So that I can give people controlled individual access to resources on the ownCloud server + + Scenario Outline: admin creates a user + Given using OCS API version "" + And user "brand-new-user" has been deleted + When the administrator sends a user creation request for user "brand-new-user" password "%alt1%" using the provisioning API + Then the OCS status code should be "" + And the HTTP status code should be "200" + And user "brand-new-user" should exist + And user "brand-new-user" should be able to access a skeleton file + Examples: + | ocs_api_version | ocs_status_code | + | 1 | 100 | + | 2 | 200 | diff --git a/ocis/tests/acceptance/features/apiBasic/createShareToSharesFolder.feature b/ocis/tests/acceptance/features/apiBasic/createShareToSharesFolder.feature new file mode 100644 index 000000000..b2b1af193 --- /dev/null +++ b/ocis/tests/acceptance/features/apiBasic/createShareToSharesFolder.feature @@ -0,0 +1,18 @@ +@api @files_sharing-app-required +Feature: sharing + + Scenario Outline: Creating a share of a file with a user + Given the administrator has set the default folder for received shares to "Shares" + And auto-accept shares has been disabled + And using OCS API version "" + And user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has uploaded file with content "ownCloud test text file 0" to "/textfile0.txt" + And user "Brian" has been created with default attributes and without skeleton files + When user "Alice" shares file "textfile0.txt" with user "Brian" using the sharing API + And user "Brian" accepts share "/textfile0.txt" offered by user "Alice" using the sharing API + Then the HTTP status code should be "200" + And the content of file "/Shares/textfile0.txt" for user "Brian" should be "ownCloud test text file 0" + Examples: + | ocs_api_version | + | 1 | + | 2 | diff --git a/ocis/tests/acceptance/features/apiBasic/uploadFile.feature b/ocis/tests/acceptance/features/apiBasic/uploadFile.feature new file mode 100644 index 000000000..bea7e0ae5 --- /dev/null +++ b/ocis/tests/acceptance/features/apiBasic/uploadFile.feature @@ -0,0 +1,18 @@ +@api +Feature: upload file + As a user + I want to be able to upload files + So that I can store and share files between multiple client systems + + Scenario Outline: upload a file and check download content + Given using OCS API version "" + And user "Alice" has been created with default attributes and without skeleton files + And using DAV path + When user "Alice" uploads file with content "uploaded content" to "/upload.txt" using the WebDAV API + Then the content of file "/upload.txt" for user "Alice" should be "uploaded content" + Examples: + | ocs_api_version | dav_version | + | 1 | old | + | 1 | new | + | 2 | old | + | 2 | new | diff --git a/ocis/tests/acceptance/features/apiBasic/webDavPUTAuthInvalid.feature b/ocis/tests/acceptance/features/apiBasic/webDavPUTAuthInvalid.feature new file mode 100644 index 000000000..79f0b3adb --- /dev/null +++ b/ocis/tests/acceptance/features/apiBasic/webDavPUTAuthInvalid.feature @@ -0,0 +1,26 @@ +@api +Feature: attempt to PUT files with invalid password + + Background: + Given user "Alice" has been created with default attributes and without skeleton files + And user "Alice" has created folder "/PARENT" + + Scenario: send PUT requests to webDav endpoints as normal user with wrong password + When user "Alice" requests these endpoints with "PUT" including body "doesnotmatter" using password "invalid" about user "Alice" + | endpoint | + | /remote.php/webdav/textfile0.txt | + | /remote.php/dav/files/%username%/textfile0.txt | + | /remote.php/webdav/PARENT | + | /remote.php/dav/files/%username%/PARENT | + | /remote.php/dav/files/%username%/PARENT/parent.txt | + Then the HTTP status code of responses on all endpoints should be "401" + + Scenario: send PUT requests to webDav endpoints as normal user with no password + When user "Alice" requests these endpoints with "PUT" including body "doesnotmatter" using password "" about user "Alice" + | endpoint | + | /remote.php/webdav/textfile0.txt | + | /remote.php/dav/files/%username%/textfile0.txt | + | /remote.php/webdav/PARENT | + | /remote.php/dav/files/%username%/PARENT | + | /remote.php/dav/files/%username%/PARENT/parent.txt | + Then the HTTP status code of responses on all endpoints should be "401"