Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API test for disableSharing #31674

Merged
merged 1 commit into from
Jun 7, 2018
Merged

API test for disableSharing #31674

merged 1 commit into from
Jun 7, 2018

Conversation

paurakhsharma
Copy link
Member

Description

This PR adds test to check API behavior when link sharing is disabled.

Related Issue

#31531

How Has This Been Tested?

Locally

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Acceptance test

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Contributor

@phil-davis phil-davis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also add scenarios that try to share a folder, and make sure that does not work.

And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to share file "welcome.txt" with user "user1" using the API
Then the OCS status code should be "404"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And...

And as user "admin"
When parameter "shareapi_enabled" of app "core" has been set to "no"
Then user "user0" should not be able to share file "welcome.txt" with group "sharinggroup" using the API
Then the OCS status code should be "404"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And...

Given using API version "1"
And using old DAV path

Scenario: user tries to share a file with another user when an sharing api has been disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an sharing api/the sharing api/

Then the OCS status code should be "404"
And the HTTP status code should be "200"

Scenario: user tries to share a file with group when an sharing api has been disabled
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an sharing api/the sharing api/

$options['auth'] = $this->getAuthOptionForUser($sharer);
$this->response = $client->get($fullUrl, $options);
if ($this->isUserOrGroupInSharedData($sharee, $permissions)) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to do this check?
If it returns true here then this return will make this step pass.

@paurakhsharma paurakhsharma force-pushed the API-test-disableSharing branch 2 times, most recently from 8e0ec7b to 6fad514 Compare June 7, 2018 10:40
@paurakhsharma
Copy link
Member Author

What are other scenarios you think I should add here? I will add scenarios for public share after #31677 is merged.

@codecov
Copy link

codecov bot commented Jun 7, 2018

Codecov Report

Merging #31674 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #31674   +/-   ##
=========================================
  Coverage     62.89%   62.89%           
  Complexity    18418    18418           
=========================================
  Files          1154     1154           
  Lines         69157    69157           
  Branches       1260     1260           
=========================================
  Hits          43499    43499           
  Misses        25289    25289           
  Partials        369      369
Flag Coverage Δ Complexity Δ
#javascript 52.39% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 64.1% <ø> (ø) 18418 <ø> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94d8747...02c598b. Read the comment docs.

@phil-davis
Copy link
Contributor

This seems a good set of tests. So I will merge when CI finishes.

@phil-davis
Copy link
Contributor

php-cs-fixer failed:

   1) tests/acceptance/features/bootstrap/Sharing.php (class_definition, method_argument_space, braces)
      ---------- begin diff ----------
--- Original
+++ New
@@ -432,7 +432,7 @@
 	 * @return void
 	 */
 	public function shouldNotBeAbleToCreatePublicShare($sharer, $filepath) {
-		$this->createAPublicShare($sharer,  $filepath);
+		$this->createAPublicShare($sharer, $filepath);
 		PHPUnit_Framework_Assert::assertEquals(
 			404,
 			$this->getOCSResponseStatusCode($this->response)

      ----------- end diff -----------

It is good to do:

make test-php-style

before pushing code up. That saves having these annoying little format issues.

I removed the extra space, squash, rebased...

@paurakhsharma
Copy link
Member Author

Thank you, @phil-davis I will remember it form next time.

@paurakhsharma paurakhsharma merged commit 649c57c into master Jun 7, 2018
@phil-davis phil-davis deleted the API-test-disableSharing branch June 7, 2018 13:43
@paurakhsharma
Copy link
Member Author

Backport on #31694

@phil-davis
Copy link
Contributor

1 line of code was bonus unused - see PR #31695
I have added that commit to the backport.

@lock
Copy link

lock bot commented Jul 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants