Search test added
@@ -131,4 +131,54 @@ public class NugetPackageControllerTest extends RestAssuredBaseTest
.header("Content-Length", equalTo(String.valueOf(packageFileSize)));
}
+ @Test
+ public void testPackageSearch()
+ throws Exception
+ {
+ String basedir = PropertyUtils.getHomeDirectory() + "/tmp";
+
+ String packageId = "Org.Carlspring.Strongbox.Nuget.Test.Search";
+ String packageVersion = "1.0.0";
+ String packageFileName = packageId + "." + packageVersion + ".nupkg";
+
+ NugetPackageGenerator nugetPackageGenerator = new NugetPackageGenerator(basedir);
+ nugetPackageGenerator.generateNugetPackage(packageId, packageVersion);
+
+ Path packageFilePath = Paths.get(basedir).resolve(packageVersion).resolve(packageFileName);
+
+ ByteArrayOutputStream contentStream = new ByteArrayOutputStream();
+
+ MultipartEntityBuilder.create()
+ .addBinaryBody("package",
+ Files.newInputStream(packageFilePath))
+ .setBoundary("---------------------------123qwe")
+ .build()
+ .writeTo(contentStream);
+ contentStream.flush();
+
+ //Push
+ given().header("User-Agent", "NuGet/*")
+ .header("X-NuGet-ApiKey",
+ "eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJTdHJvbmdib3giLCJqdGkiOiJ0SExSbWU4eFJOSnJjNXVXdTVkZDhRIiwic3ViIjoiYWRtaW4iLCJzZWN1cml0eS10b2tlbi1rZXkiOiJhZG1pbi1zZWNyZXQifQ.xRWxXt5yob5qcHjsvV1YsyfY3C-XFt9oKPABY0tYx88")
+ .header("Content-Type", "multipart/form-data; boundary=---------------------------123qwe")
+ .body(contentStream.toByteArray())
+ .when()
+ .put(getContextBaseUrl() + "/storages/" + STORAGE_ID + "/" + REPOSITORY_RELEASES_1 + "/")
+ .peek()
+ .then()
+ .statusCode(HttpStatus.CREATED.value());
+
+ //Search
+ given().header("User-Agent", "NuGet/*")
+ .when()
+ .get(getContextBaseUrl() + "/storages/" + STORAGE_ID + "/" + REPOSITORY_RELEASES_1
+ + String.format("/Search()?$filter=%s&$skip=%s&$top=%s&searchTerm=%s&targetFramework=",
+ "IsLatestVersion", 0, 30, "Test"))
+ .then()
+ .statusCode(HttpStatus.OK.value())
+ .and()
+ .assertThat()
+ .body("feed.title", equalTo("Packages"));
+
+ }
}
