mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-10 16:25:37 +00:00
Fix Users Issue due to capital names (#16828)
* Fix Users Issue due to capital names * Fixed Tests * No lowercasing name * Revert * toLowerCase * fix email casing from UI side on basic auth * compare lowercase email only from the loggedInUser * address comments * Updated LowerCase UserName on updates * revert ui changes * Migrate Name and Email * cypress failure * fix glossary test * fix activity feed test * Compare by Lowercasing Email and username --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Co-authored-by: Chira Madlani <chirag@getcollate.io> Co-authored-by: karanh37 <karanh37@gmail.com>
This commit is contained in:
parent
8561022c70
commit
b1620e682a
@ -23,3 +23,47 @@ WHERE name IN (
|
||||
'columnValuesToBeBetween',
|
||||
'tableRowCountToBeBetween'
|
||||
);
|
||||
|
||||
-- Remove Duplicate Usernames and Lowercase Them
|
||||
WITH cte AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (PARTITION BY LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.name'))) ORDER BY id) as rn
|
||||
FROM
|
||||
user_entity
|
||||
)
|
||||
DELETE FROM user_entity
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM cte
|
||||
WHERE rn > 1
|
||||
);
|
||||
|
||||
UPDATE user_entity
|
||||
SET json = JSON_SET(
|
||||
json,
|
||||
'$.name',
|
||||
LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.name')))
|
||||
);
|
||||
|
||||
-- Remove Duplicate Emails and Lowercase Them
|
||||
WITH cte AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (PARTITION BY LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.email'))) ORDER BY id) as rn
|
||||
FROM
|
||||
user_entity
|
||||
)
|
||||
DELETE FROM user_entity
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM cte
|
||||
WHERE rn > 1
|
||||
);
|
||||
|
||||
UPDATE user_entity
|
||||
SET json = JSON_SET(
|
||||
json,
|
||||
'$.email',
|
||||
LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.email')))
|
||||
);
|
||||
|
@ -22,3 +22,47 @@ WHERE name IN (
|
||||
'columnValuesToBeBetween',
|
||||
'tableRowCountToBeBetween'
|
||||
);
|
||||
|
||||
-- Remove Duplicate UserNames and lowercase them
|
||||
WITH cte AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (PARTITION BY to_jsonb(LOWER(json->>'name')) ORDER BY id) as rn
|
||||
FROM
|
||||
user_entity
|
||||
)
|
||||
DELETE from user_entity
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM cte
|
||||
WHERE rn > 1
|
||||
);
|
||||
|
||||
UPDATE user_entity
|
||||
SET json = jsonb_set(
|
||||
json,
|
||||
'{name}',
|
||||
to_jsonb(LOWER(json->>'name'))
|
||||
);
|
||||
|
||||
-- Remove Duplicate Emails and lowercase them
|
||||
WITH cte AS (
|
||||
SELECT
|
||||
id,
|
||||
ROW_NUMBER() OVER (PARTITION BY to_jsonb(LOWER(json->>'email')) ORDER BY id) as rn
|
||||
FROM
|
||||
user_entity
|
||||
)
|
||||
DELETE from user_entity
|
||||
WHERE id IN (
|
||||
SELECT id
|
||||
FROM cte
|
||||
WHERE rn > 1
|
||||
);
|
||||
|
||||
UPDATE user_entity
|
||||
SET json = jsonb_set(
|
||||
json,
|
||||
'{email}',
|
||||
to_jsonb(LOWER(json->>'email'))
|
||||
);
|
||||
|
@ -77,7 +77,7 @@ public abstract class EntityCsv<T extends EntityInterface> {
|
||||
protected final CsvImportResult importResult = new CsvImportResult();
|
||||
protected boolean processRecord; // When set to false record processing is discontinued
|
||||
protected final Map<String, T> dryRunCreatedEntities = new HashMap<>();
|
||||
private final String importedBy;
|
||||
protected final String importedBy;
|
||||
protected int recordIndex = 0;
|
||||
|
||||
protected EntityCsv(String entityType, List<CsvHeader> csvHeaders, String importedBy) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.openmetadata.service.jdbi3;
|
||||
|
||||
import static org.openmetadata.service.exception.AppException.APP_RUN_RECORD_NOT_FOUND;
|
||||
import static org.openmetadata.service.resources.teams.UserResource.getUser;
|
||||
import static org.openmetadata.service.util.UserUtil.getUser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -118,12 +118,12 @@ public class AppRepository extends EntityRepository<App> {
|
||||
Bot appBot =
|
||||
new Bot()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(botUser.getName())
|
||||
.withName(botName)
|
||||
.withUpdatedBy("admin")
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
.withBotUser(botUser.getEntityReference())
|
||||
.withProvider(ProviderType.USER)
|
||||
.withFullyQualifiedName(botUser.getName());
|
||||
.withFullyQualifiedName(botName);
|
||||
|
||||
// Create Bot with above user
|
||||
bot = botRepository.createInternal(appBot);
|
||||
|
@ -42,6 +42,7 @@ import org.apache.commons.csv.CSVRecord;
|
||||
import org.jdbi.v3.sqlobject.transaction.Transaction;
|
||||
import org.openmetadata.csv.EntityCsv;
|
||||
import org.openmetadata.schema.api.teams.CreateTeam.TeamType;
|
||||
import org.openmetadata.schema.api.teams.CreateUser;
|
||||
import org.openmetadata.schema.entity.teams.AuthenticationMechanism;
|
||||
import org.openmetadata.schema.entity.teams.Team;
|
||||
import org.openmetadata.schema.entity.teams.User;
|
||||
@ -338,7 +339,10 @@ public class UserRepository extends EntityRepository<User> {
|
||||
|
||||
public void validateLoggedInUserNameAndEmailMatches(
|
||||
String username, String email, User storedUser) {
|
||||
if (!(username.equals(storedUser.getName()) && email.equals(storedUser.getEmail()))) {
|
||||
String lowerCasedName = username.toLowerCase();
|
||||
String lowerCasedEmail = email.toLowerCase();
|
||||
if (!(lowerCasedName.equals(storedUser.getName().toLowerCase())
|
||||
&& lowerCasedEmail.equals(storedUser.getEmail().toLowerCase()))) {
|
||||
throw EntityNotFoundException.byMessage(CatalogExceptionMessage.entityNotFound(USER, email));
|
||||
}
|
||||
}
|
||||
@ -436,13 +440,15 @@ public class UserRepository extends EntityRepository<User> {
|
||||
CSVRecord csvRecord = getNextRecord(printer, csvRecords);
|
||||
// Field 1, 2, 3, 4, 5, 6 - name, displayName, description, email, timezone, isAdmin
|
||||
User user =
|
||||
new User()
|
||||
.withName(csvRecord.get(0))
|
||||
.withDisplayName(csvRecord.get(1))
|
||||
.withDescription(csvRecord.get(2))
|
||||
.withEmail(csvRecord.get(3))
|
||||
.withTimezone(csvRecord.get(4))
|
||||
.withIsAdmin(getBoolean(printer, csvRecord, 5))
|
||||
UserUtil.getUser(
|
||||
importedBy,
|
||||
new CreateUser()
|
||||
.withName(csvRecord.get(0))
|
||||
.withDisplayName(csvRecord.get(1))
|
||||
.withDescription(csvRecord.get(2))
|
||||
.withEmail(csvRecord.get(3))
|
||||
.withTimezone(csvRecord.get(4))
|
||||
.withIsAdmin(getBoolean(printer, csvRecord, 5)))
|
||||
.withTeams(getTeams(printer, csvRecord, csvRecord.get(0)))
|
||||
.withRoles(getEntityReferences(printer, csvRecord, 7, ROLE));
|
||||
if (processRecord) {
|
||||
@ -542,6 +548,10 @@ public class UserRepository extends EntityRepository<User> {
|
||||
@Transaction
|
||||
@Override
|
||||
public void entitySpecificUpdate() {
|
||||
// LowerCase Email
|
||||
updated.setEmail(updated.getEmail().toLowerCase());
|
||||
|
||||
// Updates
|
||||
updateRoles(original, updated);
|
||||
updateTeams(original, updated);
|
||||
updatePersonas(original, updated);
|
||||
@ -551,7 +561,7 @@ public class UserRepository extends EntityRepository<User> {
|
||||
recordChange("timezone", original.getTimezone(), updated.getTimezone());
|
||||
recordChange("isBot", original.getIsBot(), updated.getIsBot());
|
||||
recordChange("isAdmin", original.getIsAdmin(), updated.getIsAdmin());
|
||||
recordChange("email", original.getEmail(), updated.getEmail());
|
||||
recordChange("email", original.getEmail(), updated.getEmail().toLowerCase());
|
||||
recordChange("isEmailVerified", original.getIsEmailVerified(), updated.getIsEmailVerified());
|
||||
updateAuthenticationMechanism(original, updated);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import static org.openmetadata.service.secrets.ExternalSecretsManager.NULL_SECRE
|
||||
import static org.openmetadata.service.security.jwt.JWTTokenGenerator.getExpiryDate;
|
||||
import static org.openmetadata.service.util.UserUtil.getRoleListFromUser;
|
||||
import static org.openmetadata.service.util.UserUtil.getRolesFromAuthorizationToken;
|
||||
import static org.openmetadata.service.util.UserUtil.getUser;
|
||||
import static org.openmetadata.service.util.UserUtil.reSyncUserRolesFromToken;
|
||||
import static org.openmetadata.service.util.UserUtil.validateAndGetRolesRef;
|
||||
|
||||
@ -1450,26 +1451,6 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
return importCsvInternal(securityContext, team, csv, dryRun);
|
||||
}
|
||||
|
||||
public static User getUser(String updatedBy, CreateUser create) {
|
||||
return new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(create.getName())
|
||||
.withFullyQualifiedName(create.getName())
|
||||
.withEmail(create.getEmail())
|
||||
.withDescription(create.getDescription())
|
||||
.withDisplayName(create.getDisplayName())
|
||||
.withIsBot(create.getIsBot())
|
||||
.withIsAdmin(create.getIsAdmin())
|
||||
.withProfile(create.getProfile())
|
||||
.withPersonas(create.getPersonas())
|
||||
.withDefaultPersona(create.getDefaultPersona())
|
||||
.withTimezone(create.getTimezone())
|
||||
.withUpdatedBy(updatedBy)
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
.withTeams(EntityUtil.toEntityReferences(create.getTeams(), Entity.TEAM))
|
||||
.withRoles(EntityUtil.toEntityReferences(create.getRoles(), Entity.ROLE));
|
||||
}
|
||||
|
||||
public void validateEmailAlreadyExists(String email) {
|
||||
if (repository.checkEmailAlreadyExists(email)) {
|
||||
throw new CustomExceptionMessage(
|
||||
|
@ -16,14 +16,14 @@ package org.openmetadata.service.security;
|
||||
import java.security.Principal;
|
||||
import lombok.Getter;
|
||||
|
||||
public record CatalogPrincipal(@Getter String name, @Getter String email) implements Principal {
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@Getter
|
||||
public class CatalogPrincipal implements Principal {
|
||||
private final String name;
|
||||
private final String email;
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
public CatalogPrincipal(String name, String email) {
|
||||
this.name = name.toLowerCase();
|
||||
this.email = email.toLowerCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,9 +14,9 @@
|
||||
package org.openmetadata.service.security;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import javax.ws.rs.core.SecurityContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openmetadata.schema.api.teams.CreateUser;
|
||||
import org.openmetadata.schema.entity.teams.User;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
import org.openmetadata.schema.type.Include;
|
||||
@ -30,6 +30,7 @@ import org.openmetadata.service.security.policyevaluator.OperationContext;
|
||||
import org.openmetadata.service.security.policyevaluator.PolicyEvaluator;
|
||||
import org.openmetadata.service.security.policyevaluator.ResourceContextInterface;
|
||||
import org.openmetadata.service.util.RestUtil.PutResponse;
|
||||
import org.openmetadata.service.util.UserUtil;
|
||||
|
||||
@Slf4j
|
||||
public class NoopAuthorizer implements Authorizer {
|
||||
@ -70,12 +71,8 @@ public class NoopAuthorizer implements Authorizer {
|
||||
Entity.getEntityByName(Entity.USER, username, "", Include.NON_DELETED);
|
||||
} catch (EntityNotFoundException ex) {
|
||||
User user =
|
||||
new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(username)
|
||||
.withEmail(username + "@domain.com")
|
||||
.withUpdatedBy(username)
|
||||
.withUpdatedAt(System.currentTimeMillis());
|
||||
UserUtil.getUser(
|
||||
username, new CreateUser().withName(username).withEmail(username + "@domain.com"));
|
||||
addOrUpdateUser(user);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to create anonymous user {}", username, e);
|
||||
|
@ -81,25 +81,21 @@ public final class SecurityUtil {
|
||||
Map<String, String> jwtPrincipalClaimsMapping,
|
||||
List<String> jwtPrincipalClaimsOrder,
|
||||
Map<String, ?> claims) {
|
||||
String userName;
|
||||
if (!nullOrEmpty(jwtPrincipalClaimsMapping)) {
|
||||
// We have a mapping available so we will use that
|
||||
String usernameClaim = jwtPrincipalClaimsMapping.get(USERNAME_CLAIM_KEY);
|
||||
String userNameClaimValue = getClaimOrObject(claims.get(usernameClaim));
|
||||
if (!nullOrEmpty(userNameClaimValue)) {
|
||||
return userNameClaimValue;
|
||||
userName = userNameClaimValue;
|
||||
} else {
|
||||
throw new AuthenticationException("Invalid JWT token, 'username' claim is not present");
|
||||
}
|
||||
} else {
|
||||
String jwtClaim = getFirstMatchJwtClaim(jwtPrincipalClaimsOrder, claims);
|
||||
String userName;
|
||||
if (jwtClaim.contains("@")) {
|
||||
userName = jwtClaim.split("@")[0];
|
||||
} else {
|
||||
userName = jwtClaim;
|
||||
}
|
||||
return userName;
|
||||
userName = jwtClaim.contains("@") ? jwtClaim.split("@")[0] : jwtClaim;
|
||||
}
|
||||
return userName.toLowerCase();
|
||||
}
|
||||
|
||||
public static String findEmailFromClaims(
|
||||
@ -107,12 +103,13 @@ public final class SecurityUtil {
|
||||
List<String> jwtPrincipalClaimsOrder,
|
||||
Map<String, ?> claims,
|
||||
String defaulPrincipalClaim) {
|
||||
String email;
|
||||
if (!nullOrEmpty(jwtPrincipalClaimsMapping)) {
|
||||
// We have a mapping available so we will use that
|
||||
String emailClaim = jwtPrincipalClaimsMapping.get(EMAIL_CLAIM_KEY);
|
||||
String emailClaimValue = getClaimOrObject(claims.get(emailClaim));
|
||||
if (!nullOrEmpty(emailClaimValue) && emailClaimValue.contains("@")) {
|
||||
return emailClaimValue;
|
||||
email = emailClaimValue;
|
||||
} else {
|
||||
throw new AuthenticationException(
|
||||
String.format(
|
||||
@ -121,12 +118,12 @@ public final class SecurityUtil {
|
||||
}
|
||||
} else {
|
||||
String jwtClaim = getFirstMatchJwtClaim(jwtPrincipalClaimsOrder, claims);
|
||||
if (jwtClaim.contains("@")) {
|
||||
return jwtClaim;
|
||||
} else {
|
||||
return String.format("%s@%s", jwtClaim, defaulPrincipalClaim);
|
||||
}
|
||||
email =
|
||||
jwtClaim.contains("@")
|
||||
? jwtClaim
|
||||
: String.format("%s@%s", jwtClaim, defaulPrincipalClaim);
|
||||
}
|
||||
return email.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getClaimOrObject(Object obj) {
|
||||
|
@ -39,6 +39,7 @@ import static org.openmetadata.service.exception.CatalogExceptionMessage.TOKEN_E
|
||||
import static org.openmetadata.service.resources.teams.UserResource.USER_PROTECTED_FIELDS;
|
||||
import static org.openmetadata.service.util.EmailUtil.getSmtpSettings;
|
||||
import static org.openmetadata.service.util.UserUtil.getRoleListFromUser;
|
||||
import static org.openmetadata.service.util.UserUtil.getUser;
|
||||
|
||||
import at.favre.lib.crypto.bcrypt.BCrypt;
|
||||
import freemarker.template.TemplateException;
|
||||
@ -449,17 +450,14 @@ public class BasicAuthenticator implements AuthenticatorHandler {
|
||||
BCrypt.withDefaults().hashToString(HASHING_COST, create.getPassword().toCharArray());
|
||||
|
||||
BasicAuthMechanism newAuthMechanism = new BasicAuthMechanism().withPassword(hashedPwd);
|
||||
return new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(username)
|
||||
.withFullyQualifiedName(username)
|
||||
.withEmail(create.getEmail())
|
||||
.withDisplayName(create.getFirstName() + create.getLastName())
|
||||
.withIsBot(false)
|
||||
.withIsAdmin(false)
|
||||
.withUpdatedBy(username)
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
.withIsEmailVerified(false)
|
||||
return getUser(
|
||||
username,
|
||||
new CreateUser()
|
||||
.withName(username)
|
||||
.withEmail(create.getEmail())
|
||||
.withDisplayName(String.format("%s%s", create.getFirstName(), create.getLastName()))
|
||||
.withIsBot(false)
|
||||
.withIsAdmin(false))
|
||||
.withAuthenticationMechanism(
|
||||
new AuthenticationMechanism()
|
||||
.withAuthType(AuthenticationMechanism.AuthType.BASIC)
|
||||
|
@ -34,6 +34,7 @@ import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openmetadata.common.utils.CommonUtil;
|
||||
import org.openmetadata.schema.api.configuration.LoginConfiguration;
|
||||
import org.openmetadata.schema.api.teams.CreateUser;
|
||||
import org.openmetadata.schema.auth.LdapConfiguration;
|
||||
import org.openmetadata.schema.auth.LoginRequest;
|
||||
import org.openmetadata.schema.auth.RefreshToken;
|
||||
@ -254,31 +255,18 @@ public class LdapAuthenticator implements AuthenticatorHandler {
|
||||
|
||||
private User getUserForLdap(String email) {
|
||||
String userName = email.split("@")[0];
|
||||
return new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(userName)
|
||||
.withFullyQualifiedName(userName)
|
||||
.withEmail(email)
|
||||
.withIsBot(false)
|
||||
.withUpdatedBy(userName)
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
return UserUtil.getUser(
|
||||
userName, new CreateUser().withName(userName).withEmail(email).withIsBot(false))
|
||||
.withIsEmailVerified(false)
|
||||
.withAuthenticationMechanism(null);
|
||||
}
|
||||
|
||||
private User getUserForLdap(String email, String userName, String userDn) {
|
||||
User user =
|
||||
new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(userName)
|
||||
.withFullyQualifiedName(userName)
|
||||
.withEmail(email)
|
||||
.withIsBot(false)
|
||||
.withUpdatedBy(userName)
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
UserUtil.getUser(
|
||||
userName, new CreateUser().withName(userName).withEmail(email).withIsBot(false))
|
||||
.withIsEmailVerified(false)
|
||||
.withAuthenticationMechanism(null);
|
||||
|
||||
try {
|
||||
getRoleForLdap(user, userDn, false);
|
||||
} catch (LDAPException | JsonProcessingException e) {
|
||||
|
@ -32,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
import javax.json.JsonPatch;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openmetadata.schema.api.teams.CreateUser;
|
||||
import org.openmetadata.schema.auth.BasicAuthMechanism;
|
||||
import org.openmetadata.schema.auth.JWTAuthMechanism;
|
||||
import org.openmetadata.schema.auth.JWTTokenExpiry;
|
||||
@ -161,14 +162,8 @@ public final class UserUtil {
|
||||
}
|
||||
|
||||
public static User user(String name, String domain, String updatedBy) {
|
||||
return new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(name)
|
||||
.withFullyQualifiedName(EntityInterfaceUtil.quoteName(name))
|
||||
.withEmail(name + "@" + domain)
|
||||
.withUpdatedBy(updatedBy)
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
.withIsBot(false);
|
||||
return getUser(
|
||||
updatedBy, new CreateUser().withName(name).withEmail(name + "@" + domain).withIsBot(false));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -330,4 +325,24 @@ public final class UserUtil {
|
||||
|
||||
return syncUser;
|
||||
}
|
||||
|
||||
public static User getUser(String updatedBy, CreateUser create) {
|
||||
return new User()
|
||||
.withId(UUID.randomUUID())
|
||||
.withName(create.getName().toLowerCase())
|
||||
.withFullyQualifiedName(EntityInterfaceUtil.quoteName(create.getName().toLowerCase()))
|
||||
.withEmail(create.getEmail().toLowerCase())
|
||||
.withDescription(create.getDescription())
|
||||
.withDisplayName(create.getDisplayName())
|
||||
.withIsBot(create.getIsBot())
|
||||
.withIsAdmin(create.getIsAdmin())
|
||||
.withProfile(create.getProfile())
|
||||
.withPersonas(create.getPersonas())
|
||||
.withDefaultPersona(create.getDefaultPersona())
|
||||
.withTimezone(create.getTimezone())
|
||||
.withUpdatedBy(updatedBy.toLowerCase())
|
||||
.withUpdatedAt(System.currentTimeMillis())
|
||||
.withTeams(EntityUtil.toEntityReferences(create.getTeams(), Entity.TEAM))
|
||||
.withRoles(EntityUtil.toEntityReferences(create.getRoles(), Entity.ROLE));
|
||||
}
|
||||
}
|
||||
|
@ -2925,7 +2925,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
return patchEntityAndCheck(entity, originalJson, authHeaders, MINOR_UPDATE, change);
|
||||
}
|
||||
|
||||
protected final void validateCommonEntityFields(T entity, CreateEntity create, String updatedBy) {
|
||||
protected void validateCommonEntityFields(T entity, CreateEntity create, String updatedBy) {
|
||||
assertListNotNull(entity.getId(), entity.getHref(), entity.getFullyQualifiedName());
|
||||
assertEquals(create.getName(), entity.getName());
|
||||
assertEquals(create.getDisplayName(), entity.getDisplayName());
|
||||
|
@ -95,6 +95,7 @@ import org.junit.jupiter.api.TestInfo;
|
||||
import org.junit.jupiter.api.TestMethodOrder;
|
||||
import org.openmetadata.csv.EntityCsv;
|
||||
import org.openmetadata.csv.EntityCsvTest;
|
||||
import org.openmetadata.schema.CreateEntity;
|
||||
import org.openmetadata.schema.api.CreateBot;
|
||||
import org.openmetadata.schema.api.teams.CreateTeam;
|
||||
import org.openmetadata.schema.api.teams.CreateUser;
|
||||
@ -869,6 +870,17 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
entityNotFound("user", user.getId()));
|
||||
}
|
||||
|
||||
protected void validateCommonEntityFields(User entity, CreateEntity create, String updatedBy) {
|
||||
assertListNotNull(entity.getId(), entity.getHref(), entity.getFullyQualifiedName());
|
||||
assertEquals(create.getName().toLowerCase(), entity.getName());
|
||||
assertEquals(create.getDisplayName(), entity.getDisplayName());
|
||||
assertEquals(create.getDescription(), entity.getDescription());
|
||||
assertEquals(
|
||||
JsonUtils.valueToTree(create.getExtension()), JsonUtils.valueToTree(entity.getExtension()));
|
||||
assertReference(create.getOwner(), entity.getOwner());
|
||||
assertEquals(updatedBy, entity.getUpdatedBy());
|
||||
}
|
||||
|
||||
@Test
|
||||
void put_generateToken_bot_user_200_ok() throws HttpResponseException {
|
||||
AuthenticationMechanism authMechanism =
|
||||
@ -940,7 +952,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
// jwtAuth Response should be null always
|
||||
user = getEntity(user.getId(), ADMIN_AUTH_HEADERS);
|
||||
assertNull(user.getAuthenticationMechanism());
|
||||
assertEquals(name, user.getName());
|
||||
assertEquals(name.toLowerCase(), user.getName());
|
||||
assertEquals(name.toLowerCase(), user.getFullyQualifiedName());
|
||||
|
||||
// Login With Correct Password
|
||||
@ -1006,9 +1018,9 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
getResource("users/signup"), newRegistrationRequest, String.class, ADMIN_AUTH_HEADERS);
|
||||
|
||||
// jwtAuth Response should be null always
|
||||
User user = getEntityByName("testBasicAuth123", null, ADMIN_AUTH_HEADERS);
|
||||
User user = getEntityByName(name, null, ADMIN_AUTH_HEADERS);
|
||||
assertNull(user.getAuthenticationMechanism());
|
||||
assertEquals(name, user.getName());
|
||||
assertEquals(name.toLowerCase(), user.getName());
|
||||
assertEquals(name.toLowerCase(), user.getFullyQualifiedName());
|
||||
|
||||
// Login With Correct Password
|
||||
@ -1024,7 +1036,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
OK.getStatusCode(),
|
||||
ADMIN_AUTH_HEADERS);
|
||||
|
||||
validateJwtBasicAuth(jwtResponse, "testBasicAuth123");
|
||||
validateJwtBasicAuth(jwtResponse, name);
|
||||
|
||||
// Login With Wrong email
|
||||
LoginRequest failedLoginWithWrongEmail =
|
||||
@ -1157,36 +1169,36 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
// Create users in the team hierarchy
|
||||
// Headers - name,displayName,description,email,timezone,isAdmin,teams,roles
|
||||
String user =
|
||||
"userImportExport,d,s,userImportExport@domain.com,America/Los_Angeles,true,teamImportExport,";
|
||||
"userimportexport,d,s,userimportexport@domain.com,America/Los_Angeles,true,teamImportExport,";
|
||||
String user1 =
|
||||
"userImportExport1,,,userImportExport1@domain.com,,false,teamImportExport1,DataConsumer";
|
||||
String user11 = "userImportExport11,,,userImportExport11@domain.com,,false,teamImportExport11,";
|
||||
"userimportexport1,,,userimportexport1@domain.com,,false,teamImportExport1,DataConsumer";
|
||||
String user11 = "userimportexport11,,,userimportexport11@domain.com,,false,teamImportExport11,";
|
||||
List<String> createRecords = listOf(user, user1, user11);
|
||||
|
||||
// Update user descriptions
|
||||
user = "userImportExport,displayName,,userImportExport@domain.com,,false,teamImportExport,";
|
||||
user = "userimportexport,displayName,,userimportexport@domain.com,,false,teamImportExport,";
|
||||
user1 =
|
||||
"userImportExport1,displayName1,,userImportExport1@domain.com,,false,teamImportExport1,";
|
||||
"userimportexport1,displayName1,,userimportexport1@domain.com,,false,teamImportExport1,";
|
||||
user11 =
|
||||
"userImportExport11,displayName11,,userImportExport11@domain.com,,false,teamImportExport11,";
|
||||
"userimportexport11,displayName11,,userimportexport11@domain.com,,false,teamImportExport11,";
|
||||
List<String> updateRecords = listOf(user, user1, user11);
|
||||
|
||||
// Add new users
|
||||
String user2 =
|
||||
"userImportExport2,displayName2,,userImportExport2@domain.com,,false,teamImportExport1,";
|
||||
"userimportexport2,displayName2,,userimportexport2@domain.com,,false,teamImportExport1,";
|
||||
String user21 =
|
||||
"userImportExport21,displayName21,,userImportExport21@domain.com,,false,teamImportExport11,";
|
||||
"userimportexport21,displayName21,,userimportexport21@domain.com,,false,teamImportExport11,";
|
||||
List<String> newRecords = listOf(user2, user21);
|
||||
testImportExport("teamImportExport", UserCsv.HEADERS, createRecords, updateRecords, newRecords);
|
||||
|
||||
// Import to team11 a user in team1 - since team1 is not under team11 hierarchy, import should
|
||||
// fail
|
||||
String user3 =
|
||||
"userImportExport3,displayName3,,userImportExport3@domain.com,,false,teamImportExport1,";
|
||||
"userimportexport3,displayName3,,userimportexport3@domain.com,,false,teamImportExport1,";
|
||||
csv = EntityCsvTest.createCsv(UserCsv.HEADERS, listOf(user3), null);
|
||||
result = importCsv("teamImportExport11", csv, false);
|
||||
String error =
|
||||
UserCsv.invalidTeam(6, "teamImportExport11", "userImportExport3", "teamImportExport1");
|
||||
UserCsv.invalidTeam(6, "teamImportExport11", "userimportexport3", "teamImportExport1");
|
||||
assertTrue(result.getImportResultsCsv().contains(error));
|
||||
}
|
||||
|
||||
@ -1200,7 +1212,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
Date date = jwt.getExpiresAt();
|
||||
long hours = ((date.getTime() - jwt.getIssuedAt().getTime()) / (1000 * 60 * 60));
|
||||
assertEquals(1, hours);
|
||||
assertEquals(username, jwt.getClaims().get("sub").asString());
|
||||
assertEquals(username.toLowerCase(), jwt.getClaims().get("sub").asString().toLowerCase());
|
||||
assertEquals(false, jwt.getClaims().get("isBot").asBoolean());
|
||||
}
|
||||
|
||||
@ -1404,7 +1416,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
@Override
|
||||
public void validateCreatedEntity(
|
||||
User user, CreateUser createRequest, Map<String, String> authHeaders) {
|
||||
assertEquals(createRequest.getName(), user.getName());
|
||||
assertEquals(createRequest.getName().toLowerCase(), user.getName());
|
||||
assertEquals(createRequest.getDisplayName(), user.getDisplayName());
|
||||
assertEquals(createRequest.getTimezone(), user.getTimezone());
|
||||
assertEquals(createRequest.getIsBot(), user.getIsBot());
|
||||
|
@ -23,7 +23,7 @@ import {
|
||||
import { DELETE_TERM } from '../../constants/constants';
|
||||
import { GlobalSettingOptions } from '../../constants/settings.constant';
|
||||
|
||||
const botName = `Bot-ct-test-${uuid()}`;
|
||||
const botName = `bot-ct-test-${uuid()}`;
|
||||
const botEmail = `${botName}@mail.com`;
|
||||
const description = 'This is bot description';
|
||||
const updatedDescription = 'This is updated bot description';
|
||||
|
@ -57,7 +57,7 @@ const expirationTime = {
|
||||
twomonths: '60',
|
||||
threemonths: '90',
|
||||
};
|
||||
const name = `Usercttest${uuid()}`;
|
||||
const name = `usercttest${uuid()}`;
|
||||
const owner = generateRandomUser();
|
||||
let userId = '';
|
||||
const ownerName = `${owner.firstName}${owner.lastName}`;
|
||||
|
@ -57,7 +57,7 @@ test.describe('Activity feed', () => {
|
||||
test('Assigned task should appear to task tab', async ({ page }) => {
|
||||
const value: TaskDetails = {
|
||||
term: entity.entity.name,
|
||||
assignee: `${user.data.firstName}.${user.data.lastName}`,
|
||||
assignee: user.responseData.name,
|
||||
};
|
||||
await entity.visitEntityPage(page);
|
||||
|
||||
|
@ -29,9 +29,8 @@ const AppRouter = () => {
|
||||
|
||||
// web analytics instance
|
||||
const analytics = useAnalytics();
|
||||
const { currentUser } = useApplicationStore();
|
||||
|
||||
const { isAuthenticated, isApplicationLoading } = useApplicationStore();
|
||||
const { currentUser, isAuthenticated, isApplicationLoading } =
|
||||
useApplicationStore();
|
||||
|
||||
useEffect(() => {
|
||||
const { pathname } = location;
|
||||
|
@ -115,7 +115,7 @@ const BasicAuthProvider = ({
|
||||
onLoginSuccess({
|
||||
id_token: response.accessToken,
|
||||
profile: {
|
||||
email,
|
||||
email: response.email,
|
||||
name: '',
|
||||
picture: '',
|
||||
sub: '',
|
||||
|
@ -17,7 +17,6 @@ import React, { useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import loginBG from '../../assets/img/login-bg.png';
|
||||
|
||||
import { useBasicAuth } from '../../components/Auth/AuthProviders/BasicAuthProvider';
|
||||
import BrandImage from '../../components/common/BrandImage/BrandImage';
|
||||
import { ROUTES, VALIDATION_MESSAGES } from '../../constants/constants';
|
||||
|
Loading…
x
Reference in New Issue
Block a user