-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Endpoint to get the files shared with the user (#80)
* feat: Endpoint to obtain the list of shares, the tests are not yet implemented Receives the user's token and returns the list of shared files/folders and the user they were shared with. * feat: Shared list endpoint Receives the user's token and returns the list of shared files/folders that have been shared with them * fix: check-format * refactor: Added the missing "extension" field Added the missing "extension" field in addition to changing sharedFile to files * refactor: init file and file_views The endpoint is complemented by adding the handler to the init file, in addition to adding the path in the file_views file * feat: Tests for shared_files endpoint The endpoint shared files is completed, adding the tests, which exceed 70% * docs(http): Add new request to bruno collection --------- Co-authored-by: Andvelavi <[email protected]> Co-authored-by: Pedro Andrés Chaparro Quintero <[email protected]>
- Loading branch information
1 parent
79773f6
commit 9fe3011
Showing
5 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
meta { | ||
name: get-shared-with-me | ||
type: http | ||
seq: 15 | ||
} | ||
|
||
get { | ||
url: {{API_BASE_URL}}/file/shared | ||
body: none | ||
auth: bearer | ||
} | ||
|
||
auth:bearer { | ||
token: {{AUTH_TOKEN}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from random import randbytes | ||
from main import app | ||
from src.config.soap_client import soap_client | ||
from src.lib.faker import fake_username, fake_password | ||
|
||
# SHARED WITH FILE TESTS | ||
shared_files_data = { | ||
"username": fake_username(), | ||
"password": fake_password(), | ||
"otherUsername": fake_username(), | ||
"file": { | ||
"uuid": None, | ||
"name": "picture.jpeg", | ||
"content": randbytes(1024), | ||
}, | ||
} | ||
|
||
|
||
def test_shared_bad_request(): | ||
# Register an user | ||
register_response = soap_client.service.account_register( | ||
{ | ||
"username": shared_files_data["username"], | ||
"password": shared_files_data["password"], | ||
} | ||
) | ||
assert register_response.error is False | ||
|
||
# Login with the user | ||
login_response = soap_client.service.auth_login( | ||
{ | ||
"username": shared_files_data["username"], | ||
"password": shared_files_data["password"], | ||
} | ||
) | ||
assert login_response.error is False | ||
|
||
# NO TOKEN | ||
response = app.test_client().get("/file/shared") | ||
assert response.status_code == 401 | ||
|
||
|
||
def test_shared_success_request(): | ||
# Register the second user | ||
register_response2 = soap_client.service.account_register( | ||
{ | ||
"username": shared_files_data["otherUsername"], | ||
"password": shared_files_data["password"], | ||
} | ||
) | ||
assert register_response2.error is False | ||
|
||
# Login with the user | ||
login_response = soap_client.service.auth_login( | ||
{ | ||
"username": shared_files_data["username"], | ||
"password": shared_files_data["password"], | ||
} | ||
) | ||
assert login_response.error is False | ||
token = login_response.auth.token | ||
|
||
# Upload a file as the first user | ||
upload_response = soap_client.service.file_upload( | ||
{ | ||
"token": token, | ||
"fileName": shared_files_data["file"]["name"], | ||
"fileContent": shared_files_data["file"]["content"], | ||
"location": None, | ||
} | ||
) | ||
assert upload_response.error is False | ||
shared_files_data["file"]["uuid"] = upload_response.fileUUID | ||
|
||
# share a file | ||
create_share_response = soap_client.service.share_file( | ||
{ | ||
"fileUUID": shared_files_data["file"]["uuid"], | ||
"otherUsername": shared_files_data["otherUsername"], | ||
"token": token, | ||
} | ||
) | ||
assert create_share_response.error is False | ||
|
||
login_response2 = soap_client.service.auth_login( | ||
{ | ||
"username": shared_files_data["otherUsername"], | ||
"password": shared_files_data["password"], | ||
} | ||
) | ||
assert login_response2.error is False | ||
token2 = login_response2.auth.token | ||
|
||
# list users | ||
file_response = app.test_client().get( | ||
"/file/shared", headers={"Authorization": f"Bearer {token2}"} | ||
) | ||
assert file_response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters