mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-11 08:23:40 +00:00
* Fix #13347: AdminPrincipals username with dot in it is not created with quoteFQN * Fix #13347: AdminPrincipals username with dot in it is not created with quoteFQN * Fix #13347: AdminPrincipals username with dot in it is not created with quoteFQN * Fix test with new exception msg being thrown --------- Co-authored-by: Pere Miquel Brull <peremiquelbrull@gmail.com>
This commit is contained in:
parent
2c3ff8dc08
commit
4d9570c627
@ -33,6 +33,7 @@ import org.openmetadata.schema.entity.teams.User;
|
|||||||
import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig;
|
import org.openmetadata.schema.security.client.OpenMetadataJWTClientConfig;
|
||||||
import org.openmetadata.schema.services.connections.metadata.AuthProvider;
|
import org.openmetadata.schema.services.connections.metadata.AuthProvider;
|
||||||
import org.openmetadata.schema.type.EntityReference;
|
import org.openmetadata.schema.type.EntityReference;
|
||||||
|
import org.openmetadata.schema.utils.EntityInterfaceUtil;
|
||||||
import org.openmetadata.service.Entity;
|
import org.openmetadata.service.Entity;
|
||||||
import org.openmetadata.service.exception.EntityNotFoundException;
|
import org.openmetadata.service.exception.EntityNotFoundException;
|
||||||
import org.openmetadata.service.jdbi3.EntityRepository;
|
import org.openmetadata.service.jdbi3.EntityRepository;
|
||||||
@ -88,10 +89,12 @@ public final class UserUtil {
|
|||||||
// user email
|
// user email
|
||||||
updatedUser.setEmail(String.format("%s@%s", username, domain));
|
updatedUser.setEmail(String.format("%s@%s", username, domain));
|
||||||
} else {
|
} else {
|
||||||
LOG.error(
|
if (Boolean.TRUE.equals(originalUser.getIsBot())) {
|
||||||
String.format(
|
LOG.error(
|
||||||
"You configured bot user %s in initialAdmins config. Bot user cannot be promoted to be an admin.",
|
String.format(
|
||||||
originalUser.getName()));
|
"You configured bot user %s in initialAdmins config. Bot user cannot be promoted to be an admin.",
|
||||||
|
originalUser.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (EntityNotFoundException e) {
|
} catch (EntityNotFoundException e) {
|
||||||
updatedUser = user(username, domain, username).withIsAdmin(isAdmin).withIsEmailVerified(true);
|
updatedUser = user(username, domain, username).withIsAdmin(isAdmin).withIsEmailVerified(true);
|
||||||
@ -145,7 +148,7 @@ public final class UserUtil {
|
|||||||
return new User()
|
return new User()
|
||||||
.withId(UUID.randomUUID())
|
.withId(UUID.randomUUID())
|
||||||
.withName(name)
|
.withName(name)
|
||||||
.withFullyQualifiedName(name)
|
.withFullyQualifiedName(EntityInterfaceUtil.quoteName(name))
|
||||||
.withEmail(name + "@" + domain)
|
.withEmail(name + "@" + domain)
|
||||||
.withUpdatedBy(updatedBy)
|
.withUpdatedBy(updatedBy)
|
||||||
.withUpdatedAt(System.currentTimeMillis())
|
.withUpdatedAt(System.currentTimeMillis())
|
||||||
|
|||||||
@ -245,6 +245,18 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
|||||||
assertResponse(() -> createEntity(create, ADMIN_AUTH_HEADERS), CONFLICT, "Entity already exists");
|
assertResponse(() -> createEntity(create, ADMIN_AUTH_HEADERS), CONFLICT, "Entity already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void test_adminPrincipalsCreation() throws IOException {
|
||||||
|
// This is test is ensure adminPrincipals are getting created as expected
|
||||||
|
// we are hardcoding the usernames as they are passed in config
|
||||||
|
// Create user with different optional fields
|
||||||
|
User user = getEntityByName("admin", ADMIN_AUTH_HEADERS);
|
||||||
|
assertEquals("admin", user.getName());
|
||||||
|
|
||||||
|
user = getEntityByName("hello.world", ADMIN_AUTH_HEADERS);
|
||||||
|
assertEquals("hello.world", user.getName());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void put_validUser_200_ok() throws IOException {
|
void put_validUser_200_ok() throws IOException {
|
||||||
// Create user with different optional fields
|
// Create user with different optional fields
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import static org.openmetadata.common.utils.CommonUtil.listOf;
|
|||||||
import static org.openmetadata.service.Entity.INGESTION_BOT_NAME;
|
import static org.openmetadata.service.Entity.INGESTION_BOT_NAME;
|
||||||
import static org.openmetadata.service.Entity.TABLE;
|
import static org.openmetadata.service.Entity.TABLE;
|
||||||
import static org.openmetadata.service.exception.CatalogExceptionMessage.entityNotFound;
|
import static org.openmetadata.service.exception.CatalogExceptionMessage.entityNotFound;
|
||||||
import static org.openmetadata.service.exception.CatalogExceptionMessage.entityTypeNotFound;
|
import static org.openmetadata.service.exception.CatalogExceptionMessage.entityRepositoryNotFound;
|
||||||
import static org.openmetadata.service.security.SecurityUtil.authHeaders;
|
import static org.openmetadata.service.security.SecurityUtil.authHeaders;
|
||||||
import static org.openmetadata.service.util.TestUtils.ADMIN_AUTH_HEADERS;
|
import static org.openmetadata.service.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||||
import static org.openmetadata.service.util.TestUtils.NON_EXISTENT_ENTITY;
|
import static org.openmetadata.service.util.TestUtils.NON_EXISTENT_ENTITY;
|
||||||
@ -107,7 +107,7 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
|
|||||||
assertResponse(
|
assertResponse(
|
||||||
() -> reportUsage(invalidEntityType, UUID.randomUUID(), usageReport(), ADMIN_AUTH_HEADERS),
|
() -> reportUsage(invalidEntityType, UUID.randomUUID(), usageReport(), ADMIN_AUTH_HEADERS),
|
||||||
NOT_FOUND,
|
NOT_FOUND,
|
||||||
entityTypeNotFound(invalidEntityType));
|
entityRepositoryNotFound(invalidEntityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -116,7 +116,7 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
|
|||||||
assertResponse(
|
assertResponse(
|
||||||
() -> reportUsagePut(invalidEntityType, UUID.randomUUID(), usageReport(), ADMIN_AUTH_HEADERS),
|
() -> reportUsagePut(invalidEntityType, UUID.randomUUID(), usageReport(), ADMIN_AUTH_HEADERS),
|
||||||
NOT_FOUND,
|
NOT_FOUND,
|
||||||
entityTypeNotFound(invalidEntityType));
|
entityRepositoryNotFound(invalidEntityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@ -129,6 +129,7 @@ authorizerConfiguration:
|
|||||||
containerRequestFilter: "org.openmetadata.service.security.CatalogOpenIdAuthorizationRequestFilter"
|
containerRequestFilter: "org.openmetadata.service.security.CatalogOpenIdAuthorizationRequestFilter"
|
||||||
adminPrincipals:
|
adminPrincipals:
|
||||||
- "admin"
|
- "admin"
|
||||||
|
- "hello.world"
|
||||||
# Added only for test purposes and not for production setup
|
# Added only for test purposes and not for production setup
|
||||||
testPrincipals:
|
testPrincipals:
|
||||||
- "test"
|
- "test"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user