🚧 Return 501 on Snapshot upload
This commit is contained in:
parent
15b9be7cc8
commit
63c3de81ad
@ -5,29 +5,24 @@ import io.quarkus.arc.profile.IfBuildProfile;
|
||||
import io.quarkus.runtime.Startup;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.POST;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
@ApplicationScoped
|
||||
@IfBuildProfile("x")
|
||||
@jakarta.ws.rs.Path("/dev")
|
||||
@IfBuildProfile("dev")
|
||||
public class Dev
|
||||
{
|
||||
@Inject
|
||||
Service service;
|
||||
|
||||
@Startup
|
||||
void init() throws IOException
|
||||
@GET
|
||||
public void init() throws IOException
|
||||
{
|
||||
service.upload("/org/apache/httpcomponents/client5/httpclient5/5.6/httpclient5-5.6.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/httpclient5-5.6.jar"))).close();
|
||||
|
||||
service.upload("/com/fasterxml/jackson/core/jackson-core/2.21.0/jackson-core-2.21.0.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/jackson-core-2.21.0.jar"))).close();
|
||||
|
||||
service.upload("/org/postgresql/postgresql/42.7.9/postgresql-42.7.9.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/postgresql-42.7.9.jar"))).close();
|
||||
service.upload("/org/postgresql/postgresql/42.2.9/postgresql-42.2.9.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/postgresql-42.7.9.jar"))).close();
|
||||
service.upload("/org/postgresql/postgresql/42.4.9/postgresql-42.4.9.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/postgresql-42.7.9.jar"))).close();
|
||||
service.upload("/org/postgresql/postgresql/41.4.9/postgresql-41.4.9.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/postgresql-42.7.9.jar"))).close();
|
||||
service.upload("/org/postgresql/postgresql/41.4.9/postgresql-41.4.9.pom", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/core/src/main/resources/jar/postgresql-42.7.9.pom"))).close();
|
||||
service.upload("/org/postgresql/postgresql/41.4.9/postgresql-41.4.9.jar", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/src/main/resources/jar/postgresql-42.7.9.jar"))).close();
|
||||
service.upload("/org/postgresql/postgresql/41.4.9/postgresql-41.4.9.pom", Files.readAllBytes(Path.of("/home/andreas/Documents/dev/maven/core/src/main/resources/jar/postgresql-42.7.9.pom"))).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,7 @@ import dev.dinauer.maven.jpa.maven.GroupId;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -19,4 +20,11 @@ public class GroupResource
|
||||
{
|
||||
return groupRepo.listAll();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{group-id}")
|
||||
public GroupId get(@PathParam("group-id") String groupId)
|
||||
{
|
||||
return groupRepo.findById(groupId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@ import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.transaction.Transactional;
|
||||
import jakarta.ws.rs.NotFoundException;
|
||||
import jakarta.ws.rs.WebApplicationException;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jdk.jshell.spi.ExecutionControl;
|
||||
@ -43,6 +44,10 @@ public class Service
|
||||
public Response upload(String path, byte[] body)
|
||||
{
|
||||
MavenContext mavenContext = MavenContextProvider.parse(path);
|
||||
if (mavenContext.version().getSnapshot())
|
||||
{
|
||||
throw new WebApplicationException(501);
|
||||
}
|
||||
switch (mavenContext.file().getType())
|
||||
{
|
||||
case JAR ->
|
||||
|
||||
@ -47,6 +47,14 @@ public class ResourceTest
|
||||
Assertions.assertEquals("a6b97b8d22c55f296040344dd75641b2", responsePomMd5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestSecurity(user = "user")
|
||||
void test_snapshot()
|
||||
{
|
||||
RestAssured.given().body(readFile("/jar/postgresql-42.7.9.jar")).put("/maven2/org/postgresql/postgresql/42.7.9-SNAPSHOT/postgresql-42.7.9.jar").then().statusCode(501);
|
||||
RestAssured.given().body(readFile("/jar/postgresql-42.7.9.pom")).put("/maven2/org/postgresql/postgresql/42.7.9-SNAPSHOT/postgresql-42.7.9.pom").then().statusCode(501);
|
||||
}
|
||||
|
||||
private InputStream readFile(String path)
|
||||
{
|
||||
return getClass().getResourceAsStream(path);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user