Giter Club home page Giter Club logo

Comments (2)

daniel-hunt-tessella avatar daniel-hunt-tessella commented on July 1, 2024

Up-to-date Acceptance Criteria
Authorised DELETE request to: http://172.28.129.160:8888/deletefile/
With body of form {"bucket": "<bucket-name>", "file": "<file-path-and-name>"}.
Eg: {"bucket": "ditto-anything-i-want", "file": "/2test2/33testing/444testing/555testing/test.txt"}

Should return a warning message if the bucket or the file does not exist at the S3 end

Otherwise, deletes the file and returns a message confirming the deletion


Testing
Note that as part of #71 status and status code errors will be fixed. ✔️
Works for the happy path and if the bucket or file does not exist at the S3 end ✔️

❌ Problem caused when a file path is given that goes outside the bucket - eg {"bucket": "ditto-anything-i-want", "file": ".."}. Also applies when "file": "" is given
This causes a 500 Internal Server Error
This actually happens for all API calls that require a file or directory

2018-11-30 09:47:57,514 ditto-web-api DEBUG    Called delete-file handler
DEBUG:ditto-web-api:Called delete-file handler
2018-11-30 09:47:57,514 ditto-web-api DEBUG    About to check for warning to do with bucket name ditto-anything-i-want
DEBUG:ditto-web-api:About to check for warning to do with bucket name ditto-anything-i-want
2018-11-30 09:47:57,517 ditto-web-api DEBUG    Bucket "ditto-anything-i-want" does exist
DEBUG:ditto-web-api:Bucket "ditto-anything-i-want" does exist
2018-11-30 09:47:57,517 ditto-web-api DEBUG    No bucket related warnings found
DEBUG:ditto-web-api:No bucket related warnings found
ERROR:tornado.application:Uncaught exception DELETE /deletefile/ (172.28.129.1)
HTTPServerRequest(protocol='http', host='172.28.129.160:8888', method='DELETE', uri='/deletefile/', version='HTTP/1.1', remote_ip='172.28.129.1')
Traceback (most recent call last):
  File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado/web.py", line 1592, in _execute
    result = yield result
  File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado/gen.py", line 326, in wrapper
    yielded = next(result)
  File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/tornado_json/schema.py", line 160, in_wrapper
    output = rh_method(self, *args, **kwargs)
  File "/home/vagrant/ditto_web_api/DittoWebApi/src/handlers/delete_file.py", line 25, in delete
    result = self._data_replication_service.try_delete_file(bucket_name, file_rel_path)
  File "/home/vagrant/ditto_web_api/DittoWebApi/src/services/data_replication/data_replication_service.py", line 92, in try_delete_file
    if not self._external_data_service.does_object_exist(bucket_name, file_rel_path):
  File "/home/vagrant/ditto_web_api/DittoWebApi/src/services/external/external_data_service.py", line 79, indoes_object_exist
    key = bucket.get_key(file_name)
  File "/home/vagrant/ditto_web_api/DittoWebApi/src/services/external/storage_adapters/boto_bucket.py", line13, in get_key
    key = self._bucket.get_key(*args, **kwargs)
  File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/boto/s3/bucket.py", line 193, in get_key
    key, resp = self._get_key_internal(key_name, headers, query_args_l)
  File "/home/vagrant/ditto_web_api/venv/lib64/python3.6/site-packages/boto/s3/bucket.py", line 232, in _get_key_internal
    response.status, response.reason, '')
boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request

ERROR:tornado.access:500 DELETE /deletefile/ (172.28.129.1) 61.91ms

from ditto.

daniel-hunt-tessella avatar daniel-hunt-tessella commented on July 1, 2024

Problem caused by attempting to delete a file outside of the root directory has been resolved. This now returns a 403 Forbidden error instead of the previous 500 error

from ditto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.