mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-07-24 17:59:52 +00:00
Fix Allowed Fields (#4756)
This commit is contained in:
parent
ee1dda5366
commit
ebf329dd7e
@ -273,6 +273,12 @@ public final class Entity {
|
||||
return new ArrayList<>(Arrays.asList(propertyOrder.value()));
|
||||
}
|
||||
|
||||
public static <T> List<String> getAllowedFields(Class<T> clz) {
|
||||
String entityType = getEntityTypeFromClass(clz);
|
||||
EntityRepository<?> repository = getEntityRepository(entityType);
|
||||
return repository.getAllowedFields();
|
||||
}
|
||||
|
||||
/** Class for getting validated entity list from a queryParam with list of entities. */
|
||||
public static class EntityList {
|
||||
private EntityList() {}
|
||||
|
@ -906,6 +906,10 @@ public abstract class EntityRepository<T> {
|
||||
return new Fields(allowedFields, fields);
|
||||
}
|
||||
|
||||
public final List<String> getAllowedFields() {
|
||||
return allowedFields;
|
||||
}
|
||||
|
||||
enum Operation {
|
||||
PUT,
|
||||
PATCH,
|
||||
|
@ -36,7 +36,7 @@ public abstract class EntityResource<T, K extends EntityRepository<T>> {
|
||||
|
||||
public EntityResource(Class<T> entityClass, K repository, Authorizer authorizer) {
|
||||
this.entityClass = entityClass;
|
||||
allowedFields = Entity.getEntityFields(entityClass);
|
||||
allowedFields = Entity.getAllowedFields(entityClass);
|
||||
supportsOwner = allowedFields.contains(FIELD_OWNER);
|
||||
this.dao = repository;
|
||||
this.authorizer = authorizer;
|
||||
|
@ -224,12 +224,11 @@ public abstract class EntityResourceTest<T, K> extends CatalogApplicationTest {
|
||||
this.entityListClass = entityListClass;
|
||||
this.collectionName = collectionName;
|
||||
this.allFields = fields;
|
||||
|
||||
ENTITY_RESOURCE_TEST_MAP.put(entityType, this);
|
||||
List<String> allowedFields = Entity.getEntityFields(entityClass);
|
||||
this.supportsFollowers = allowedFields.contains(FIELD_FOLLOWERS);
|
||||
this.supportsOwner = allowedFields.contains(FIELD_OWNER);
|
||||
this.supportsTags = allowedFields.contains(FIELD_TAGS);
|
||||
ENTITY_RESOURCE_TEST_MAP.put(entityType, this);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@ -340,7 +339,7 @@ public abstract class EntityResourceTest<T, K> extends CatalogApplicationTest {
|
||||
T entity = createEntity(createRequest(test, 0), ADMIN_AUTH_HEADERS);
|
||||
EntityInterface<T> entityInterface = getEntityInterface(entity);
|
||||
|
||||
String allFields = String.join(",", Entity.getEntityFields(entityClass));
|
||||
String allFields = String.join(",", Entity.getAllowedFields(entityClass));
|
||||
|
||||
// GET an entity by ID with all the field names of an entity should be successful
|
||||
getEntity(entityInterface.getId(), allFields, ADMIN_AUTH_HEADERS);
|
||||
|
@ -111,7 +111,6 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
public UserResourceTest() {
|
||||
super(Entity.USER, User.class, UserList.class, "users", UserResource.FIELDS);
|
||||
this.supportsAuthorizedMetadataOperations = false;
|
||||
this.supportsFieldsQueryParam = false;
|
||||
}
|
||||
|
||||
public void setupUsers(TestInfo test) throws HttpResponseException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user