-
Notifications
You must be signed in to change notification settings - Fork 332
Introduce reserved-properties setting; reserve "polaris." by default #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5688cfc
682ad76
eea7ad7
2c3701f
3d5c230
c8640aa
34bd577
34c517d
67b54f2
d7d22bf
496afeb
b3aa47b
a0458b1
74d7d73
c0717fb
0012ec5
bab7c77
b6c1bdb
e8ecd3a
40eac62
b128e95
b20edd1
eceb796
2030eb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -84,6 +84,7 @@ | |
| import org.junit.jupiter.api.BeforeAll; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import org.testcontainers.shaded.com.google.common.collect.ImmutableMap; | ||
| import org.testcontainers.shaded.org.awaitility.Awaitility; | ||
|
|
||
| /** | ||
|
|
@@ -2102,6 +2103,129 @@ public void testDropNamespaceStatus() { | |
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testCreateAndUpdateCatalogRoleWithReservedProperties() { | ||
| String catalogName = client.newEntityName("mycatalog1"); | ||
| Catalog catalog = | ||
| PolarisCatalog.builder() | ||
| .setType(Catalog.TypeEnum.INTERNAL) | ||
| .setName(catalogName) | ||
| .setProperties(new CatalogProperties("s3://required/base/location")) | ||
| .setStorageConfigInfo( | ||
| new AwsStorageConfigInfo( | ||
| "arn:aws:iam::012345678901:role/jdoe", StorageConfigInfo.StorageTypeEnum.S3)) | ||
| .build(); | ||
| managementApi.createCatalog(catalog); | ||
|
|
||
| CatalogRole badCatalogRole = | ||
| new CatalogRole("mycatalogrole", Map.of("polaris.reserved", "foo"), 0L, 0L, 1); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/catalogs/{cat}/catalog-roles", Map.of("cat", catalogName)) | ||
| .post(Entity.json(new CreateCatalogRoleRequest(badCatalogRole)))) { | ||
| assertThat(response) | ||
| .returns(Response.Status.BAD_REQUEST.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| CatalogRole okCatalogRole = new CatalogRole("mycatalogrole", Map.of("foo", "bar"), 0L, 0L, 1); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/catalogs/{cat}/catalog-roles", Map.of("cat", catalogName)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I didn't do this is that the methods in e.g. See existing test |
||
| .post(Entity.json(new CreateCatalogRoleRequest(okCatalogRole)))) { | ||
| assertThat(response).returns(Response.Status.CREATED.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| UpdateCatalogRoleRequest updateRequest = | ||
| new UpdateCatalogRoleRequest( | ||
| okCatalogRole.getEntityVersion(), Map.of("polaris.reserved", "true")); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/catalogs/{cat}/catalog-roles/mycatalogrole", Map.of("cat", catalogName)) | ||
| .put(Entity.json(updateRequest))) { | ||
| assertThat(response) | ||
| .returns(Response.Status.BAD_REQUEST.getStatusCode(), Response::getStatus); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testCreateAndUpdatePrincipalRoleWithReservedProperties() { | ||
| String principal = "testCreateAndUpdatePrincipalRoleWithReservedProperties"; | ||
| managementApi.createPrincipal(principal); | ||
|
|
||
| PrincipalRole badPrincipalRole = | ||
| new PrincipalRole( | ||
| client.newEntityName("myprincipalrole"), Map.of("polaris.reserved", "foo"), 0L, 0L, 1); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/principal-roles") | ||
| .post(Entity.json(new CreatePrincipalRoleRequest(badPrincipalRole)))) { | ||
| assertThat(response) | ||
| .returns(Response.Status.BAD_REQUEST.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| PrincipalRole goodPrincipalRole = | ||
| new PrincipalRole( | ||
| client.newEntityName("myprincipalrole"), Map.of("not.reserved", "foo"), 0L, 0L, 1); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/principal-roles") | ||
| .post(Entity.json(new CreatePrincipalRoleRequest(goodPrincipalRole)))) { | ||
| assertThat(response).returns(Response.Status.CREATED.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| UpdatePrincipalRoleRequest badUpdate = | ||
| new UpdatePrincipalRoleRequest( | ||
| goodPrincipalRole.getEntityVersion(), ImmutableMap.of("polaris.reserved", "true")); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/principal-roles/{pr}", Map.of("pr", goodPrincipalRole.getName())) | ||
| .put(Entity.json(badUpdate))) { | ||
| assertThat(response) | ||
| .returns(Response.Status.BAD_REQUEST.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| managementApi.deletePrincipalRole(goodPrincipalRole); | ||
| managementApi.deletePrincipal(principal); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCreateAndUpdatePrincipalWithReservedProperties() { | ||
| String principal = "testCreateAndUpdatePrincipalWithReservedProperties"; | ||
|
|
||
| Principal badPrincipal = | ||
| new Principal( | ||
| principal, "clientId", ImmutableMap.of("polaris.reserved", "true"), 0L, 0L, 1); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/principals") | ||
| .post(Entity.json(new CreatePrincipalRequest(badPrincipal, false)))) { | ||
| assertThat(response) | ||
| .returns(Response.Status.BAD_REQUEST.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| Principal goodPrincipal = | ||
| new Principal(principal, "clientId", ImmutableMap.of("not.reserved", "true"), 0L, 0L, 1); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/principals") | ||
| .post(Entity.json(new CreatePrincipalRequest(goodPrincipal, false)))) { | ||
| assertThat(response).returns(Response.Status.CREATED.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| UpdatePrincipalRequest badUpdate = | ||
| new UpdatePrincipalRequest( | ||
| goodPrincipal.getEntityVersion(), ImmutableMap.of("polaris.reserved", "true")); | ||
| try (Response response = | ||
| managementApi | ||
| .request("v1/principals/{p}", Map.of("p", goodPrincipal.getName())) | ||
| .put(Entity.json(badUpdate))) { | ||
| assertThat(response) | ||
| .returns(Response.Status.BAD_REQUEST.getStatusCode(), Response::getStatus); | ||
| } | ||
|
|
||
| managementApi.deletePrincipal(principal); | ||
| } | ||
|
|
||
| public static JWTCreator.Builder defaultJwt() { | ||
| Instant now = Instant.now(); | ||
| return JWT.create() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.polaris.service.quarkus.config; | ||
|
|
||
| import io.smallrye.config.ConfigMapping; | ||
| import java.util.List; | ||
| import org.apache.polaris.service.config.ReservedProperties; | ||
|
|
||
| @ConfigMapping(prefix = "polaris.reserved-properties") | ||
| public interface QuarkusReservedProperties extends ReservedProperties { | ||
| @Override | ||
| default List<String> prefixes() { | ||
| return List.of("polaris."); | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.