Skip to content

Commit 0f194a1

Browse files
formatting
1 parent c4133f3 commit 0f194a1

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisManagementServiceIntegrationTest.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -876,22 +876,23 @@ public void testCreatePrincipalAndRotateCredentials() {
876876
@Test
877877
public void testCreatePrincipalAndResetCredentialsWithCustomValues() {
878878
// Create a new principal using root user
879-
Principal principal = Principal.builder()
879+
Principal principal =
880+
Principal.builder()
880881
.setName(client.newEntityName("myprincipal-reset"))
881882
.setProperties(Map.of("custom-tag", "bar"))
882883
.build();
883884

884-
PrincipalWithCredentials creds = managementApi.createPrincipal(
885-
new CreatePrincipalRequest(principal, true)
886-
);
885+
PrincipalWithCredentials creds =
886+
managementApi.createPrincipal(new CreatePrincipalRequest(principal, true));
887887

888-
Map<String, String> customBody = Map.of(
888+
Map<String, String> customBody =
889+
Map.of(
889890
"clientId", "f174b76a7e1a99e2",
890-
"clientSecret", "27029d236abc08e204922b0a07031bc2"
891-
);
891+
"clientSecret", "27029d236abc08e204922b0a07031bc2");
892892

893893
PrincipalWithCredentials resetCreds;
894-
try (Response response = managementApi
894+
try (Response response =
895+
managementApi
895896
.request("v1/principals/{p}/reset", Map.of("p", principal.getName()))
896897
.post(Entity.json(customBody))) {
897898

@@ -900,24 +901,25 @@ public void testCreatePrincipalAndResetCredentialsWithCustomValues() {
900901
}
901902

902903
assertThat(resetCreds.getCredentials().getClientId()).isEqualTo("f174b76a7e1a99e2");
903-
assertThat(resetCreds.getCredentials().getClientSecret()).isEqualTo("27029d236abc08e204922b0a07031bc2");
904+
assertThat(resetCreds.getCredentials().getClientSecret())
905+
.isEqualTo("27029d236abc08e204922b0a07031bc2");
904906

905907
// Principal itself tries to reset with custom creds → should fail (403 Forbidden)
906908
String principalToken = client.obtainToken(resetCreds);
907-
customBody = Map.of(
909+
customBody =
910+
Map.of(
908911
"clientId", "f174b76a7e1a99e3",
909-
"clientSecret", "27029d236abc08e204922b0a07031bc3"
910-
);
911-
try (Response response = client.managementApi(principalToken)
912+
"clientSecret", "27029d236abc08e204922b0a07031bc3");
913+
try (Response response =
914+
client
915+
.managementApi(principalToken)
912916
.request("v1/principals/{p}/reset", Map.of("p", principal.getName()))
913917
.post(Entity.json(customBody))) {
914918

915919
assertThat(response).returns(Response.Status.FORBIDDEN.getStatusCode(), Response::getStatus);
916920
}
917921
}
918922

919-
920-
921923
@Test
922924
public void testCreateFederatedPrincipalRoleSucceeds() {
923925
// Create a federated Principal Role

polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisAuthorizerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,11 @@ public void authorizeOrThrow(
606606
@Override
607607
public void authorizeOrThrow(@Nonnull AuthenticatedPolarisPrincipal authenticatedPrincipal) {
608608
boolean isRoot =
609-
getRootPrincipalName().equals(authenticatedPrincipal.getPrincipalEntity().getName());
609+
getRootPrincipalName().equals(authenticatedPrincipal.getPrincipalEntity().getName());
610610
if (!isRoot) {
611-
throw new ForbiddenException("Only %s principal can reset credentials", authenticatedPrincipal.getPrincipalEntity().getName());
611+
throw new ForbiddenException(
612+
"Only %s principal can reset credentials",
613+
authenticatedPrincipal.getPrincipalEntity().getName());
612614
}
613615
}
614616

runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020

2121
import static com.google.common.base.Preconditions.checkArgument;
2222
import static com.google.common.base.Preconditions.checkState;
23-
import static org.apache.polaris.core.entity.PolarisEntityConstants.getRootPrincipalName;
2423

2524
import jakarta.annotation.Nonnull;
2625
import jakarta.annotation.Nullable;
2726
import jakarta.validation.constraints.NotNull;
28-
import jakarta.ws.rs.ForbiddenException;
2927
import jakarta.ws.rs.core.SecurityContext;
3028
import java.util.ArrayList;
3129
import java.util.Arrays;

0 commit comments

Comments
 (0)