-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Added #9413: Asset file upload from API #14698
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Signed-off-by: snipe <snipe@snipe.net>
Based heavily on the Assets assets files controller. Added errors related to to the files management. Added the API endpoints for file upload and show, but only upload is currently tested/works.
Error/success was mixed up
💖 Thanks for this pull request! 💖 We use semantic commit messages to streamline the release process and easily generate changelogs between versions. Before your pull request can be merged, you should update your pull request title to start with a semantic prefix if it doesn't have one already. Examples of commit messages with semantic prefixes:
Things that will help get your PR across the finish line:
We get a lot of pull requests on this repo, so please be patient and we will get back to you as soon as we can. |
PR Summary
|
@Scarzy I'll follow up on your comment about testing here
First off, thanks for being thorough about testing. I appreciate that 😄 What issues were you running into getting the test suite up and running? It's not part of the PR template so you might have missed it but have you seen the testing docs here? |
I have read the testing page, yes. I have now got a clean copy of my branch running in an Ubuntu 22.04 VM, and my current error is; phpunit (v9.5.10) is definitely installed, I had to install that through apt as a separate step |
Ok, got past that issue. I'm not familiar with composer and didn't realise I needed to rerun the install step without the "--no-dev" argument. I'm now able to run the testing, I get 12 fails 224 passes, the fails are; FAIL Tests\Unit\CustomFieldTest I also had 6 failures in LDAP (primarily 'Undefined constant "App\Models\LDAP_OPT_REFERRALS"'), but as I haven't got LDAP set up, I'm now running the tests with the LDAP group excluded. As I'm now able to run the tests, I'll get some tests for the new file uploads sorted and report back. |
@Scarzy I appreciate you pushing through this. I'm using Herd and not docker so I'm not sure of any quirks in getting the app running for development in Docker.
I would assume that would work but ideally the composer file will get you up and running (without that If you're able to write up tests and focus on running just the ones you create you can skip the ones you mentioned giving you problems in this case. |
Names of some of the routes overlapped with others in an incompatible way. This makes the names more distinct
HTTP500 was never a good choice. Now it sends back an empty array
Thanks, will do. Can I just check; are there any tests for file interactions for existing functionality? I was looking to see how they handled generating/using temporary files, e.g. for testing file upload through the GUI, or image upload via GUI or API. But I can't find any reference to any such tests in the tests directory. I tried to sanity check myself on this, and running the following from the root of the snipe-it checkout, and ignoring any results relating solely to new files I've created, I get;
|
There is currently only really a test for listing, and only for the empty list response
Added the upload functionality to the get and delete tests, but I currently don't seem to be able to reference the correct file ID
Ok, tests for all features created. I believe all I'm missing now is updating the API documentation. Is someone able to point me to this? |
@Scarzy - Our documentation platform doesn't allow you to easily add docs to the API documentation, but if you let me know what you'd like added, I can do that for you. |
@snipe Basically just adding the following endpoints: /hardware/:id/files GET -> List uploaded files for asset As I believe I have now done all of my bits for this, I will change this PR to no longer be in draft. |
Description
Add support for uploading, listing, downloading, and deleting files on an asset via the API.
This is to enable automation with handling files on assets.
Fixes #9413
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
In all cases the web GUI, the JSON response, and the downloaded file were visually inspected to ensure they were as expected.
I have tested it successfully with the following file types;
I also tried with a binary file with random contents, and this didn't work. As far as I can tell the file disappeared somewhere inside laravel, and never made it to the controller. If interested, the random file was created via;
Test Configuration:
Checklist: