@ExtendWith(RepositoryManagementTestExecutionListener.class) @Test public void testGetMetadata(@NugetRepository(storageId = STORAGE_ID, repositoryId = REPOSITORY_RELEASES_1) Repository repository) { final String storageId = repository.getStorage().getId(); final String repositoryId = repository.getId(); String url = getContextBaseUrl() + "/storages/{storageId}/{repositoryId}/$metadata;client=127.0.0.1"; mockMvc.header(HttpHeaders.USER_AGENT, "NuGet/*") .when() .get(url, storageId, repositoryId) .then() .statusCode(HttpStatus.OK.value()); }
@ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) public ResponseEntity<Resource> getMetadata() { InputStream inputStream = NugetArtifactController.class.getResourceAsStream("/metadata.xml"); return new ResponseEntity<>(new InputStreamResource(inputStream), HttpStatus.OK); }
NugetArtifactController extends BaseArtifactController { @ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) public ResponseEntity<Resource> getMetadata() { InputStream inputStream = NugetArtifactController.class.getResourceAsStream("/metadata.xml"); return new ResponseEntity<>(new InputStreamResource(inputStream), HttpStatus.OK); } }
NugetArtifactController extends BaseArtifactController { @ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) public ResponseEntity<Resource> getMetadata() { InputStream inputStream = NugetArtifactController.class.getResourceAsStream("/metadata.xml"); return new ResponseEntity<>(new InputStreamResource(inputStream), HttpStatus.OK); }  }
NugetArtifactController extends BaseArtifactController { @ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) public ResponseEntity<Resource> getMetadata() { InputStream inputStream = NugetArtifactController.class.getResourceAsStream("/metadata.xml"); return new ResponseEntity<>(new InputStreamResource(inputStream), HttpStatus.OK); }  @DeleteMapping(path = { "{storageId}/{repositoryId}/{packageId}/{version}" }) @PreAuthorize("hasAuthority('ARTIFACTS_DEPLOY')") ResponseEntity deletePackage(@RequestHeader(name = "X-NuGet-ApiKey", required = false) String apiKey,
                                        @RepositoryMapping Repository repository,
                                        @PathVariable("packageId") String packageId,
                                        @PathVariable("version") String version); @GetMapping(path = { "{storageId}/{repositoryId}/Search()/$count" }, produces = MediaType.TEXT_PLAIN) ResponseEntity<String> countPackages(@RepositoryMapping Repository repository,
                                                @RequestParam(name = "$filter", required = false) String filter,
                                                @RequestParam(name = "searchTerm", required = false) String searchTerm,
                                                @RequestParam(name = "targetFramework", required = false) String targetFramework); @GetMapping(path = { "{storageId}/{repositoryId}/{searchCommandName:(?:Packages(?:\\(\\))?|Search\\(\\))}" }, produces = MediaType.APPLICATION_XML) ResponseEntity<?> searchPackages(@RepositoryMapping Repository repository,
                                            @PathVariable(name = "searchCommandName") String searchCommandName,
                                            @RequestParam(name = "$filter", required = false) String filter,
                                            @RequestParam(name = "$orderby", required = false, defaultValue = "Id") String orderBy,
                                            @RequestParam(name = "$skip", required = false) Integer skip,
                                            @RequestParam(name = "$top", required = false) Integer top,
                                            @RequestParam(name = "searchTerm", required = false) String searchTerm,
                                            @RequestParam(name = "targetFramework", required = false) String targetFramework,
                                            HttpServletResponse response); @GetMapping(path = { "{storageId}/{repositoryId}/FindPackagesById()" }, produces = MediaType.APPLICATION_XML) ResponseEntity<?> searchPackageById(@RepositoryMapping Repository repository,
                                               @RequestParam(name = "id", required = true) String packageId,
                                               HttpServletResponse response); Collection<? extends Nupkg> getPackages(Repository repository,
                                                   String filter,
                                                   String orderBy,
                                                   String searchTerm,
                                                   String targetFramework,
                                                   Integer skip,
                                                   Integer top); @ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) ResponseEntity<Resource> getMetadata(); @ApiOperation(value = "Used to check storage availability") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Storage available."), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Storage requires authorization.") }) @GetMapping(path = { "{storageId}/{repositoryId}", "checkRepositoryAccess" }) @PreAuthorize("hasAuthority('ARTIFACTS_RESOLVE')") ResponseEntity<String> checkRepositoryAccess(); @ApiOperation(value = "Used to deploy a package") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The package was deployed successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @PreAuthorize("hasAuthority('ARTIFACTS_DEPLOY')") @RequestMapping(path = "{storageId}/{repositoryId}/", method = RequestMethod.PUT, consumes = MediaType.MULTIPART_FORM_DATA) ResponseEntity putPackage(@RequestHeader(name = "X-NuGet-ApiKey", required = false) String apiKey,
                                     @RepositoryMapping Repository repository,
                                     @RequestParam(value = "package") MultipartFile file,
                                     HttpServletRequest request); @ApiOperation(value = "Used to download a package") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The request was successfull."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Server error occurred."), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested path was not found."), @ApiResponse(code = HttpURLConnection.HTTP_UNAVAILABLE, message = "Repository not in service currently.")}) @PreAuthorize("hasAuthority('ARTIFACTS_RESOLVE')") @RequestMapping(path = "{storageId}/{repositoryId}/{commandName:(?:download|package)}/{packageId}/{packageVersion}", method = {RequestMethod.GET, RequestMethod.HEAD}, produces = MediaType.APPLICATION_OCTET_STREAM) void downloadPackage(@RepositoryMapping Repository repository,
                                @ApiParam(value = "The packageId", required = true) @PathVariable(name = "packageId") String packageId,
                                @ApiParam(value = "The packageVersion", required = true) @PathVariable(name = "packageVersion") String packageVersion,
                                HttpServletResponse response,
                                HttpServletRequest request,
                                @RequestHeader HttpHeaders httpHeaders); @ApiOperation(value = "Used to download a package") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The request was successfull."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Server error occurred."), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested path was not found."), @ApiResponse(code = HttpURLConnection.HTTP_UNAVAILABLE, message = "Repository not in service currently.")}) @PreAuthorize("hasAuthority('ARTIFACTS_RESOLVE')") @RequestMapping(path = "{storageId}/{repositoryId}/{packageId}/{packageVersion}", method = {RequestMethod.GET, RequestMethod.HEAD}, produces = MediaType.APPLICATION_OCTET_STREAM) void getPackage(@RepositoryMapping Repository repository,
                           @ApiParam(value = "The packageId", required = true) @PathVariable(name = "packageId") String packageId,
                           @ApiParam(value = "The packageVersion", required = true) @PathVariable(name = "packageVersion") String packageVersion,
                           HttpServletResponse response,
                           HttpServletRequest request, 
                           @RequestHeader HttpHeaders httpHeaders); }
NugetArtifactController extends BaseArtifactController { @ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) public ResponseEntity<Resource> getMetadata() { InputStream inputStream = NugetArtifactController.class.getResourceAsStream("/metadata.xml"); return new ResponseEntity<>(new InputStreamResource(inputStream), HttpStatus.OK); }  @DeleteMapping(path = { "{storageId}/{repositoryId}/{packageId}/{version}" }) @PreAuthorize("hasAuthority('ARTIFACTS_DEPLOY')") ResponseEntity deletePackage(@RequestHeader(name = "X-NuGet-ApiKey", required = false) String apiKey,
                                        @RepositoryMapping Repository repository,
                                        @PathVariable("packageId") String packageId,
                                        @PathVariable("version") String version); @GetMapping(path = { "{storageId}/{repositoryId}/Search()/$count" }, produces = MediaType.TEXT_PLAIN) ResponseEntity<String> countPackages(@RepositoryMapping Repository repository,
                                                @RequestParam(name = "$filter", required = false) String filter,
                                                @RequestParam(name = "searchTerm", required = false) String searchTerm,
                                                @RequestParam(name = "targetFramework", required = false) String targetFramework); @GetMapping(path = { "{storageId}/{repositoryId}/{searchCommandName:(?:Packages(?:\\(\\))?|Search\\(\\))}" }, produces = MediaType.APPLICATION_XML) ResponseEntity<?> searchPackages(@RepositoryMapping Repository repository,
                                            @PathVariable(name = "searchCommandName") String searchCommandName,
                                            @RequestParam(name = "$filter", required = false) String filter,
                                            @RequestParam(name = "$orderby", required = false, defaultValue = "Id") String orderBy,
                                            @RequestParam(name = "$skip", required = false) Integer skip,
                                            @RequestParam(name = "$top", required = false) Integer top,
                                            @RequestParam(name = "searchTerm", required = false) String searchTerm,
                                            @RequestParam(name = "targetFramework", required = false) String targetFramework,
                                            HttpServletResponse response); @GetMapping(path = { "{storageId}/{repositoryId}/FindPackagesById()" }, produces = MediaType.APPLICATION_XML) ResponseEntity<?> searchPackageById(@RepositoryMapping Repository repository,
                                               @RequestParam(name = "id", required = true) String packageId,
                                               HttpServletResponse response); Collection<? extends Nupkg> getPackages(Repository repository,
                                                   String filter,
                                                   String orderBy,
                                                   String searchTerm,
                                                   String targetFramework,
                                                   Integer skip,
                                                   Integer top); @ApiOperation(value = "Used to get storage metadata") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The metadata was downloaded successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @GetMapping(path = { "{storageId}/{repositoryId}/$metadata" }, produces = MediaType.APPLICATION_XML) ResponseEntity<Resource> getMetadata(); @ApiOperation(value = "Used to check storage availability") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "Storage available."), @ApiResponse(code = HttpURLConnection.HTTP_UNAUTHORIZED, message = "Storage requires authorization.") }) @GetMapping(path = { "{storageId}/{repositoryId}", "checkRepositoryAccess" }) @PreAuthorize("hasAuthority('ARTIFACTS_RESOLVE')") ResponseEntity<String> checkRepositoryAccess(); @ApiOperation(value = "Used to deploy a package") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The package was deployed successfully."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "An error occurred.") }) @PreAuthorize("hasAuthority('ARTIFACTS_DEPLOY')") @RequestMapping(path = "{storageId}/{repositoryId}/", method = RequestMethod.PUT, consumes = MediaType.MULTIPART_FORM_DATA) ResponseEntity putPackage(@RequestHeader(name = "X-NuGet-ApiKey", required = false) String apiKey,
                                     @RepositoryMapping Repository repository,
                                     @RequestParam(value = "package") MultipartFile file,
                                     HttpServletRequest request); @ApiOperation(value = "Used to download a package") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The request was successfull."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Server error occurred."), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested path was not found."), @ApiResponse(code = HttpURLConnection.HTTP_UNAVAILABLE, message = "Repository not in service currently.")}) @PreAuthorize("hasAuthority('ARTIFACTS_RESOLVE')") @RequestMapping(path = "{storageId}/{repositoryId}/{commandName:(?:download|package)}/{packageId}/{packageVersion}", method = {RequestMethod.GET, RequestMethod.HEAD}, produces = MediaType.APPLICATION_OCTET_STREAM) void downloadPackage(@RepositoryMapping Repository repository,
                                @ApiParam(value = "The packageId", required = true) @PathVariable(name = "packageId") String packageId,
                                @ApiParam(value = "The packageVersion", required = true) @PathVariable(name = "packageVersion") String packageVersion,
                                HttpServletResponse response,
                                HttpServletRequest request,
                                @RequestHeader HttpHeaders httpHeaders); @ApiOperation(value = "Used to download a package") @ApiResponses(value = { @ApiResponse(code = HttpURLConnection.HTTP_OK, message = "The request was successfull."), @ApiResponse(code = HttpURLConnection.HTTP_INTERNAL_ERROR, message = "Server error occurred."), @ApiResponse(code = HttpURLConnection.HTTP_NOT_FOUND, message = "The requested path was not found."), @ApiResponse(code = HttpURLConnection.HTTP_UNAVAILABLE, message = "Repository not in service currently.")}) @PreAuthorize("hasAuthority('ARTIFACTS_RESOLVE')") @RequestMapping(path = "{storageId}/{repositoryId}/{packageId}/{packageVersion}", method = {RequestMethod.GET, RequestMethod.HEAD}, produces = MediaType.APPLICATION_OCTET_STREAM) void getPackage(@RepositoryMapping Repository repository,
                           @ApiParam(value = "The packageId", required = true) @PathVariable(name = "packageId") String packageId,
                           @ApiParam(value = "The packageVersion", required = true) @PathVariable(name = "packageVersion") String packageVersion,
                           HttpServletResponse response,
                           HttpServletRequest request, 
                           @RequestHeader HttpHeaders httpHeaders);  }