Add pre and post import validation to gists import
What does this MR do and why?
Adds post-import and pre-import validations to check if files count and repos size was exceeded.
Corresponding issue: Fail gist import if git repository too big (#384860 - closed)
Screenshots or screen recordings
To check repo size post-import validation I substitute git_pull_url with a git repo that exceeds max size limit. (This repo needs to have not more than 10 files, otherwise, the files count validation will fail import even before repo size validation)
How to set up and validate locally
For the testing purpose I changed application settings to have a lower max snippet size using Change application settings for snippet_size_limit
For pre-import validations:
- On GitHub.com create gists with more than 10 files and gist with a size bigger than your
snippet_size_limit
value. - Initiate gists import via {{host}}/api/v4/import/github/gists (Import GitHub gists into GitLab snippets)
- After the import is finished check
http://gdk.test:3000/rails/letter_opener/
it should have an email with the list of gists that were not imported with an error message or/andimporter.log
it should have error messages of not imported gists.
For post-import validations:
- For testing purposes I commented
validate_input!
method execution inlib/gitlab/github_gists_import/importer/gist_importer.rb
to skip pre-import validations. - On GitHub.com create gists with more than 10 files and gist with a size bigger than your
snippet_size_limit
value. - Initiate gists import via {{host}}/api/v4/import/github/gists (Import GitHub gists into GitLab snippets)
- After the import is finished check
http://gdk.test:3000/rails/letter_opener/
it should have an email with the list of gists that were not imported with an error message or/andimporter.log
is should have error messages of not imported gists.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.