adutra commented on code in PR #590:
URL: https://github.com/apache/polaris/pull/590#discussion_r1907367844
##########
integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisApplicationIntegrationTest.java:
##########
@@ -715,36 +622,22 @@ public void testRequestBodyTooLarge() {
// The size is set to be higher than the limit in
polaris-server-integrationtest.yml
Entity<PrincipalRole> largeRequest = Entity.json(new
PrincipalRole("r".repeat(1000001)));
- try (Response response =
- EXT.client()
- .target(
- String.format(
- "http://localhost:%d/api/management/v1/principal-roles",
EXT.getLocalPort()))
- .request("application/json")
- .header("Authorization", "Bearer " + userToken)
- .header(REALM_PROPERTY_KEY, realm)
- .post(largeRequest)) {
+ try (Response response =
managementApi.request("v1/principal-roles").post(largeRequest)) {
assertThat(response)
.returns(Response.Status.BAD_REQUEST.getStatusCode(),
Response::getStatus)
- .matches(
- r ->
- r.readEntity(RequestThrottlingErrorResponse.class)
- .errorType()
- .equals(REQUEST_TOO_LARGE));
+ .extracting(r -> r.readEntity(Map.class))
+ .extracting("error_type")
+ .isEqualTo("REQUEST_TOO_LARGE");
}
}
@Test
public void testRefreshToken() throws IOException {
- String path =
- String.format("http://localhost:%d/api/catalog/v1/oauth/tokens",
EXT.getLocalPort());
+ String path =
endpoints.catalogApiEndpoint().resolve("v1/oauth/tokens").toString();
try (RESTClient client =
- HTTPClient.builder(ImmutableMap.of())
- .withHeader(REALM_PROPERTY_KEY, realm)
- .uri(path)
- .build()) {
+ HTTPClient.builder(Map.of()).withHeader(REALM_HEADER,
realm).uri(path).build()) {
String credentialString =
- snowmanCredentials.clientId() + ":" +
snowmanCredentials.clientSecret();
+ clientCredentials.clientId() + ":" +
clientCredentials.clientSecret();
var authConfig =
AuthConfig.builder().credential(credentialString).scope("PRINCIPAL_ROLE:ALL").build();
ImmutableAuthConfig configSpy = spy(authConfig);
Review Comment:
Oddly, this is failing on my machine:
```
org.mockito.exceptions.base.MockitoException:
Cannot mock/spy class org.apache.iceberg.rest.auth.ImmutableAuthConfig
Mockito cannot mock/spy because :
- final class
```
##########
integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisApplicationIntegrationTest.java:
##########
@@ -715,36 +622,22 @@ public void testRequestBodyTooLarge() {
// The size is set to be higher than the limit in
polaris-server-integrationtest.yml
Entity<PrincipalRole> largeRequest = Entity.json(new
PrincipalRole("r".repeat(1000001)));
- try (Response response =
- EXT.client()
- .target(
- String.format(
- "http://localhost:%d/api/management/v1/principal-roles",
EXT.getLocalPort()))
- .request("application/json")
- .header("Authorization", "Bearer " + userToken)
- .header(REALM_PROPERTY_KEY, realm)
- .post(largeRequest)) {
+ try (Response response =
managementApi.request("v1/principal-roles").post(largeRequest)) {
Review Comment:
2 remarks:
- The appropriate response status should be `REQUEST_ENTITY_TOO_LARGE`
(413). That's what Quarkus expects.
- Similar to the `testRequestHeaderTooLarge` test, this test should be
resilient to closed sockets. Here is the Quarkus version from #469:
```java
@Test
public void testRequestBodyTooLarge() {
Entity<PrincipalRole> largeRequest =
Entity.json(new PrincipalRole("r".repeat((int) (maxBodySize + 1))));
try (Client client = ClientBuilder.newClient()) {
try (Response response =
client
.target(String.format("%s/api/management/v1/principal-roles",
testEnv.baseUri()))
.request("application/json")
.header("Authorization", "Bearer " + fixture.adminToken)
.header(REALM_PROPERTY_KEY, fixture.realm)
.post(largeRequest)) {
assertThat(response)
.returns(Response.Status.REQUEST_ENTITY_TOO_LARGE.getStatusCode(),
Response::getStatus);
} catch (ProcessingException e) {
// In some runtime environments the request above will return a 431
but in others it'll
// result
// in a ProcessingException from the socket being closed. The test
asserts that one of those
// things happens.
assertThat(e).hasMessageContaining("Connection was closed");
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]