Skip to content

Commit d2ab13a

Browse files
MiguelMRojasshoriwePedroChaparroAndreaVelasquezAAndvelavi
authored
release: v0.11.0 (#67)
* test: Increment save file endpoint coverage (#54) * refactor(files): Remove unreachable block Since JSON is not being used in the endpoint, the block is unreachable * test(files): Increment upload handler coverage to 88% All lines, except the `500` status code error, are covered now * test(files): Fix broken tests related to file upload (#58) * fix: Add extra validations for UUIDs (#65) * fix(files): Update endpoint to create directories * fix(files): Add extra validations for UUIDs * feat: share a file with another user (#61) * feat: share a file with another user Endpoint to share files with another user who is registered * fix: fixed integration issues. * refactor(files): Add extra validations to the share endpoint * test(files): Add missing test cases to the endpoint to share a file File is fully covered (87%) except for the internal server error response --------- Co-authored-by: Andvelavi <54145562+Andvelavi@users.noreply.github.com> Co-authored-by: Pedro Andrés Chaparro Quintero <pedro.chaparro.2020@upb.edu.co> * feat: download file (#60) * feat: download file endpont folder creation: download_file download_file contains the .py files _handler.py and _download_files_test, at the moment there is no test. Additionally, the path is added to the _file_views.py file. * fix: import but unused Fixed check-linter errors where unused imports were found * feat(files): Return file instead of JSON when downloading a file According to the openapi spec, the download endpoint should return the file itself * test(files): Update tests to download a file * fix: invalid except valueError Removal of unnecessary exception * style(files): Format views file --------- Co-authored-by: Andvelavi <54145562+Andvelavi@users.noreply.github.com> Co-authored-by: Pedro Andrés Chaparro Quintero <pedro.chaparro.2020@upb.edu.co> Co-authored-by: Pedro Andrés Chaparro Quintero <62714297+PedroChaparro@users.noreply.github.com> * feat: list user files (#64) * feat: Get file by UUID (#66) * docs(openapi): Update spec * feat(files): Add endpoint to get file by its UUID * test(files): Add tests to the new endpoint --------- Co-authored-by: Antonio Donis <antoniojosedonishung@gmail.com> Co-authored-by: Pedro Andrés Chaparro Quintero <62714297+PedroChaparro@users.noreply.github.com> Co-authored-by: Pedro Andrés Chaparro Quintero <pedro.chaparro.2020@upb.edu.co> Co-authored-by: Andrea Velasquez <55466005+andre154@users.noreply.github.com> Co-authored-by: Andvelavi <54145562+Andvelavi@users.noreply.github.com>
1 parent ba95b75 commit d2ab13a

24 files changed

Lines changed: 842 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
1-
## [0.8.1](https://github.com/hawks-atlanta/proxy-python/compare/v0.8.0...v0.8.1) (2023-10-14)
1+
# [0.11.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.10.0...v0.11.0) (2023-10-15)
22

33

4-
### Bug Fixes
4+
### Features
55

6-
* **files:** Keep files extension ([#56](https://github.com/hawks-atlanta/proxy-python/issues/56)) ([624cc06](https://github.com/hawks-atlanta/proxy-python/commit/624cc06af6443602bc9b946c8fc7ee5376dbea2c))
6+
* Get file by UUID ([#66](https://github.com/hawks-atlanta/proxy-python/issues/66)) ([b292621](https://github.com/hawks-atlanta/proxy-python/commit/b2926217b2e4cc03ea59525e1f59c0f2167b6791))
77

88

99

10-
# [0.8.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.7.0...v0.8.0) (2023-10-14)
10+
# [0.10.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.9.0...v0.10.0) (2023-10-15)
1111

1212

1313
### Features
1414

15-
* file upload ([#53](https://github.com/hawks-atlanta/proxy-python/issues/53)) ([097d026](https://github.com/hawks-atlanta/proxy-python/commit/097d0267b4596ee8cea5f24e4b4ceaf019ff801d))
15+
* list user files ([#64](https://github.com/hawks-atlanta/proxy-python/issues/64)) ([6daf51f](https://github.com/hawks-atlanta/proxy-python/commit/6daf51f7860e49bdd5d48c2878a525e14bb08c9a))
1616

1717

1818

19-
# [0.7.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.6.0...v0.7.0) (2023-10-14)
19+
# [0.9.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.8.2...v0.9.0) (2023-10-15)
2020

2121

2222
### Features
2323

24-
* create a folder ([#52](https://github.com/hawks-atlanta/proxy-python/issues/52)) ([7aca7f2](https://github.com/hawks-atlanta/proxy-python/commit/7aca7f204ce10c37154bcf1ed716cd13ca02c142))
24+
* download file ([#60](https://github.com/hawks-atlanta/proxy-python/issues/60)) ([9bf0cdb](https://github.com/hawks-atlanta/proxy-python/commit/9bf0cdb8b7d4901fdcad1991c4a88766bf1a3bf2))
25+
* share a file with another user ([#61](https://github.com/hawks-atlanta/proxy-python/issues/61)) ([a6f7074](https://github.com/hawks-atlanta/proxy-python/commit/a6f7074c3e69edda8bc3c91c370b917c14cc3cc6))
2526

2627

2728

28-
# [0.6.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.5.0...v0.6.0) (2023-10-13)
29+
## [0.8.2](https://github.com/hawks-atlanta/proxy-python/compare/v0.8.1...v0.8.2) (2023-10-15)
2930

3031

31-
### Features
32+
### Bug Fixes
3233

33-
* Update password ([#51](https://github.com/hawks-atlanta/proxy-python/issues/51)) ([395b44b](https://github.com/hawks-atlanta/proxy-python/commit/395b44bf9223cf1126521f80ac0ae1796d2207de))
34+
* Add extra validations for UUIDs ([#65](https://github.com/hawks-atlanta/proxy-python/issues/65)) ([7c41c70](https://github.com/hawks-atlanta/proxy-python/commit/7c41c70445858a3e46e162d59692605375a2ec42))
3435

3536

3637

37-
# [0.5.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.4.0...v0.5.0) (2023-10-13)
38+
## [0.8.1](https://github.com/hawks-atlanta/proxy-python/compare/v0.8.0...v0.8.1) (2023-10-14)
3839

3940

40-
### Features
41+
### Bug Fixes
4142

42-
* Endpoint to rename a file ([#50](https://github.com/hawks-atlanta/proxy-python/issues/50)) ([b1e93fc](https://github.com/hawks-atlanta/proxy-python/commit/b1e93fc468187e15341161c3db1084559b64e93c))
43+
* **files:** Keep files extension ([#56](https://github.com/hawks-atlanta/proxy-python/issues/56)) ([624cc06](https://github.com/hawks-atlanta/proxy-python/commit/624cc06af6443602bc9b946c8fc7ee5376dbea2c))
4344

4445

4546

docs/spec.openapi.yaml

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,34 @@ paths:
319319
$ref: "#/components/schemas/statusResponse"
320320

321321
/file/{fileUUID}:
322+
get:
323+
tags:
324+
- Files
325+
security:
326+
- bearer: []
327+
description: Get a file by its UUID
328+
parameters:
329+
- in: path
330+
name: fileUUID
331+
required: true
332+
schema:
333+
type: string
334+
description: The ID of the file to get
335+
responses:
336+
"200":
337+
description: File successfully obtained
338+
content:
339+
aplication/json:
340+
schema:
341+
type: object
342+
properties:
343+
file:
344+
type: object
345+
allOf:
346+
- $ref: "#/components/schemas/fileDetails"
347+
msg:
348+
type: string
349+
example: "The file have been obtained successfully"
322350
delete:
323351
tags:
324352
- Files
@@ -372,9 +400,15 @@ paths:
372400
content:
373401
application/json:
374402
schema:
375-
type: array
376-
items:
377-
$ref: "#/components/schemas/fileDetails"
403+
type: object
404+
properties:
405+
files:
406+
type: array
407+
items:
408+
$ref: "#/components/schemas/fileDetails"
409+
msg:
410+
type: string
411+
example: "Files have been listed successfully"
378412
"401":
379413
description: Not authorized
380414
content:
@@ -657,6 +691,9 @@ components:
657691
name:
658692
type: string
659693
example: "pixture.png"
694+
extension:
695+
type: string
696+
example: "image/png"
660697
size:
661698
type: integer
662699
example: 4687

src/controllers/account/register_user/_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ def register_handler():
2929
return {"msg": "Invalid JSON data provided in the request"}, 400
3030

3131
except Exception as e:
32-
print("[Exception] register_handler ->", str(e))
32+
print("[Exception] register_handler ->", e)
3333
return {"msg": "There was an error registering the user"}, 500

src/controllers/account/update_password/_handler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ def update_password_handler(token):
2525
return {"msg": "Invalid JSON data provided in the request"}, 400
2626

2727
except Exception as e:
28-
print("[Exception] password_handler ->", str(e))
29-
return {"msg": "Internal error", "error": str(e)}, 500
28+
print("[Exception] password_handler ->", e)
29+
return {"msg": "Internal error"}, 500

src/controllers/authentication/login/_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ def login_handler():
2828
return {"msg": "Invalid JSON data provided in the request"}, 400
2929

3030
except Exception as e:
31-
print("[Exception] login_handler ->", str(e))
31+
print("[Exception] login_handler ->", e)
3232
return {"msg": "There was an error logging in"}, 500

src/controllers/authentication/refresh/_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ def challenge_handler(token):
1414
return {"msg": response.msg}, response.code
1515

1616
except Exception as e:
17-
print("[Exception] challenge ->", str(e))
17+
print("[Exception] challenge ->", e)
1818
return {"msg": "There was an error validating or refreshing the session"}, 500

src/controllers/files/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22
from .rename_file._handler import rename_handler
33
from .create_directory._handler import create_new_dir_handler
44
from .upload_file._handler import upload_file_handler
5+
from .get_file_by_uuid._handler import get_file_handler
6+
from .list_files._handler import list_files_handler
7+
from .download_file._handler import download_file_handler
8+
from .share_file._handler import share_handler
59

610
FILES_HANDLERS = {
711
"CHECK_STATE": check_state_handler,
812
"RENAME": rename_handler,
913
"CREATE_DIRECTORY": create_new_dir_handler,
1014
"UPLOAD": upload_file_handler,
15+
"GET_BY_UUID": get_file_handler,
16+
"FILE_LIST": list_files_handler,
17+
"DOWNLOAD_FILE": download_file_handler,
18+
"SHARE": share_handler,
1119
}

src/controllers/files/check_file_status/_check_file_status_test.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020

21-
def test_get_status_not_success_code():
21+
def test_get_status_bad_request():
2222
# Register an user
2323
register_response = soap_client.service.account_register(
2424
{
@@ -38,6 +38,25 @@ def test_get_status_not_success_code():
3838
assert login_response.error is False
3939
token = login_response.auth.token
4040

41+
# Not valid file UUID (400 Bad Request)
42+
response = app.test_client().get(
43+
"/file/1234/status",
44+
headers={"Authorization": f"Bearer {token}"},
45+
)
46+
assert response.status_code == 400
47+
48+
49+
def test_get_status_not_success_code():
50+
# Login with the user
51+
login_response = soap_client.service.auth_login(
52+
{
53+
"username": get_status_test_data["username"],
54+
"password": get_status_test_data["password"],
55+
}
56+
)
57+
assert login_response.error is False
58+
token = login_response.auth.token
59+
4160
# Try to get status of the file
4261
random_file_uuid = uuid4()
4362
response = soap_client.service.file_check(

src/controllers/files/check_file_status/_handler.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
from src.config.soap_client import soap_client
2+
from src.lib.helpers import is_valid_uuid
23

34

45
def check_state_handler(token, file_uuid):
56
try:
7+
not_valid_file_uuid = not file_uuid or not is_valid_uuid(file_uuid)
8+
if not_valid_file_uuid:
9+
return {"msg": "Not valid file UUID provided"}, 400
10+
611
response = soap_client.service.file_check(
712
{"token": token, "fileUUID": file_uuid}
813
)
@@ -16,5 +21,5 @@ def check_state_handler(token, file_uuid):
1621
"ready": response.ready,
1722
}, response.code
1823
except Exception as e:
19-
print("[Exception] check_state_handler ->", str(e))
24+
print("[Exception] check_state_handler ->", e)
2025
return {"msg": "There was an error checking the file state"}, 500

src/controllers/files/create_directory/_create_directory_test.py

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
2-
from main import app
32

3+
from main import app
44
from src.config.soap_client import soap_client
55
from src.lib.faker import fake_username, fake_password
66

@@ -10,8 +10,9 @@
1010
"username": fake_username(),
1111
"password": fake_password(),
1212
"folder": {
13+
"uuid": None,
1314
"directoryName": "test-directory232",
14-
"location": "test-location232",
15+
"location": None,
1516
"token": "test-token232",
1617
},
1718
}
@@ -52,8 +53,19 @@ def test_createfolder_bad_request():
5253
)
5354
assert response.status_code == 400
5455

56+
# Not valid location (400 Bad Request)
57+
response = app.test_client().post(
58+
"/folders",
59+
json={
60+
"directoryName": test_folders["folder"]["directoryName"],
61+
"location": "not-valid-uuid",
62+
},
63+
headers={"Authorization": f"Bearer {token}"},
64+
)
65+
assert response.status_code == 400
66+
5567

56-
def test_createfolder_success():
68+
def test_create_folder_in_root_success():
5769
# Login with the user
5870
login_response = soap_client.service.auth_login(
5971
{
@@ -73,11 +85,13 @@ def test_createfolder_success():
7385
},
7486
headers={"Authorization": f"Bearer {token}"},
7587
)
88+
create_folder_json_response = json.loads(create_folder_response.data)
7689

7790
assert create_folder_response.status_code == 201
91+
test_folders["folder"]["uuid"] = create_folder_json_response["directoryUUID"]
7892

7993

80-
def test_createfolder_duplicate():
94+
def test_create_folder_in_folder_success():
8195
# Login with the user
8296
login_response = soap_client.service.auth_login(
8397
{
@@ -88,7 +102,31 @@ def test_createfolder_duplicate():
88102
assert login_response.error is False
89103
token = login_response.auth.token
90104

91-
# Create a folder with a duplicate name
105+
# Create a folder
106+
create_folder_response = app.test_client().post(
107+
"/folders",
108+
json={
109+
"directoryName": test_folders["folder"]["directoryName"],
110+
"location": test_folders["folder"]["uuid"],
111+
},
112+
headers={"Authorization": f"Bearer {token}"},
113+
)
114+
115+
assert create_folder_response.status_code == 201
116+
117+
118+
def test_create_folder_duplicate():
119+
# Login with the user
120+
login_response = soap_client.service.auth_login(
121+
{
122+
"username": test_folders["username"],
123+
"password": test_folders["password"],
124+
}
125+
)
126+
assert login_response.error is False
127+
token = login_response.auth.token
128+
129+
# Create a folder in root with same name
92130
create_folder_response = app.test_client().post(
93131
"/folders",
94132
json={
@@ -100,4 +138,15 @@ def test_createfolder_duplicate():
100138

101139
# already exists
102140
assert create_folder_response.status_code == 409
103-
json.loads(create_folder_response.data)
141+
142+
# Create a folder in folder with same name
143+
create_folder_response = app.test_client().post(
144+
"/folders",
145+
json={
146+
"directoryName": test_folders["folder"]["directoryName"],
147+
"location": test_folders["folder"]["uuid"],
148+
},
149+
headers={"Authorization": f"Bearer {token}"},
150+
)
151+
152+
assert create_folder_response.status_code == 409

0 commit comments

Comments
 (0)