{"id":18329614,"url":"https://github.com/jupiter-tools/mvc-requester","last_synced_at":"2025-10-10T19:35:28.766Z","repository":{"id":54427074,"uuid":"168095879","full_name":"jupiter-tools/mvc-requester","owner":"jupiter-tools","description":"Wrapper over the MockMvc to write tests of REST API in Spring.","archived":false,"fork":false,"pushed_at":"2023-06-14T22:29:22.000Z","size":87,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-21T09:46:08.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jupiter-tools.com","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jupiter-tools.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-01-29T05:37:19.000Z","updated_at":"2023-05-18T07:21:30.000Z","dependencies_parsed_at":"2025-02-15T10:26:54.358Z","dependency_job_id":"67d6501e-152b-4836-8643-5f2706788fbf","html_url":"https://github.com/jupiter-tools/mvc-requester","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/jupiter-tools/mvc-requester","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fmvc-requester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fmvc-requester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fmvc-requester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fmvc-requester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jupiter-tools","download_url":"https://codeload.github.com/jupiter-tools/mvc-requester/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jupiter-tools%2Fmvc-requester/sbom","scorecard":{"id":543063,"data":{"date":"2025-08-11","repo":{"name":"github.com/jupiter-tools/mvc-requester","commit":"6e81b2c4fc72e406087132a1dbbed2e0f6a10973"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/10 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'","Warn: branch protection not enabled for branch 'spring-4'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 26 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"10 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-h46c-h94j-95f3","Warn: Project is vulnerable to: GHSA-wf8f-6423-gfxg","Warn: Project is vulnerable to: GHSA-288c-cq4h-88gq","Warn: Project is vulnerable to: GHSA-3x8x-79m2-3w2w","Warn: Project is vulnerable to: GHSA-57j2-w4cx-62h2","Warn: Project is vulnerable to: GHSA-jjjh-jjxp-wpff","Warn: Project is vulnerable to: GHSA-rgv9-q543-rqg4","Warn: Project is vulnerable to: GHSA-5mg8-w23w-74h3","Warn: Project is vulnerable to: GHSA-7g45-4rm6-3mm3","Warn: Project is vulnerable to: GHSA-j288-q9x7-2f5v"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T08:43:28.701Z","repository_id":54427074,"created_at":"2025-08-20T08:43:28.701Z","updated_at":"2025-08-20T08:43:28.701Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005030,"owners_count":26083827,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-11-05T19:18:04.483Z","updated_at":"2025-10-10T19:35:28.729Z","avatar_url":"https://github.com/jupiter-tools.png","language":"Java","readme":":toc: preamble\n\n# MvcRequester\n\nimage:https://travis-ci.com/jupiter-tools/mvc-requester.svg?branch=master[\"Build Status\", link=\"https://travis-ci.com/jupiter-tools/mvc-requester\"]\nimage:https://codecov.io/gh/jupiter-tools/mvc-requester/branch/master/graph/badge.svg[link =\"https://codecov.io/gh/jupiter-tools/mvc-requester\"]\n\n\nTools which wrap the MockMvc in a simple matcher of HTTP responses,\nto write your REST-API tests in a more easy way.\n\n## Getting started\n\nYou need to add a next dependency:\n\n[source, xml]\n----\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.jupiter-tools\u003c/groupId\u003e\n    \u003cartifactId\u003emvc-requester\u003c/artifactId\u003e\n    \u003cversion\u003e0.4\u003c/version\u003e\n\u003c/dependency\u003e\n----\n\nAnd now you can write MVC tests in a more simple way.\n\n\nLet's consider the next controller:\n\n[source, java]\n----\n@RestController\n@RequestMapping(\"/test\")\npublic class TestController {\n\n    @GetMapping(\"/object\")\n    public SimpleObject getObject() {\n        return new SimpleObject(\"test-name\", 1987);\n    }\n\n    @GetMapping(\"/custom-object\")\n    public SimpleObject getWithParams(@RequestParam(\"name\") String name,\n                                      @RequestParam(\"value\") int value) {\n        return new SimpleObject(name, value);\n    }\n\n    @GetMapping(\"/{id}/object\")\n    public SimpleObject getWithPathVariable(@PathVariable(\"id\") int id) {\n        return new SimpleObject(String.valueOf(id), id);\n    }\n}\n----\n\n## Simple GET request:\n\n[source, java]\n----\n@Test\nvoid testReturnAs() throws Exception {\n    // Act\n    SimpleObject result = MvcRequester.on(mockMvc)\n                                      .to(\"/test/object\")\n                                      .get()\n                                      .returnAs(SimpleObject.class); \u003c1\u003e\n    // Asserts\n    assertThat(result).isNotNull() \u003c2\u003e\n                      .extracting(SimpleObject::getName, SimpleObject::getValue)\n                      .containsOnly(\"test-name\", 1987);\n}\n----\n\u003c1\u003e return received response as a type safety object\n\u003c2\u003e asserting of the received object with a type safety\n\n## Make a GET request with parameters:\n\n[source, java]\n----\n@Test\nvoid getWithParams() throws Exception {\n    // Act\n    SimpleObject result = MvcRequester.on(mockMvc)\n                                      .to(\"/test/custom-object\")\n                                      .withParam(\"name\", \"custom\")\n                                      .withParam(\"value\", 10101)\n                                      .get()\n                                      .returnAs(SimpleObject.class);\n    // Asserts\n    assertThat(result).isNotNull()\n                      .extracting(SimpleObject::getName, SimpleObject::getValue)\n                      .containsOnly(\"custom\", 10101);\n}\n----\n\n\n## Using path variables\n\n[source, java]\n----\nMvcRequester.on(mockMvc)\n            .to(\"/users/{name}/acls\", \"admin\") \u003c1\u003e\n            .get()\n            .returnAs(AclDto.class);\n----\n\u003c1\u003e String `admin` will be put instead of `{name}` variable in the url, before send request.\n\n## Checking returned status\n\n[source, java]\n----\n@Test\nvoid testCreateObject() throws Exception {\n    MvcRequester.on(mockMvc)\n                .to(\"/objects/create\")\n                .post()\n                .expectStatus(HttpStatus.CREATED); \u003c1\u003e\n}\n----\n\u003c1\u003e Check the HTTP status of the response\n\n## Send POST request with the body\n\nLet's consider the next controller:\n\n[source, java]\n----\n@RestController\n@RequestMapping(\"/test\")\npublic class TestController {\n\n    @PostMapping(\"/object-body\")\n    public SimpleObject postWithBody(@RequestBody SimpleObject body) {\n        return new SimpleObject(body.getName() + \"-test\",\n                                body.getValue() + 1000);\n    }\n}\n----\n\n[source, java]\n----\nSimpleObject postBody = new SimpleObject(\"body\", 987); \u003c1\u003e\n\nSimpleObject result = MvcRequester.on(mockMvc)\n                                  .to(\"/test/object-body\")\n                                  .post(postBody) \u003c2\u003e\n                                  .returnAs(SimpleObject.class);\n----\n\u003c1\u003e create an object which will send in the body\n\u003c2\u003e send a POST request with converting the body to JSON\n\n## Expected Parametrized Type\n\nFor example, we consider an API which return the list of entities:\n\n[source, java]\n----\n@RestController\n@RequestMapping(\"/objects\")\npublic class TestController {\n\n    @GetMapping(\"/list\")\n    public List\u003cSimpleObject\u003e getObject() {\n        SimpleObject a = new SimpleObject(\"AAA\", 1);\n        SimpleObject b = new SimpleObject(\"BBB\", 1);\n        SimpleObject c = new SimpleObject(\"CCC\", 1);\n        return Arrays.asList(a, b, c);\n    }\n}\n----\n\nand we can test it like that:\n\n[source, java]\n----\n@Test\nvoid parametrizedType() throws Exception {\n    // Act\n    List\u003cSimpleObject\u003e objectList = MvcRequester.on(mockMvc)\n                                                .to(\"/objects/list\")\n                                                .get()\n                                                .doReturn(new TypeReference\u003cList\u003cSimpleObject\u003e\u003e() {});\n    // Asserts\n    assertThat(objectList).isNotNull()\n                          .hasSize(3)\n                          .extracting(SimpleObject::getName)\n                          .containsOnly(\"AAA\", \"BBB\", \"CCC\");\n}\n----\n\n## Use custom headers in request\n\n[source,java]\n----\nMvcRequester.on(mockMvc)\n            .to(\"test/headers/check\")\n            .withHeader(\"custom-header\", \"12345\")\n            .get();\n----\n\n## Upload the MultipartFile\n\n[source, java]\n----\nbyte[] data = \"file content\".getBytes();\n\nMvcRequester.on(mockMvc)\n            .to(\"/test/create\")\n            .withFile(\"data\",\n                      \"filename.txt\",\n                      MimeType.valueOf(\"text/plain\"),\n                      data)\n            .upload();\n----\n\n## Authorization\n\n### OAuth\n\n[source, java]\n----\nMvcRequester.on(mockMvc)\n            .to(\"/test/oauth\")\n            .withOAuth(TOKEN)\n            .get();\n----\n\nwill send a request with the next header:\n\n`Authorization: Bearer {TOKEN}`\n\n### Basic Authorization\n\n[source, java]\n----\nString result = MvcRequester.on(mockMvc)\n                           .to(\"/test/basic\")\n                           .withBasicAuth(\"root\", \"12345\")\n                           .post()\n----\n\nwill send a request with the next header:\n\n`Authorization: Basic {base64}`\n\n## Response charset\n\nTo get a response in the specific charset you can use `MvcRequestResult.charset` method,\nfor example when we expect a response in `cp1251`:\n\n[source, java]\n----\nString response = MvcRequester.on(mockMvc)\n                              .to(\"/api/endpoint\")\n                              .get()\n                              .charset(Charset.forName(\"cp1251\"))\n                              .returnAsPrimitive(String.class);\n----\n\nBy default MvcRequester uses the `UTF-8` charset.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiter-tools%2Fmvc-requester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjupiter-tools%2Fmvc-requester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjupiter-tools%2Fmvc-requester/lists"}