Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
4bd13c4
[ci skip] chore(release): 0.0.4
shoriwe Aug 24, 2023
fca70d6
docs: OpenApi Specification (#9)
MiguelMRojas Sep 2, 2023
409ad31
chore: Update docker-compose (#12)
PedroChaparro Oct 1, 2023
22a84d2
ci: Linter and formatter (#14)
PedroChaparro Oct 3, 2023
4921ca1
feat: endpoint login (#15)
MiguelMRojas Oct 4, 2023
e0e1ea1
[ci skip] chore(release): 0.0.5
shoriwe Oct 4, 2023
ee78fb6
feat: endpoint challenge (#33)
MiguelMRojas Oct 8, 2023
8053b99
[ci skip] chore(release): 0.0.6
shoriwe Oct 8, 2023
556edf9
refactor: Update endpoints (#37)
PedroChaparro Oct 9, 2023
77e1bf2
[ci skip] chore(release): 0.0.7
shoriwe Oct 9, 2023
3e85e7e
Merge branch 'main' into dev
PedroChaparro Oct 9, 2023
d9b0805
[ci skip] chore(release): 0.0.8
shoriwe Oct 9, 2023
3ba394f
fix: Enable CORS (#40)
MiguelMRojas Oct 9, 2023
38392d4
feat: Register endpoint (#39)
AndreaVelasquezA Oct 9, 2023
d8d3871
[ci skip] chore(release): 0.0.9
shoriwe Oct 9, 2023
c4bbd73
Merge branch 'main' into dev
MiguelMRojas Oct 10, 2023
9f8ad6a
fix: Enable all CORS origins (#44)
PedroChaparro Oct 11, 2023
5292585
[ci skip] chore(release): 0.0.10
shoriwe Oct 11, 2023
221c004
Merge branch 'main' into dev
PedroChaparro Oct 11, 2023
b268821
[ci skip] chore(release): 0.0.11
shoriwe Oct 11, 2023
7da7a7c
ci: Fix tagging pipeline (#48)
PedroChaparro Oct 12, 2023
a32f442
ci: Fix typo
PedroChaparro Oct 12, 2023
9dc6959
feat: update docs openapi (#41)
MiguelMRojas Oct 12, 2023
ba8ff15
[ci skip] chore(release): v0.1.0 [skip ci]
shoriwe Oct 12, 2023
af95070
feat: Endpoint to get the file status (#49)
PedroChaparro Oct 12, 2023
7345e45
[ci skip] chore(release): v0.4.0 [skip ci]
shoriwe Oct 12, 2023
b1e93fc
feat: Endpoint to rename a file (#50)
MiguelMRojas Oct 13, 2023
724cc9e
[ci skip] chore(release): v0.5.0 [skip ci]
shoriwe Oct 13, 2023
395b44b
feat: Update password (#51)
AndreaVelasquezA Oct 13, 2023
38a395e
[ci skip] chore(release): v0.6.0 [skip ci]
shoriwe Oct 13, 2023
7aca7f2
feat: create a folder (#52)
MiguelMRojas Oct 14, 2023
3c408a9
[ci skip] chore(release): v0.7.0 [skip ci]
shoriwe Oct 14, 2023
097d026
feat: file upload (#53)
AndreaVelasquezA Oct 14, 2023
f335708
[ci skip] chore(release): v0.8.0 [skip ci]
shoriwe Oct 14, 2023
624cc06
fix(files): Keep files extension (#56)
PedroChaparro Oct 14, 2023
0c7acae
[ci skip] chore(release): v0.8.1 [skip ci]
shoriwe Oct 14, 2023
4de7711
test: Increment save file endpoint coverage (#54)
PedroChaparro Oct 14, 2023
d397a24
Merge branch 'main' into dev
PedroChaparro Oct 14, 2023
c30a733
test(files): Fix broken tests related to file upload (#58)
PedroChaparro Oct 14, 2023
371075b
Merge branch 'main' into dev
PedroChaparro Oct 14, 2023
7c41c70
fix: Add extra validations for UUIDs (#65)
PedroChaparro Oct 15, 2023
4b26239
[ci skip] chore(release): v0.8.2 [skip ci]
shoriwe Oct 15, 2023
a6f7074
feat: share a file with another user (#61)
AndreaVelasquezA Oct 15, 2023
9bf0cdb
feat: download file (#60)
AndreaVelasquezA Oct 15, 2023
1e09c26
[ci skip] chore(release): v0.9.0 [skip ci]
shoriwe Oct 15, 2023
6daf51f
feat: list user files (#64)
MiguelMRojas Oct 15, 2023
62fa02d
[ci skip] chore(release): v0.10.0 [skip ci]
shoriwe Oct 15, 2023
b292621
feat: Get file by UUID (#66)
PedroChaparro Oct 15, 2023
d999d86
[ci skip] chore(release): v0.11.0 [skip ci]
shoriwe Oct 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,46 @@
## [0.8.1](https://github.com/hawks-atlanta/proxy-python/compare/v0.8.0...v0.8.1) (2023-10-14)
# [0.11.0](https://github.com/hawks-atlanta/proxy-python/compare/v0.10.0...v0.11.0) (2023-10-15)


### Bug Fixes
### Features

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



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


### Features

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



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


### Features

* create a folder ([#52](https://github.com/hawks-atlanta/proxy-python/issues/52)) ([7aca7f2](https://github.com/hawks-atlanta/proxy-python/commit/7aca7f204ce10c37154bcf1ed716cd13ca02c142))
* download file ([#60](https://github.com/hawks-atlanta/proxy-python/issues/60)) ([9bf0cdb](https://github.com/hawks-atlanta/proxy-python/commit/9bf0cdb8b7d4901fdcad1991c4a88766bf1a3bf2))
* 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))



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


### Features
### Bug Fixes

* Update password ([#51](https://github.com/hawks-atlanta/proxy-python/issues/51)) ([395b44b](https://github.com/hawks-atlanta/proxy-python/commit/395b44bf9223cf1126521f80ac0ae1796d2207de))
* 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))



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


### Features
### Bug Fixes

* 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))
* **files:** Keep files extension ([#56](https://github.com/hawks-atlanta/proxy-python/issues/56)) ([624cc06](https://github.com/hawks-atlanta/proxy-python/commit/624cc06af6443602bc9b946c8fc7ee5376dbea2c))



43 changes: 40 additions & 3 deletions docs/spec.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,34 @@ paths:
$ref: "#/components/schemas/statusResponse"

/file/{fileUUID}:
get:
tags:
- Files
security:
- bearer: []
description: Get a file by its UUID
parameters:
- in: path
name: fileUUID
required: true
schema:
type: string
description: The ID of the file to get
responses:
"200":
description: File successfully obtained
content:
aplication/json:
schema:
type: object
properties:
file:
type: object
allOf:
- $ref: "#/components/schemas/fileDetails"
msg:
type: string
example: "The file have been obtained successfully"
delete:
tags:
- Files
Expand Down Expand Up @@ -372,9 +400,15 @@ paths:
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/fileDetails"
type: object
properties:
files:
type: array
items:
$ref: "#/components/schemas/fileDetails"
msg:
type: string
example: "Files have been listed successfully"
"401":
description: Not authorized
content:
Expand Down Expand Up @@ -657,6 +691,9 @@ components:
name:
type: string
example: "pixture.png"
extension:
type: string
example: "image/png"
size:
type: integer
example: 4687
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/account/register_user/_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ def register_handler():
return {"msg": "Invalid JSON data provided in the request"}, 400

except Exception as e:
print("[Exception] register_handler ->", str(e))
print("[Exception] register_handler ->", e)
return {"msg": "There was an error registering the user"}, 500
4 changes: 2 additions & 2 deletions src/controllers/account/update_password/_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ def update_password_handler(token):
return {"msg": "Invalid JSON data provided in the request"}, 400

except Exception as e:
print("[Exception] password_handler ->", str(e))
return {"msg": "Internal error", "error": str(e)}, 500
print("[Exception] password_handler ->", e)
return {"msg": "Internal error"}, 500
2 changes: 1 addition & 1 deletion src/controllers/authentication/login/_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ def login_handler():
return {"msg": "Invalid JSON data provided in the request"}, 400

except Exception as e:
print("[Exception] login_handler ->", str(e))
print("[Exception] login_handler ->", e)
return {"msg": "There was an error logging in"}, 500
2 changes: 1 addition & 1 deletion src/controllers/authentication/refresh/_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def challenge_handler(token):
return {"msg": response.msg}, response.code

except Exception as e:
print("[Exception] challenge ->", str(e))
print("[Exception] challenge ->", e)
return {"msg": "There was an error validating or refreshing the session"}, 500
8 changes: 8 additions & 0 deletions src/controllers/files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
from .rename_file._handler import rename_handler
from .create_directory._handler import create_new_dir_handler
from .upload_file._handler import upload_file_handler
from .get_file_by_uuid._handler import get_file_handler
from .list_files._handler import list_files_handler
from .download_file._handler import download_file_handler
from .share_file._handler import share_handler

FILES_HANDLERS = {
"CHECK_STATE": check_state_handler,
"RENAME": rename_handler,
"CREATE_DIRECTORY": create_new_dir_handler,
"UPLOAD": upload_file_handler,
"GET_BY_UUID": get_file_handler,
"FILE_LIST": list_files_handler,
"DOWNLOAD_FILE": download_file_handler,
"SHARE": share_handler,
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}


def test_get_status_not_success_code():
def test_get_status_bad_request():
# Register an user
register_response = soap_client.service.account_register(
{
Expand All @@ -38,6 +38,25 @@ def test_get_status_not_success_code():
assert login_response.error is False
token = login_response.auth.token

# Not valid file UUID (400 Bad Request)
response = app.test_client().get(
"/file/1234/status",
headers={"Authorization": f"Bearer {token}"},
)
assert response.status_code == 400


def test_get_status_not_success_code():
# Login with the user
login_response = soap_client.service.auth_login(
{
"username": get_status_test_data["username"],
"password": get_status_test_data["password"],
}
)
assert login_response.error is False
token = login_response.auth.token

# Try to get status of the file
random_file_uuid = uuid4()
response = soap_client.service.file_check(
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/files/check_file_status/_handler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from src.config.soap_client import soap_client
from src.lib.helpers import is_valid_uuid


def check_state_handler(token, file_uuid):
try:
not_valid_file_uuid = not file_uuid or not is_valid_uuid(file_uuid)
if not_valid_file_uuid:
return {"msg": "Not valid file UUID provided"}, 400

response = soap_client.service.file_check(
{"token": token, "fileUUID": file_uuid}
)
Expand All @@ -16,5 +21,5 @@ def check_state_handler(token, file_uuid):
"ready": response.ready,
}, response.code
except Exception as e:
print("[Exception] check_state_handler ->", str(e))
print("[Exception] check_state_handler ->", e)
return {"msg": "There was an error checking the file state"}, 500
61 changes: 55 additions & 6 deletions src/controllers/files/create_directory/_create_directory_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from main import app

from main import app
from src.config.soap_client import soap_client
from src.lib.faker import fake_username, fake_password

Expand All @@ -10,8 +10,9 @@
"username": fake_username(),
"password": fake_password(),
"folder": {
"uuid": None,
"directoryName": "test-directory232",
"location": "test-location232",
"location": None,
"token": "test-token232",
},
}
Expand Down Expand Up @@ -52,8 +53,19 @@ def test_createfolder_bad_request():
)
assert response.status_code == 400

# Not valid location (400 Bad Request)
response = app.test_client().post(
"/folders",
json={
"directoryName": test_folders["folder"]["directoryName"],
"location": "not-valid-uuid",
},
headers={"Authorization": f"Bearer {token}"},
)
assert response.status_code == 400


def test_createfolder_success():
def test_create_folder_in_root_success():
# Login with the user
login_response = soap_client.service.auth_login(
{
Expand All @@ -73,11 +85,13 @@ def test_createfolder_success():
},
headers={"Authorization": f"Bearer {token}"},
)
create_folder_json_response = json.loads(create_folder_response.data)

assert create_folder_response.status_code == 201
test_folders["folder"]["uuid"] = create_folder_json_response["directoryUUID"]


def test_createfolder_duplicate():
def test_create_folder_in_folder_success():
# Login with the user
login_response = soap_client.service.auth_login(
{
Expand All @@ -88,7 +102,31 @@ def test_createfolder_duplicate():
assert login_response.error is False
token = login_response.auth.token

# Create a folder with a duplicate name
# Create a folder
create_folder_response = app.test_client().post(
"/folders",
json={
"directoryName": test_folders["folder"]["directoryName"],
"location": test_folders["folder"]["uuid"],
},
headers={"Authorization": f"Bearer {token}"},
)

assert create_folder_response.status_code == 201


def test_create_folder_duplicate():
# Login with the user
login_response = soap_client.service.auth_login(
{
"username": test_folders["username"],
"password": test_folders["password"],
}
)
assert login_response.error is False
token = login_response.auth.token

# Create a folder in root with same name
create_folder_response = app.test_client().post(
"/folders",
json={
Expand All @@ -100,4 +138,15 @@ def test_createfolder_duplicate():

# already exists
assert create_folder_response.status_code == 409
json.loads(create_folder_response.data)

# Create a folder in folder with same name
create_folder_response = app.test_client().post(
"/folders",
json={
"directoryName": test_folders["folder"]["directoryName"],
"location": test_folders["folder"]["uuid"],
},
headers={"Authorization": f"Bearer {token}"},
)

assert create_folder_response.status_code == 409
10 changes: 7 additions & 3 deletions src/controllers/files/create_directory/_handler.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import json
from flask import request
from src.config.soap_client import soap_client
from src.lib.helpers import is_valid_uuid


def create_new_dir_handler(token):
try:
data = json.loads(request.data)

directoryName = data.get("directoryName")
location = data.get("location")

if not directoryName or not location:
if not directoryName:
return {"msg": "Required fields are missing in JSON data"}, 400

not_valid_location = location is not None and not is_valid_uuid(location)
if not_valid_location:
return {"msg": "Not valid location provided"}, 400

response = soap_client.service.file_new_dir(
{
"directoryName": directoryName,
Expand All @@ -33,5 +37,5 @@ def create_new_dir_handler(token):
return {"msg": "Invalid JSON data provided in the request"}, 400

except Exception as e:
print("[Exception] create_new_directory ->", str(e))
print("[Exception] create_new_directory ->", e)
return {"msg": "There was an error creating the new directory"}, 500
Loading