{"id":16552188,"url":"https://github.com/dreadwarrior/java-spring-boot-katas","last_synced_at":"2026-05-11T02:52:49.076Z","repository":{"id":141890865,"uuid":"514957011","full_name":"dreadwarrior/java-spring-boot-katas","owner":"dreadwarrior","description":"Playground for exercising common problems with Katas in Spring Boot","archived":false,"fork":false,"pushed_at":"2024-12-18T18:45:02.000Z","size":75,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T00:32:54.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dreadwarrior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-17T21:14:07.000Z","updated_at":"2024-12-18T18:45:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"c5933ea5-1712-4031-92ea-01dd6056296f","html_url":"https://github.com/dreadwarrior/java-spring-boot-katas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreadwarrior%2Fjava-spring-boot-katas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreadwarrior%2Fjava-spring-boot-katas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreadwarrior%2Fjava-spring-boot-katas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreadwarrior%2Fjava-spring-boot-katas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreadwarrior","download_url":"https://codeload.github.com/dreadwarrior/java-spring-boot-katas/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241885740,"owners_count":20036956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T19:44:10.188Z","updated_at":"2026-05-11T02:52:44.049Z","avatar_url":"https://github.com/dreadwarrior.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring Boot Katas\n\n## Requirements\n\n* JDK 17\n* Maven 3.8\n\n## Katas\n\n### Greetings\n\n- simple greetings resource for bootstrapping testing\n- demonstrates BDD-style testing\n\n### Multi-part File Uploads\n\n- practice emitting metrics about errors on incoming multi-part file uploads\n\n#### TODO\n\n- [ ] fix \"java.net.SocketException: Broken pipe (Write failed)\" (http/multipartfileuploads.http#multiple files exceeding max request size)\n- [ ] test / visualize metrics with Prometheus\n- [ ] refactor `UploadSizeExceptionAdvice#recordMetrics()`\n\n#### Development\n\n1. Start the `Application`\n2. Note down the generated security password from the log messaging starting \n   with `Using generated security password`\n3. Run the following command to create a IntelliJ HTTP client configuration\n\n   ```sh\n   cp -n src/test/http/http-client.env.json http-client.private.env.json`\n   ```\n\n4. Insert the generated security password of step 2. to the JSON property at \n   path `dev.password`\n5. Open the file `multipartfileuploads.http`, select the `dev` environment in\n   field **Run with**.\n6. Run the examples\n\nHot reloading the application (\u003ckbd\u003eCmd\u003c/kbd\u003e+\u003ckbd\u003eF9\u003c/kbd\u003e) during development\nis possible, as Spring Boot Devtools are available in the classpath. Steps 2. + 4. \nneed to be re-run in this case.\n\n#### Run tests\n\n1. Generate payload samples (generates 512KB, 1MB, 1.1MB files):\n\n    ```sh\n    dd if=/dev/urandom bs=524288 count=1 of=src/test/resources/multipartfileuploads/file512kb\n    dd if=/dev/urandom bs=1048576 count=1 of=src/test/resources/multipartfileuploads/file1mb\n    dd if=/dev/urandom bs=1153433 count=1 of=src/test/resources/multipartfileuploads/filegt1mb\n    ```\n\n2. Run the use-case test:\n\n    ```sh\n    mvn -Dtest=\"*.multipartfileuploads.**\" test\n    ```\n\n#### Knowledge resources\n\n- [How to use `RestTemplate` for multipart file uploads](https://github.com/eugenp/tutorials/blob/master/spring-web-modules/spring-resttemplate-3/src/main/java/com/baeldung/web/upload/client/MultipartFileUploadClient.java)\n- [How to use `ClassPathResource` in Spring JUnit tests](https://www.baeldung.com/spring-classpath-file-access)\n- [Data units conversion](https://www.gbmb.org/)\n- [Behavior-Driven Development mit JUnit 5 (german)](https://blog.codecentric.de/2018/09/behavior-driven-development-mit-junit-5/)\n- [Spring Security Auto Configuration](https://docs.spring.io/spring-security/reference/servlet/getting-started.html#servlet-hello-auto-configuration)\n- [How to disable CSRF for Spring Security](https://docs.spring.io/spring-security/reference/servlet/exploits/csrf.html#servlet-csrf-configure-disable)\n- [Multipart form requests with IntelliJ HTTP client](https://www.jetbrains.com/help/idea/exploring-http-syntax.html#use-multipart-form-data)\n\n#### Learnings\n\n##### Spring Security CSRF configuration defaults\n\nThe Spring documentation is very detailed about CSRF protection in conjunction \nwith [Multipart file uploads](https://docs.spring.io/spring-security/reference/features/exploits/csrf.html#csrf-considerations-multipart).\n\nIt also includes a section about [When to use CSRF protection](https://docs.spring.io/spring-security/reference/features/exploits/csrf.html#csrf-when)\nwhich may help to make a decision about enabling or disabling it.\n\nFor the purpose of the `multipartfileuploads` use case, the CSRF protection was\ndisabled.\n\n##### `spring.servlet.multipart.max-request-size` evaluation\n\nWhen configuring the total request size for multipart requests, it may not be \nobvious that the request becomes too large even if multiple files are uploaded \nwhose total size is equal to that setting.\n\nA multipart file upload consists of additional data (like `--boundary--` \nmarkers; HTTP headers for each part e.g. `Content-Type: application/octet-stream`)\nwhich raises the request content length, too.\n\n##### Consider `Apache Commons Fileupload`\n\nUsing `commons-fileupload:commons-fileupload` may provide [\"maximum portability \nacross Servlet containers\"](https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-multipart-resolver-commons).\n\nNote that both options – servlet built-in and commons-fileupload resolvers – \nmake use of temporary files, which may not be feasible in a microservice \narchitecture.\n\n#### How to...\n\n##### ...generate sample files with certain size\n\n    # replace \"1153433\" with desired size and adjust file name in `of` argument accordingly\n    dd if=/dev/urandom bs=1153433 count=1 of=filegt1mb\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreadwarrior%2Fjava-spring-boot-katas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreadwarrior%2Fjava-spring-boot-katas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreadwarrior%2Fjava-spring-boot-katas/lists"}