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

Call to get_shares without shares raises a HTTPResponseError with code 200 #131

Closed
jvillafanez opened this issue Nov 25, 2015 · 14 comments
Closed
Assignees
Labels

Comments

@jvillafanez
Copy link
Member

Steps:

  1. Connect with pyocclient to an ownCloud instance and an account without any share
  2. Call the get_shares method in that account

Expected behaviour

Either the call returns an empty list of shares, or raise another kind of exception

Actual behaviour

Checked with the python cli

>>> c2.get_shares()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jvillafanez/.virtualenvs/upgrade_script3/src/pyocclient/owncloud/owncloud.py", line 786, in get_shares
    raise HTTPResponseError(res)
owncloud.owncloud.HTTPResponseError: HTTP error: 200
@PVince81
Copy link
Contributor

@PVince81 PVince81 self-assigned this Nov 25, 2015
@PVince81
Copy link
Contributor

Strange, when I try this against master I get a 404. (get_share with only the name of an existing file).

Which OC version are you testing against ?

@jvillafanez
Copy link
Member Author

ownCloud 8.1.1 (stable)

@PVince81
Copy link
Contributor

I'm getting a 404 with curl as well, on 8.1.1, 8.1.4 and master:

% curl -X GET "http://root:admin@127.0.0.1/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares?path=test"                                                                                                                         !10064
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>failure</status>
  <statuscode>404</statuscode>
  <message>share doesn't exist</message>
 </meta>
 <data/>
</ocs>

How did you setup the shares to get an empty result ?

@PVince81
Copy link
Contributor

(I'd rather expect an empty set here from OCS... but that's another topic)

@jvillafanez
Copy link
Member Author

I have two servers, the first one shares a file with the second one. The call is done in the second one, without accepting the remote share yet, so I guess there shouldn't be any share available in the second server

@PVince81
Copy link
Contributor

Hmmm. Are you able to run select * from oc_share in that server ? It should give no results, but I suspect that there might be some hidden information somewhere that influences the OCS result.

Can you also run the curl command from above against the target server ? (with the correct file name)

@jvillafanez
Copy link
Member Author

Looks like the HTTP code is 200 but the status code from the ocs response is 404. I guess this is fixed in newer versions of the server

curl -v -X GET -u admin:11111  "http://10.0.2.6:21180/ocs/v1.php/apps/files_sharing/api/v1/shares?path=8.jpg"
* Hostname was NOT found in DNS cache
*   Trying 10.0.2.6...
* Connected to 10.0.2.6 (10.0.2.6) port 21180 (#0)
* Server auth using Basic with user 'admin'
> GET /ocs/v1.php/apps/files_sharing/api/v1/shares?path=8.jpg HTTP/1.1
> Authorization: Basic YWRtaW46MTExMTE=
> User-Agent: curl/7.35.0
> Host: 10.0.2.6:21180
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Wed, 25 Nov 2015 13:36:16 GMT
* Server Apache/2.4.7 (Ubuntu) is not blacklisted
< Server: Apache/2.4.7 (Ubuntu)
< X-Powered-By: PHP/5.5.9-1ubuntu4.13
< Set-Cookie: oclbf6etf1um=tra1ri887osditkt0as738mfb7; path=/; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src *; font-src 'self' data:; media-src *; connect-src *
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: Sameorigin
< X-Robots-Tag: none
< Set-Cookie: oclbf6etf1um=qi183gg2bick98qmhmjet0kch3; path=/; HttpOnly
< Set-Cookie: oc_username=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; httponly
< Set-Cookie: oc_token=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; httponly
< Set-Cookie: oc_remember_login=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; httponly
< Set-Cookie: oc_username=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; httponly
< Set-Cookie: oc_token=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; httponly
< Set-Cookie: oc_remember_login=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; httponly
< Set-Cookie: oclbf6etf1um=go8q6pnosjl5ukek17j35jl7r2; path=/; HttpOnly
< Vary: Accept-Encoding
< Content-Length: 160
< Content-Type: text/xml; charset=UTF-8
< 
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>failure</status>
  <statuscode>404</statuscode>
  <message>share doesn't exist</message>
 </meta>
 <data/>
</ocs>
* Connection #0 to host 10.0.2.6 left intact

@PVince81
Copy link
Contributor

This is what I'm getting. And if I use pyocclient with get_share it throws 404, not 200.
I still wonder how you managed to get a 200 ?

@PVince81
Copy link
Contributor

did you add additional arguments ?

@jvillafanez
Copy link
Member Author

Nope. Both servers have ownCloud 8.1.1, with the default configuration

@PVince81
Copy link
Contributor

Are you calling getshare on a newly created file or is it an old one ? Was is shared then unshared ?

@PVince81
Copy link
Contributor

Ok, now I understand: You called get_share() without any arguments.
I think this is not a valid use case.

What I did is call get_share(webdav_root + file_name) and that specific file does not have shares. In that case I get 404.

So maybe it's a bug in the OCS API and it should return 400 bad request if the path= argument is ommitted.

@PVince81
Copy link
Contributor

Ok, @rullzer said it's a legitimate use case that would return all shares.

Here is the fix #132 with a unit test for both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants