mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-06 22:35:24 +00:00
Sonar.2 oct22 (#7860)
* Fix of variable names according to the naming convention (#7855) * Changed the fields to final static * correct the java checkstyle * Changed the naming of packages according to the naming conventions * Fixing warnings in the code Co-authored-by: Shivam Purohit <91889807+shivam-Purohit@users.noreply.github.com>
This commit is contained in:
parent
c27657ea5e
commit
6b5a788d2b
@ -39,8 +39,6 @@ public class OpenMetadata {
|
||||
}
|
||||
|
||||
private ApiClient apiClient;
|
||||
private OpenMetadataServerConnection serverConfig;
|
||||
private String basePath;
|
||||
private static final String requestInterceptorKey = "custom";
|
||||
|
||||
public OpenMetadata(OpenMetadataServerConnection config) {
|
||||
@ -54,7 +52,6 @@ public class OpenMetadata {
|
||||
}
|
||||
|
||||
public void initClient(OpenMetadataServerConnection config) {
|
||||
serverConfig = config;
|
||||
apiClient = new ApiClient();
|
||||
Feign.Builder builder =
|
||||
Feign.builder()
|
||||
@ -65,7 +62,7 @@ public class OpenMetadata {
|
||||
apiClient.setFeignBuilder(builder);
|
||||
AuthenticationProviderFactory factory = new AuthenticationProviderFactory();
|
||||
apiClient.addAuthorization("oauth", factory.getAuthProvider(config));
|
||||
basePath = config.getHostPort() + "/";
|
||||
String basePath = config.getHostPort() + "/";
|
||||
apiClient.setBasePath(basePath);
|
||||
apiClient.getObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Slf4j
|
||||
public class CustomRequestInterceptor<K> implements RequestInterceptor {
|
||||
private final Class<K> type;
|
||||
ObjectMapper mapper;
|
||||
final ObjectMapper mapper;
|
||||
|
||||
public CustomRequestInterceptor(ObjectMapper iMapper, Class<K> type) {
|
||||
this.type = type;
|
||||
|
@ -20,7 +20,7 @@ import org.openmetadata.client.security.interfaces.AuthenticationProvider;
|
||||
import org.openmetadata.schema.services.connections.metadata.OpenMetadataServerConnection;
|
||||
|
||||
public class OktaAccessTokenRequestInterceptor implements AuthenticationProvider {
|
||||
private OktaSSOConfig securityConfig;
|
||||
private final OktaSSOConfig securityConfig;
|
||||
private String base64Credentials;
|
||||
|
||||
public OktaAccessTokenRequestInterceptor(OktaSSOConfig config) {
|
||||
|
@ -28,10 +28,6 @@ import org.openmetadata.schema.services.connections.metadata.OpenMetadataServerC
|
||||
|
||||
@Slf4j
|
||||
public class Auth0AuthenticationProvider implements AuthenticationProvider {
|
||||
private OpenMetadataServerConnection serverConfig;
|
||||
|
||||
private final Auth0SSOClientConfig securityConfig;
|
||||
|
||||
private String generatedAuthToken;
|
||||
private Long expirationTimeMillis;
|
||||
private final Auth0AccessTokenApi auth0SSOClient;
|
||||
@ -41,9 +37,8 @@ public class Auth0AuthenticationProvider implements AuthenticationProvider {
|
||||
LOG.error("Required type to invoke is Auth0 for Auth0Authentication Provider");
|
||||
throw new RuntimeException("Required type to invoke is Auth0 for Auth0Authentication Provider");
|
||||
}
|
||||
serverConfig = iConfig;
|
||||
|
||||
securityConfig = (Auth0SSOClientConfig) iConfig.getSecurityConfig();
|
||||
Auth0SSOClientConfig securityConfig = (Auth0SSOClientConfig) iConfig.getSecurityConfig();
|
||||
if (securityConfig == null) {
|
||||
LOG.error("Security Config is missing, it is required");
|
||||
throw new RuntimeException("Security Config is missing, it is required");
|
||||
|
@ -29,7 +29,6 @@ import org.openmetadata.schema.services.connections.metadata.OpenMetadataServerC
|
||||
|
||||
@Slf4j
|
||||
public class AzureAuthenticationProvider implements AuthenticationProvider {
|
||||
private OpenMetadataServerConnection serverConfig;
|
||||
private final AzureSSOClientConfig securityConfig;
|
||||
private String generatedAuthToken;
|
||||
private Long expirationTimeMillis;
|
||||
@ -39,7 +38,6 @@ public class AzureAuthenticationProvider implements AuthenticationProvider {
|
||||
LOG.error("Required type to invoke is Azure for AzureAuthentication Provider");
|
||||
throw new RuntimeException("Required type to invoke is Azure for AzureAuthentication Provider");
|
||||
}
|
||||
serverConfig = iConfig;
|
||||
|
||||
securityConfig = (AzureSSOClientConfig) iConfig.getSecurityConfig();
|
||||
if (securityConfig == null) {
|
||||
|
@ -28,7 +28,6 @@ import org.openmetadata.schema.services.connections.metadata.OpenMetadataServerC
|
||||
|
||||
@Slf4j
|
||||
public class CustomOIDCAuthenticationProvider implements AuthenticationProvider {
|
||||
private OpenMetadataServerConnection serverConfig;
|
||||
private final CustomOIDCSSOClientConfig securityConfig;
|
||||
private String generatedAuthToken;
|
||||
private Long expirationTimeMillis;
|
||||
@ -39,7 +38,6 @@ public class CustomOIDCAuthenticationProvider implements AuthenticationProvider
|
||||
LOG.error("Required type to invoke is CustomOIDC for CustomOIDCAuthentication Provider");
|
||||
throw new RuntimeException("Required type to invoke is CustomOIDC for CustomOIDCAuthentication Provider");
|
||||
}
|
||||
serverConfig = iConfig;
|
||||
|
||||
securityConfig = (CustomOIDCSSOClientConfig) iConfig.getSecurityConfig();
|
||||
if (securityConfig == null) {
|
||||
|
@ -26,8 +26,7 @@ import org.openmetadata.schema.services.connections.metadata.OpenMetadataServerC
|
||||
|
||||
@Slf4j
|
||||
public class GoogleAuthenticationProvider implements AuthenticationProvider {
|
||||
private OpenMetadataServerConnection serverConfig;
|
||||
private GoogleSSOClientConfig securityConfig;
|
||||
private final GoogleSSOClientConfig securityConfig;
|
||||
private String generatedAuthToken;
|
||||
private Long expirationTimeMillis;
|
||||
private static final String OPENID_SCOPE = "https://www.googleapis.com/auth/plus.me";
|
||||
@ -39,7 +38,6 @@ public class GoogleAuthenticationProvider implements AuthenticationProvider {
|
||||
LOG.error("Required type to invoke is Google for GoogleAuthentication Provider");
|
||||
throw new RuntimeException("Required type to invoke is Google for GoogleAuthentication Provider");
|
||||
}
|
||||
serverConfig = iConfig;
|
||||
|
||||
securityConfig = (GoogleSSOClientConfig) iConfig.getSecurityConfig();
|
||||
if (securityConfig == null) {
|
||||
|
@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class OpenMetadataServerHealthCheck extends HealthCheck {
|
||||
|
||||
@Override
|
||||
protected Result check() throws Exception {
|
||||
protected Result check() {
|
||||
return Result.healthy();
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class DashboardIndex implements ElasticSearchIndex {
|
||||
Dashboard dashboard;
|
||||
final Dashboard dashboard;
|
||||
final List<String> excludeFields = List.of("changeDescription");
|
||||
|
||||
public DashboardIndex(Dashboard dashboard) {
|
||||
|
@ -242,7 +242,6 @@ public class ElasticSearchEventPublisher extends AbstractEventPublisher {
|
||||
|
||||
for (FieldChange fieldChange : changeDescription.getFieldsUpdated()) {
|
||||
if (fieldChange.getName().equalsIgnoreCase(FIELD_USAGE_SUMMARY)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
UsageDetails usageSummary = (UsageDetails) fieldChange.getNewValue();
|
||||
fieldAddParams.put(fieldChange.getName(), JsonUtils.getMap(usageSummary));
|
||||
scriptTxt.append("ctx._source.usageSummary = params.usageSummary;");
|
||||
@ -664,16 +663,14 @@ public class ElasticSearchEventPublisher extends AbstractEventPublisher {
|
||||
|
||||
private void updateElasticSearch(UpdateRequest updateRequest) throws IOException {
|
||||
if (updateRequest != null) {
|
||||
LOG.debug("Sending request to ElasticSearch");
|
||||
LOG.debug(updateRequest.toString());
|
||||
LOG.debug("Sending request to ElasticSearch {}", updateRequest);
|
||||
client.update(updateRequest, RequestOptions.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteEntityFromElasticSearch(DeleteRequest deleteRequest) throws IOException {
|
||||
if (deleteRequest != null) {
|
||||
LOG.debug("Sending request to ElasticSearch");
|
||||
LOG.debug(deleteRequest.toString());
|
||||
LOG.debug("Sending request to ElasticSearch {}", deleteRequest);
|
||||
deleteRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL);
|
||||
client.delete(deleteRequest, RequestOptions.DEFAULT);
|
||||
}
|
||||
@ -681,8 +678,7 @@ public class ElasticSearchEventPublisher extends AbstractEventPublisher {
|
||||
|
||||
private void deleteEntityFromElasticSearchByQuery(DeleteByQueryRequest deleteRequest) throws IOException {
|
||||
if (deleteRequest != null) {
|
||||
LOG.debug("Sending request to ElasticSearch");
|
||||
LOG.debug(deleteRequest.toString());
|
||||
LOG.debug("Sending request to ElasticSearch {}", deleteRequest);
|
||||
deleteRequest.setRefresh(true);
|
||||
client.deleteByQuery(deleteRequest, RequestOptions.DEFAULT);
|
||||
}
|
||||
|
@ -1,8 +1,7 @@
|
||||
package org.openmetadata.service.elasticsearch;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ElasticSearchIndex {
|
||||
public Map<String, Object> buildESDoc() throws JsonProcessingException;
|
||||
Map<String, Object> buildESDoc();
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class GlossaryTermIndex implements ElasticSearchIndex {
|
||||
GlossaryTerm glossaryTerm;
|
||||
final GlossaryTerm glossaryTerm;
|
||||
final List<String> excludeFields = List.of("changeDescription");
|
||||
|
||||
public GlossaryTermIndex(GlossaryTerm glossaryTerm) {
|
||||
|
@ -8,7 +8,7 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class MlModelIndex implements ElasticSearchIndex {
|
||||
MlModel mlModel;
|
||||
final MlModel mlModel;
|
||||
|
||||
public MlModelIndex(MlModel mlModel) {
|
||||
this.mlModel = mlModel;
|
||||
|
@ -9,7 +9,7 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class PipelineIndex implements ElasticSearchIndex {
|
||||
Pipeline pipeline;
|
||||
final Pipeline pipeline;
|
||||
final List<String> excludeFields = List.of("changeDescription");
|
||||
|
||||
public PipelineIndex(Pipeline pipeline) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.service.elasticsearch;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -15,13 +14,13 @@ import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class TableIndex implements ElasticSearchIndex {
|
||||
final List<String> excludeFields = List.of("sampleData", "tableProfile", "joins", "changeDescription");
|
||||
Table table;
|
||||
final Table table;
|
||||
|
||||
public TableIndex(Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public Map<String, Object> buildESDoc() throws JsonProcessingException {
|
||||
public Map<String, Object> buildESDoc() {
|
||||
Map<String, Object> doc = JsonUtils.getMap(table);
|
||||
List<ElasticSearchSuggest> suggest = new ArrayList<>();
|
||||
List<ElasticSearchSuggest> columnSuggest = new ArrayList<>();
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.service.elasticsearch;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -9,13 +8,13 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class TagIndex implements ElasticSearchIndex {
|
||||
Tag tag;
|
||||
final Tag tag;
|
||||
|
||||
public TagIndex(Tag tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
public Map<String, Object> buildESDoc() throws JsonProcessingException {
|
||||
public Map<String, Object> buildESDoc() {
|
||||
Map<String, Object> doc = JsonUtils.getMap(tag);
|
||||
List<ElasticSearchSuggest> suggest = new ArrayList<>();
|
||||
suggest.add(ElasticSearchSuggest.builder().input(tag.getFullyQualifiedName()).weight(5).build());
|
||||
|
@ -8,7 +8,7 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class TeamIndex implements ElasticSearchIndex {
|
||||
Team team;
|
||||
final Team team;
|
||||
final List<String> excludeFields = List.of("owns", "changeDescription", "roles", "inheritedRoles");
|
||||
|
||||
public TeamIndex(Team team) {
|
||||
|
@ -10,7 +10,7 @@ import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class TopicIndex implements ElasticSearchIndex {
|
||||
final List<String> excludeTopicFields = List.of("sampleData");
|
||||
Topic topic;
|
||||
final Topic topic;
|
||||
|
||||
public TopicIndex(Topic topic) {
|
||||
this.topic = topic;
|
||||
|
@ -8,7 +8,7 @@ import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
public class UserIndex implements ElasticSearchIndex {
|
||||
User user;
|
||||
final User user;
|
||||
final List<String> excludeFields = List.of("owns", "changeDescription");
|
||||
|
||||
public UserIndex(User user) {
|
||||
|
@ -59,9 +59,9 @@ public class WebhookPublisher extends AbstractEventPublisher {
|
||||
private final Webhook webhook;
|
||||
private BatchEventProcessor<EventPubSub.ChangeEventHolder> processor;
|
||||
private Client client;
|
||||
private CollectionDAO daoCollection;
|
||||
private final CollectionDAO daoCollection;
|
||||
|
||||
private WebhookRepository webhookRepository;
|
||||
private final WebhookRepository webhookRepository;
|
||||
|
||||
public WebhookPublisher(Webhook webhook, CollectionDAO dao) {
|
||||
super(webhook.getBatchSize(), webhook.getEventFilters());
|
||||
|
@ -29,7 +29,7 @@ public class BotRepository extends EntityRepository<Bot> {
|
||||
|
||||
static final String BOT_UPDATE_FIELDS = "botUser";
|
||||
|
||||
SecretsManager secretsManager;
|
||||
final SecretsManager secretsManager;
|
||||
|
||||
public BotRepository(CollectionDAO dao, SecretsManager secretsManager) {
|
||||
super(BotResource.COLLECTION_PATH, Entity.BOT, Bot.class, dao.botDAO(), dao, "", BOT_UPDATE_FIELDS);
|
||||
|
@ -3096,12 +3096,10 @@ public interface CollectionDAO {
|
||||
settings.setConfigType(configType);
|
||||
Object value = null;
|
||||
try {
|
||||
switch (configType) {
|
||||
case ACTIVITY_FEED_FILTER_SETTING:
|
||||
value = JsonUtils.readValue(json, new TypeReference<ArrayList<EventFilter>>() {});
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Invalid Settings Type");
|
||||
if (configType == SettingsType.ACTIVITY_FEED_FILTER_SETTING) {
|
||||
value = JsonUtils.readValue(json, new TypeReference<ArrayList<EventFilter>>() {});
|
||||
} else {
|
||||
throw new RuntimeException("Invalid Settings Type");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@ -508,7 +508,7 @@ public class FeedRepository {
|
||||
}
|
||||
|
||||
@Transaction
|
||||
public DeleteResponse<Thread> deleteThread(Thread thread, String deletedByUser) throws IOException {
|
||||
public DeleteResponse<Thread> deleteThread(Thread thread, String deletedByUser) {
|
||||
String id = thread.getId().toString();
|
||||
|
||||
// Delete all the relationships to other entities
|
||||
|
@ -43,7 +43,7 @@ public class ReportRepository extends EntityRepository<Report> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(Report report) throws IOException {
|
||||
public void prepare(Report report) {
|
||||
// TODO report does not have service yet
|
||||
setFullyQualifiedName(report);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public abstract class ServiceEntityRepository<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(T service) throws IOException {
|
||||
public void prepare(T service) {
|
||||
setFullyQualifiedName(service);
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class StorageServiceRepository extends EntityRepository<StorageService> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(StorageService entity) throws IOException {
|
||||
public void prepare(StorageService entity) {
|
||||
setFullyQualifiedName(entity);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class TeamRepository extends EntityRepository<Team> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeRelationships(Team team) throws IOException {
|
||||
public void storeRelationships(Team team) {
|
||||
// Add team owner relationship
|
||||
storeOwner(team, team.getOwner());
|
||||
for (EntityReference user : listOrEmpty(team.getUsers())) {
|
||||
|
@ -31,7 +31,7 @@ public class TestDefinitionRepository extends EntityRepository<TestDefinition> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(TestDefinition entity) throws IOException {
|
||||
public void prepare(TestDefinition entity) {
|
||||
setFullyQualifiedName(entity);
|
||||
// validate test platforms
|
||||
if (entity.getTestPlatforms() == null || entity.getTestPlatforms().isEmpty()) {
|
||||
|
@ -36,7 +36,7 @@ public class TestSuiteRepository extends EntityRepository<TestSuite> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare(TestSuite entity) throws IOException {
|
||||
public void prepare(TestSuite entity) {
|
||||
setFullyQualifiedName(entity);
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ public abstract class EntityResource<T extends EntityInterface, K extends Entity
|
||||
return ResourceContext.builder().resource(entityType).entityRepository(dao).name(name).build();
|
||||
}
|
||||
|
||||
public static MetadataOperation[] VIEW_ALL_OPERATIONS = {MetadataOperation.VIEW_ALL};
|
||||
public static final MetadataOperation[] VIEW_ALL_OPERATIONS = {MetadataOperation.VIEW_ALL};
|
||||
|
||||
protected MetadataOperation[] getViewOperations(Fields fields) {
|
||||
return VIEW_ALL_OPERATIONS;
|
||||
|
@ -72,7 +72,7 @@ import org.openmetadata.service.util.ResultList;
|
||||
public class BotResource extends EntityResource<Bot, BotRepository> {
|
||||
public static final String COLLECTION_PATH = "/v1/bots/";
|
||||
|
||||
SecretsManager secretsManager;
|
||||
final SecretsManager secretsManager;
|
||||
|
||||
public BotResource(CollectionDAO dao, Authorizer authorizer, SecretsManager secretsManager) {
|
||||
super(Bot.class, new BotRepository(dao, secretsManager), authorizer);
|
||||
|
@ -91,7 +91,7 @@ public class BuildSearchIndexResource {
|
||||
ElasticSearchClientUtils.createElasticSearchClient(
|
||||
ConfigurationHolder.getInstance()
|
||||
.getConfig(
|
||||
ConfigurationHolder.ConfigurationType.ELASTICSEARCHCONFIG, ElasticSearchConfiguration.class));
|
||||
ConfigurationHolder.ConfigurationType.ELASTICSEARCH_CONFIG, ElasticSearchConfiguration.class));
|
||||
this.dao = dao;
|
||||
this.authorizer = authorizer;
|
||||
this.elasticSearchIndexDefinition = new ElasticSearchIndexDefinition(client, dao);
|
||||
@ -123,8 +123,9 @@ public class BuildSearchIndexResource {
|
||||
@ApiResponse(responseCode = "404", description = "Bot for instance {id} is not found")
|
||||
})
|
||||
public Response reindexAllEntities(
|
||||
@Context UriInfo uriInfo, @Context SecurityContext securityContext, @Valid CreateEventPublisherJob createRequest)
|
||||
throws IOException {
|
||||
@Context UriInfo uriInfo,
|
||||
@Context SecurityContext securityContext,
|
||||
@Valid CreateEventPublisherJob createRequest) {
|
||||
// Only admins can issue a reindex request
|
||||
authorizer.authorizeAdmin(securityContext, false);
|
||||
String startedBy = securityContext.getUserPrincipal().getName();
|
||||
@ -173,10 +174,7 @@ public class BuildSearchIndexResource {
|
||||
private synchronized Response startReindexingStreamMode(
|
||||
UriInfo uriInfo, String startedBy, CreateEventPublisherJob createRequest) {
|
||||
// create a new Job
|
||||
threadScheduler.submit(
|
||||
() -> {
|
||||
this.submitStreamJob(uriInfo, startedBy, createRequest);
|
||||
});
|
||||
threadScheduler.submit(() -> this.submitStreamJob(uriInfo, startedBy, createRequest));
|
||||
return Response.status(Response.Status.OK).entity("Reindexing Started").build();
|
||||
}
|
||||
|
||||
@ -235,27 +233,22 @@ public class BuildSearchIndexResource {
|
||||
|
||||
// Update Listener for only Batch
|
||||
BulkProcessorListener bulkProcessorListener = new BulkProcessorListener(dao);
|
||||
;
|
||||
BulkProcessor processor = getBulkProcessor(bulkProcessorListener);
|
||||
|
||||
try {
|
||||
if (createRequest.getEntities().contains("all")) {
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TABLE, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TOPIC, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, DASHBOARD, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, PIPELINE, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, MLMODEL, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, USER, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TEAM, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, GLOSSARY_TERM, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TAG, createRequest);
|
||||
} else {
|
||||
for (String entityName : createRequest.getEntities()) {
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, entityName, createRequest);
|
||||
}
|
||||
if (createRequest.getEntities().contains("all")) {
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TABLE, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TOPIC, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, DASHBOARD, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, PIPELINE, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, MLMODEL, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, USER, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TEAM, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, GLOSSARY_TERM, createRequest);
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, TAG, createRequest);
|
||||
} else {
|
||||
for (String entityName : createRequest.getEntities()) {
|
||||
updateEntityBatch(processor, bulkProcessorListener, uriInfo, entityName, createRequest);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,8 +257,7 @@ public class BuildSearchIndexResource {
|
||||
BulkProcessorListener listener,
|
||||
UriInfo uriInfo,
|
||||
String entityType,
|
||||
CreateEventPublisherJob createRequest)
|
||||
throws IOException {
|
||||
CreateEventPublisherJob createRequest) {
|
||||
listener.allowTotalRequestUpdate();
|
||||
ElasticSearchIndexDefinition.ElasticSearchIndexType indexType =
|
||||
elasticSearchIndexDefinition.getIndexMappingByEntityType(entityType);
|
||||
@ -389,7 +381,7 @@ public class BuildSearchIndexResource {
|
||||
if (entityType.equals(TABLE)) {
|
||||
((Table) entity).getColumns().forEach(table -> table.setProfile(null));
|
||||
}
|
||||
FailureDetails failureDetails = null;
|
||||
FailureDetails failureDetails;
|
||||
Long time = Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()).getTime();
|
||||
try {
|
||||
client.update(getUpdateRequest(indexType, entityType, entity), RequestOptions.DEFAULT);
|
||||
|
@ -47,7 +47,6 @@ public class BulkProcessorListener implements BulkProcessor.Listener {
|
||||
for (BulkItemResponse bulkItemResponse : bulkResponse) {
|
||||
if (bulkItemResponse.isFailed()) {
|
||||
BulkItemResponse.Failure failure = bulkItemResponse.getFailure();
|
||||
;
|
||||
failureDetails.setLastFailedReason(
|
||||
String.format("ID [%s]. Reason : %s", failure.getId(), failure.getMessage()));
|
||||
failedCount++;
|
||||
|
@ -92,7 +92,7 @@ public class WebhookResource extends EntityResource<Webhook, WebhookRepository>
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // Method used for reflection
|
||||
public void initialize(OpenMetadataApplicationConfig config) throws IOException {
|
||||
public void initialize(OpenMetadataApplicationConfig config) {
|
||||
try {
|
||||
List<String> listAllWebhooks = webhookDAO.listAllWebhooks(webhookDAO.getTableName());
|
||||
List<Webhook> webhookList = JsonUtils.readObjects(listAllWebhooks, Webhook.class);
|
||||
|
@ -239,17 +239,17 @@ public class LineageResource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityReference getOwner() throws IOException {
|
||||
public EntityReference getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagLabel> getTags() throws IOException {
|
||||
public List<TagLabel> getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface getEntity() throws IOException {
|
||||
public EntityInterface getEntity() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.CheckForNull;
|
||||
@ -80,7 +79,7 @@ public class SettingsCache {
|
||||
|
||||
static class SettingsLoader extends CacheLoader<String, Settings> {
|
||||
@Override
|
||||
public Settings load(@CheckForNull String settingsName) throws IOException {
|
||||
public Settings load(@CheckForNull String settingsName) {
|
||||
Settings setting = SETTINGS_REPOSITORY.getConfigWithKey(settingsName);
|
||||
LOG.info("Loaded Setting {}", setting.getConfigType());
|
||||
return setting;
|
||||
|
@ -127,6 +127,7 @@ import org.openmetadata.service.security.policyevaluator.OperationContext;
|
||||
import org.openmetadata.service.security.policyevaluator.ResourceContext;
|
||||
import org.openmetadata.service.security.saml.JwtTokenCacheManager;
|
||||
import org.openmetadata.service.util.ConfigurationHolder;
|
||||
import org.openmetadata.service.util.ConfigurationHolder.ConfigurationType;
|
||||
import org.openmetadata.service.util.EmailUtil;
|
||||
import org.openmetadata.service.util.EntityUtil;
|
||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
||||
@ -178,11 +179,11 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
this.secretsManager = secretsManager;
|
||||
this.providerType =
|
||||
ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHENTICATIONCONFIG, AuthenticationConfiguration.class)
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHENTICATION_CONFIG, AuthenticationConfiguration.class)
|
||||
.getProvider();
|
||||
this.isEmailServiceEnabled =
|
||||
ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.SMTPCONFIG, SmtpSettings.class)
|
||||
.getConfig(ConfigurationType.SMTP_CONFIG, SmtpSettings.class)
|
||||
.getEnableSmtpServer();
|
||||
this.loginAttemptCache = new LoginAttemptCache();
|
||||
}
|
||||
@ -789,7 +790,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
})
|
||||
public Response registerNewUser(@Context UriInfo uriInfo, @Valid RegistrationRequest create) throws IOException {
|
||||
if (ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHENTICATIONCONFIG, AuthenticationConfiguration.class)
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHENTICATION_CONFIG, AuthenticationConfiguration.class)
|
||||
.getEnableSelfSignup()) {
|
||||
User registeredUser = registerUser(uriInfo, create);
|
||||
if (isEmailServiceEnabled) {
|
||||
@ -876,7 +877,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
@ApiResponse(responseCode = "200", description = "The user "),
|
||||
@ApiResponse(responseCode = "400", description = "Bad request")
|
||||
})
|
||||
public Response generateResetPasswordLink(@Context UriInfo uriInfo, @Valid EmailRequest request) throws IOException {
|
||||
public Response generateResetPasswordLink(@Context UriInfo uriInfo, @Valid EmailRequest request) {
|
||||
String userName = request.getEmail().split("@")[0];
|
||||
User registeredUser;
|
||||
try {
|
||||
@ -892,7 +893,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
uriInfo,
|
||||
registeredUser,
|
||||
EmailUtil.getInstance().getPasswordResetSubject(),
|
||||
EmailUtil.PASSWORDRESETTEMPLATEFILE);
|
||||
EmailUtil.PASSWORD_RESET_TEMPLATE_FILE);
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Error in sending mail for reset password" + ex.getMessage());
|
||||
return Response.status(424).entity(new ErrorMessage(424, EMAIL_SENDING_ISSUE)).build();
|
||||
@ -1206,7 +1207,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
String emailDomain = tokens[1];
|
||||
Set<String> allowedDomains =
|
||||
ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHORIZERCONFIG, AuthorizerConfiguration.class)
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHORIZER_CONFIG, AuthorizerConfiguration.class)
|
||||
.getAllowedEmailRegistrationDomains();
|
||||
if (!allowedDomains.contains("all") && !allowedDomains.contains(emailDomain)) {
|
||||
LOG.error("Email with this Domain not allowed: " + newRegistrationRequestEmail);
|
||||
@ -1217,7 +1218,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
LOG.info("Trying to register new user [" + newRegistrationRequestEmail + "]");
|
||||
User newUser = getUserFromRegistrationRequest(newRegistrationRequest);
|
||||
if (ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHORIZERCONFIG, AuthorizerConfiguration.class)
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHORIZER_CONFIG, AuthorizerConfiguration.class)
|
||||
.getAdminPrincipals()
|
||||
.contains(userName)) {
|
||||
newUser.setIsAdmin(true);
|
||||
@ -1286,17 +1287,17 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
Map<String, String> templatePopulator = new HashMap<>();
|
||||
|
||||
templatePopulator.put(EmailUtil.ENTITY, EmailUtil.getInstance().getEmailingEntity());
|
||||
templatePopulator.put(EmailUtil.SUPPORTURL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.SUPPORT_URL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.USERNAME, user.getName());
|
||||
templatePopulator.put(EmailUtil.EMAILVERIFICATIONLINKKEY, emailVerificationLink);
|
||||
templatePopulator.put(EmailUtil.EXPIRATIONTIMEKEY, "24");
|
||||
templatePopulator.put(EmailUtil.EMAIL_VERIFICATION_LINKKEY, emailVerificationLink);
|
||||
templatePopulator.put(EmailUtil.EXPIRATION_TIME_KEY, "24");
|
||||
EmailUtil.getInstance()
|
||||
.sendMail(
|
||||
EmailUtil.getInstance().getEmailVerificationSubject(),
|
||||
templatePopulator,
|
||||
user.getEmail(),
|
||||
EmailUtil.EMAILTEMPLATEBASEPATH,
|
||||
EmailUtil.EMAILVERIFICATIONTEMPLATEPATH);
|
||||
EmailUtil.EMAIL_TEMPLATE_BASEPATH,
|
||||
EmailUtil.EMAIL_VERIFICATION_TEMPLATE_PATH);
|
||||
|
||||
// insert the token
|
||||
tokenRepository.insertToken(emailVerificationToken);
|
||||
@ -1305,17 +1306,17 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
private void sendAccountStatus(User user, String action, String status) throws IOException, TemplateException {
|
||||
Map<String, String> templatePopulator = new HashMap<>();
|
||||
templatePopulator.put(EmailUtil.ENTITY, EmailUtil.getInstance().getEmailingEntity());
|
||||
templatePopulator.put(EmailUtil.SUPPORTURL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.SUPPORT_URL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.USERNAME, user.getName());
|
||||
templatePopulator.put(EmailUtil.ACTIONKEY, action);
|
||||
templatePopulator.put(EmailUtil.ACTIONSTATUSKEY, status);
|
||||
templatePopulator.put(EmailUtil.ACTION_KEY, action);
|
||||
templatePopulator.put(EmailUtil.ACTION_STATUS_KEY, status);
|
||||
EmailUtil.getInstance()
|
||||
.sendMail(
|
||||
EmailUtil.getInstance().getAccountStatusChangeSubject(),
|
||||
templatePopulator,
|
||||
user.getEmail(),
|
||||
EmailUtil.EMAILTEMPLATEBASEPATH,
|
||||
EmailUtil.ACCOUNTSTATUSTEMPLATEFILE);
|
||||
EmailUtil.EMAIL_TEMPLATE_BASEPATH,
|
||||
EmailUtil.ACCOUNT_STATUS_TEMPLATE_FILE);
|
||||
}
|
||||
|
||||
private void sendPasswordResetLink(UriInfo uriInfo, User user, String subject, String templateFilePath)
|
||||
@ -1334,13 +1335,13 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
mailVerificationToken);
|
||||
Map<String, String> templatePopulator = new HashMap<>();
|
||||
templatePopulator.put(EmailUtil.ENTITY, EmailUtil.getInstance().getEmailingEntity());
|
||||
templatePopulator.put(EmailUtil.SUPPORTURL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.SUPPORT_URL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.USERNAME, user.getName());
|
||||
templatePopulator.put(EmailUtil.PASSWORDRESETLINKKEY, passwordResetLink);
|
||||
templatePopulator.put(EmailUtil.EXPIRATIONTIMEKEY, EmailUtil.DEFAULTEXPIRATIONTIME);
|
||||
templatePopulator.put(EmailUtil.PASSWORD_RESET_LINKKEY, passwordResetLink);
|
||||
templatePopulator.put(EmailUtil.EXPIRATION_TIME_KEY, EmailUtil.DEFAULT_EXPIRATION_TIME);
|
||||
|
||||
EmailUtil.getInstance()
|
||||
.sendMail(subject, templatePopulator, user.getEmail(), EmailUtil.EMAILTEMPLATEBASEPATH, templateFilePath);
|
||||
.sendMail(subject, templatePopulator, user.getEmail(), EmailUtil.EMAIL_TEMPLATE_BASEPATH, templateFilePath);
|
||||
// don't persist tokens delete existing
|
||||
tokenRepository.deleteTokenByUserAndType(user.getId().toString(), PASSWORD_RESET.toString());
|
||||
tokenRepository.insertToken(resetToken);
|
||||
@ -1353,7 +1354,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
case ADMINCREATE:
|
||||
Map<String, String> templatePopulator = new HashMap<>();
|
||||
templatePopulator.put(EmailUtil.ENTITY, EmailUtil.getInstance().getEmailingEntity());
|
||||
templatePopulator.put(EmailUtil.SUPPORTURL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.SUPPORT_URL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.USERNAME, user.getName());
|
||||
templatePopulator.put(EmailUtil.PASSWORD, pwd);
|
||||
templatePopulator.put(EmailUtil.APPLICATION_LOGIN_LINK, EmailUtil.getInstance().getOMUrl());
|
||||
@ -1363,7 +1364,7 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
||||
subject,
|
||||
templatePopulator,
|
||||
user.getEmail(),
|
||||
EmailUtil.EMAILTEMPLATEBASEPATH,
|
||||
EmailUtil.EMAIL_TEMPLATE_BASEPATH,
|
||||
EmailUtil.INVITE_RANDOM_PWD);
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Failed in sending Mail to user [{}]. Reason : {}", user.getEmail(), ex.getMessage());
|
||||
|
@ -77,7 +77,7 @@ import org.openmetadata.service.util.RestUtil;
|
||||
|
||||
@Slf4j
|
||||
public class DefaultAuthorizer implements Authorizer {
|
||||
private static final String COLONDELIMETER = ":";
|
||||
private static final String COLON_DELIMITER = ":";
|
||||
private static final String DEFAULT_ADMIN = ADMIN_USER_NAME;
|
||||
private Set<String> adminUsers;
|
||||
private Set<String> botPrincipalUsers;
|
||||
@ -111,7 +111,7 @@ public class DefaultAuthorizer implements Authorizer {
|
||||
LOG.debug("Checking user entries for admin users");
|
||||
String domain = principalDomain.isEmpty() ? DEFAULT_PRINCIPAL_DOMAIN : principalDomain;
|
||||
if (!ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHENTICATIONCONFIG, AuthenticationConfiguration.class)
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.AUTHENTICATION_CONFIG, AuthenticationConfiguration.class)
|
||||
.getProvider()
|
||||
.equals(SSOAuthMechanism.SsoServiceType.BASIC.value())) {
|
||||
for (String adminUser : adminUsers) {
|
||||
@ -154,8 +154,8 @@ public class DefaultAuthorizer implements Authorizer {
|
||||
|
||||
private void handleBasicAuth(Set<String> adminUsers, String domain) throws IOException {
|
||||
for (String adminUser : adminUsers) {
|
||||
if (adminUser.contains(COLONDELIMETER)) {
|
||||
String[] tokens = adminUser.split(COLONDELIMETER);
|
||||
if (adminUser.contains(COLON_DELIMITER)) {
|
||||
String[] tokens = adminUser.split(COLON_DELIMITER);
|
||||
addUserForBasicAuth(tokens[0], tokens[1], domain);
|
||||
} else {
|
||||
boolean isDefaultAdmin = adminUser.equals(DEFAULT_ADMIN);
|
||||
@ -188,7 +188,7 @@ public class DefaultAuthorizer implements Authorizer {
|
||||
private void sendInviteMailToAdmin(User user, String pwd) {
|
||||
Map<String, String> templatePopulator = new HashMap<>();
|
||||
templatePopulator.put(EmailUtil.ENTITY, EmailUtil.getInstance().getEmailingEntity());
|
||||
templatePopulator.put(EmailUtil.SUPPORTURL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.SUPPORT_URL, EmailUtil.getInstance().getSupportUrl());
|
||||
templatePopulator.put(EmailUtil.USERNAME, user.getName());
|
||||
templatePopulator.put(EmailUtil.PASSWORD, pwd);
|
||||
templatePopulator.put(EmailUtil.APPLICATION_LOGIN_LINK, EmailUtil.getInstance().getOMUrl());
|
||||
@ -198,7 +198,7 @@ public class DefaultAuthorizer implements Authorizer {
|
||||
EmailUtil.getInstance().getEmailInviteSubject(),
|
||||
templatePopulator,
|
||||
user.getEmail(),
|
||||
EmailUtil.EMAILTEMPLATEBASEPATH,
|
||||
EmailUtil.EMAIL_TEMPLATE_BASEPATH,
|
||||
EmailUtil.INVITE_RANDOM_PWD);
|
||||
} catch (Exception ex) {
|
||||
LOG.error("Failed in sending Mail to user [{}]. Reason : {}", user.getEmail(), ex.getMessage());
|
||||
@ -340,10 +340,6 @@ public class DefaultAuthorizer implements Authorizer {
|
||||
* </ul>
|
||||
* </ul>
|
||||
* </ul>
|
||||
*
|
||||
* @param user the user
|
||||
* @param openMetadataApplicationConfig the OM config
|
||||
* @return enriched user
|
||||
*/
|
||||
private User addOrUpdateBotUser(User user, OpenMetadataApplicationConfig openMetadataApplicationConfig) {
|
||||
User originalUser = retrieveAuthMechanism(user);
|
||||
|
@ -16,7 +16,7 @@ public class LoginAttemptCache {
|
||||
super();
|
||||
LoginConfiguration loginConfiguration =
|
||||
ConfigurationHolder.getInstance()
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.LOGINCONFIG, LoginConfiguration.class);
|
||||
.getConfig(ConfigurationHolder.ConfigurationType.LOGIN_CONFIG, LoginConfiguration.class);
|
||||
MAX_ATTEMPT = 3;
|
||||
attemptsCache =
|
||||
CacheBuilder.newBuilder()
|
||||
|
@ -27,10 +27,10 @@ import org.openmetadata.service.security.AuthenticationException;
|
||||
|
||||
@Slf4j
|
||||
public class JWTTokenGenerator {
|
||||
private static final String subjectClaim = "sub";
|
||||
private static final String emailClaim = "email";
|
||||
private static final String isBotClaim = "isBot";
|
||||
private static JWTTokenGenerator instance = new JWTTokenGenerator();
|
||||
private static final String SUBJECT_CLAIM = "sub";
|
||||
private static final String EMAIL_CLAIM = "email";
|
||||
private static final String IS_BOT_CLAIM = "isBot";
|
||||
private static final JWTTokenGenerator INSTANCE = new JWTTokenGenerator();
|
||||
private RSAPrivateKey privateKey;
|
||||
@Getter private RSAPublicKey publicKey;
|
||||
private String issuer;
|
||||
@ -39,7 +39,7 @@ public class JWTTokenGenerator {
|
||||
private JWTTokenGenerator() {}
|
||||
|
||||
public static JWTTokenGenerator getInstance() {
|
||||
return instance;
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/** Expected to be initialized only once during application start */
|
||||
@ -74,9 +74,9 @@ public class JWTTokenGenerator {
|
||||
JWT.create()
|
||||
.withIssuer(issuer)
|
||||
.withKeyId(kid)
|
||||
.withClaim(subjectClaim, user.getName())
|
||||
.withClaim(emailClaim, user.getEmail())
|
||||
.withClaim(isBotClaim, true)
|
||||
.withClaim(SUBJECT_CLAIM, user.getName())
|
||||
.withClaim(EMAIL_CLAIM, user.getEmail())
|
||||
.withClaim(IS_BOT_CLAIM, true)
|
||||
.withIssuedAt(new Date(System.currentTimeMillis()))
|
||||
.withExpiresAt(expires)
|
||||
.sign(algorithm);
|
||||
@ -97,9 +97,9 @@ public class JWTTokenGenerator {
|
||||
JWT.create()
|
||||
.withIssuer(issuer)
|
||||
.withKeyId(kid)
|
||||
.withClaim(subjectClaim, userName)
|
||||
.withClaim(emailClaim, email)
|
||||
.withClaim(isBotClaim, isBot)
|
||||
.withClaim(SUBJECT_CLAIM, userName)
|
||||
.withClaim(EMAIL_CLAIM, email)
|
||||
.withClaim(IS_BOT_CLAIM, isBot)
|
||||
.withIssuedAt(new Date(System.currentTimeMillis()))
|
||||
.withExpiresAt(expires)
|
||||
.sign(algorithm);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.service.security.policyevaluator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.openmetadata.schema.EntityInterface;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
@ -9,7 +8,7 @@ import org.openmetadata.service.Entity;
|
||||
|
||||
/** Posts that are part of conversation threads require special handling */
|
||||
public class PostResourceContext implements ResourceContextInterface {
|
||||
private EntityReference owner;
|
||||
private final EntityReference owner;
|
||||
|
||||
public PostResourceContext(EntityReference owner) {
|
||||
this.owner = owner;
|
||||
@ -21,17 +20,17 @@ public class PostResourceContext implements ResourceContextInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityReference getOwner() throws IOException {
|
||||
public EntityReference getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagLabel> getTags() throws IOException {
|
||||
public List<TagLabel> getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface getEntity() throws IOException {
|
||||
public EntityInterface getEntity() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.openmetadata.service.security.policyevaluator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.openmetadata.schema.EntityInterface;
|
||||
import org.openmetadata.schema.type.EntityReference;
|
||||
@ -21,17 +20,17 @@ public class ThreadResourceContext implements ResourceContextInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityReference getOwner() throws IOException {
|
||||
public EntityReference getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TagLabel> getTags() throws IOException {
|
||||
public List<TagLabel> getTags() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityInterface getEntity() throws IOException {
|
||||
public EntityInterface getEntity() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -78,5 +78,5 @@ public class SocketAddressFilter implements Filter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {}
|
||||
public void init(FilterConfig filterConfig) {}
|
||||
}
|
||||
|
@ -9,13 +9,13 @@ import org.openmetadata.service.OpenMetadataApplicationConfig;
|
||||
@Slf4j
|
||||
public class ConfigurationHolder {
|
||||
public enum ConfigurationType {
|
||||
AUTHORIZERCONFIG("authorizerConfiguration"),
|
||||
AUTHENTICATIONCONFIG("authenticationConfiguration"),
|
||||
SMTPCONFIG("email"),
|
||||
ELASTICSEARCHCONFIG("elasticsearch"),
|
||||
LOGINCONFIG("login");
|
||||
AUTHORIZER_CONFIG("authorizerConfiguration"),
|
||||
AUTHENTICATION_CONFIG("authenticationConfiguration"),
|
||||
SMTP_CONFIG("email"),
|
||||
ELASTICSEARCH_CONFIG("elasticsearch"),
|
||||
LOGIN_CONFIG("login");
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
ConfigurationType(String value) {
|
||||
this.value = value;
|
||||
@ -52,20 +52,20 @@ public class ConfigurationHolder {
|
||||
ConfigurationType configTypeForEnum = ConfigurationType.fromValue(configType);
|
||||
if (configTypeForEnum == null) continue;
|
||||
switch (configTypeForEnum) {
|
||||
case AUTHORIZERCONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.AUTHORIZERCONFIG, config.getAuthorizerConfiguration());
|
||||
case AUTHORIZER_CONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.AUTHORIZER_CONFIG, config.getAuthorizerConfiguration());
|
||||
break;
|
||||
case AUTHENTICATIONCONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.AUTHENTICATIONCONFIG, config.getAuthenticationConfiguration());
|
||||
case AUTHENTICATION_CONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.AUTHENTICATION_CONFIG, config.getAuthenticationConfiguration());
|
||||
break;
|
||||
case SMTPCONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.SMTPCONFIG, config.getSmtpSettings());
|
||||
case SMTP_CONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.SMTP_CONFIG, config.getSmtpSettings());
|
||||
break;
|
||||
case ELASTICSEARCHCONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.ELASTICSEARCHCONFIG, config.getElasticSearchConfiguration());
|
||||
case ELASTICSEARCH_CONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.ELASTICSEARCH_CONFIG, config.getElasticSearchConfiguration());
|
||||
break;
|
||||
case LOGINCONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.LOGINCONFIG, config.getLoginSettings());
|
||||
case LOGIN_CONFIG:
|
||||
CONFIG_MAP.put(ConfigurationType.LOGIN_CONFIG, config.getLoginSettings());
|
||||
break;
|
||||
default:
|
||||
LOG.error("Invalid Setting Type Given.");
|
||||
|
@ -25,26 +25,26 @@ import org.simplejavamail.mailer.MailerBuilder;
|
||||
public class EmailUtil {
|
||||
public static final String USERNAME = "userName";
|
||||
public static final String ENTITY = "entity";
|
||||
public static final String SUPPORTURL = "supportUrl";
|
||||
public static final String EMAILTEMPLATEBASEPATH = "/emailTemplates";
|
||||
public static final String SUPPORT_URL = "supportUrl";
|
||||
public static final String EMAIL_TEMPLATE_BASEPATH = "/emailTemplates";
|
||||
// Email Verification
|
||||
private static final String EMAILVERIFICATIONSUBJECT = "%s: Verify your Email Address (Action Required)";
|
||||
public static final String EMAILVERIFICATIONLINKKEY = "userEmailTokenVerificationLink";
|
||||
public static final String EMAILVERIFICATIONTEMPLATEPATH = "email-verification.ftl";
|
||||
private static final String EMAIL_VERIFICATION_SUBJECT = "%s: Verify your Email Address (Action Required)";
|
||||
public static final String EMAIL_VERIFICATION_LINKKEY = "userEmailTokenVerificationLink";
|
||||
public static final String EMAIL_VERIFICATION_TEMPLATE_PATH = "email-verification.ftl";
|
||||
// Password Reset Link
|
||||
private static final String PASSWORDRESETSUBJECT = "%s: Reset your Password";
|
||||
public static final String PASSWORDRESETLINKKEY = "userResetPasswordLink";
|
||||
public static final String EXPIRATIONTIMEKEY = "expirationTime";
|
||||
public static final String DEFAULTEXPIRATIONTIME = "60";
|
||||
private static final String PASSWORD_RESET_SUBJECT = "%s: Reset your Password";
|
||||
public static final String PASSWORD_RESET_LINKKEY = "userResetPasswordLink";
|
||||
public static final String EXPIRATION_TIME_KEY = "expirationTime";
|
||||
public static final String DEFAULT_EXPIRATION_TIME = "60";
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String APPLICATION_LOGIN_LINK = "applicationLoginLink";
|
||||
|
||||
public static final String PASSWORDRESETTEMPLATEFILE = "reset-link.ftl";
|
||||
public static final String PASSWORD_RESET_TEMPLATE_FILE = "reset-link.ftl";
|
||||
// Account Change Status
|
||||
private static final String ACCOUNTSTATUSSUBJECT = "%s: Change in Account Status";
|
||||
public static final String ACTIONKEY = "action";
|
||||
public static final String ACTIONSTATUSKEY = "actionStatus";
|
||||
public static final String ACCOUNTSTATUSTEMPLATEFILE = "account-activity-change.ftl";
|
||||
private static final String ACCOUNT_STATUS_SUBJECT = "%s: Change in Account Status";
|
||||
public static final String ACTION_KEY = "action";
|
||||
public static final String ACTION_STATUS_KEY = "actionStatus";
|
||||
public static final String ACCOUNT_STATUS_TEMPLATE_FILE = "account-activity-change.ftl";
|
||||
|
||||
private static final String INVITE_SUBJECT = "Welcome to %s";
|
||||
|
||||
@ -278,15 +278,15 @@ public class EmailUtil {
|
||||
}
|
||||
|
||||
public String getEmailVerificationSubject() {
|
||||
return String.format(EMAILVERIFICATIONSUBJECT, defaultSmtpSettings.getEmailingEntity());
|
||||
return String.format(EMAIL_VERIFICATION_SUBJECT, defaultSmtpSettings.getEmailingEntity());
|
||||
}
|
||||
|
||||
public String getPasswordResetSubject() {
|
||||
return String.format(PASSWORDRESETSUBJECT, defaultSmtpSettings.getEmailingEntity());
|
||||
return String.format(PASSWORD_RESET_SUBJECT, defaultSmtpSettings.getEmailingEntity());
|
||||
}
|
||||
|
||||
public String getAccountStatusChangeSubject() {
|
||||
return String.format(ACCOUNTSTATUSSUBJECT, defaultSmtpSettings.getEmailingEntity());
|
||||
return String.format(ACCOUNT_STATUS_SUBJECT, defaultSmtpSettings.getEmailingEntity());
|
||||
}
|
||||
|
||||
public String getEmailInviteSubject() {
|
||||
|
@ -176,7 +176,6 @@ public class FilterUtil {
|
||||
|
||||
public static List<EventFilter> getEventFilterFromSettings(Settings setting) throws IOException {
|
||||
String json = JsonUtils.pojoToJson(setting.getConfigValue());
|
||||
List<EventFilter> eventFilterList = JsonUtils.readValue(json, new TypeReference<ArrayList<EventFilter>>() {});
|
||||
return eventFilterList;
|
||||
return JsonUtils.readValue(json, new TypeReference<ArrayList<EventFilter>>() {});
|
||||
}
|
||||
}
|
||||
|
@ -416,20 +416,12 @@ public final class JsonUtils {
|
||||
return Paths.get(path).getParent().getFileName().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize object removing all the fields annotated with @{@link MaskedField}
|
||||
*
|
||||
* @return Serialized JSON string
|
||||
*/
|
||||
/** Serialize object removing all the fields annotated with @{@link MaskedField} */
|
||||
public static String pojoToMaskedJson(Object entity) throws JsonProcessingException {
|
||||
return MASKER_OBJECT_MAPPER.writeValueAsString(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize object removing all the fields annotated with @{@link ExposedField}
|
||||
*
|
||||
* @return Object if the serialization of `entity` does not result in an empty JSON string.
|
||||
*/
|
||||
/** Serialize object removing all the fields annotated with @{@link ExposedField} */
|
||||
public static <T> T toExposedEntity(Object entity, Class<T> clazz) throws IOException {
|
||||
String jsonString = EXPOSED_OBJECT_MAPPER.writeValueAsString(entity);
|
||||
return EXPOSED_OBJECT_MAPPER.readValue(jsonString, clazz);
|
||||
@ -448,14 +440,7 @@ public final class JsonUtils {
|
||||
return OBJECT_MAPPER.readTree(extensionJson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compared the canonicalized JSON representation of two object to check if they are equals or not
|
||||
*
|
||||
* @param obj1
|
||||
* @param obj2
|
||||
* @return True if the representations are equal, otherwise, false
|
||||
* @throws JsonProcessingException if the Object mapper fails
|
||||
*/
|
||||
/** Compared the canonicalized JSON representation of two object to check if they are equals or not */
|
||||
public static boolean areEquals(Object obj1, Object obj2) throws JsonProcessingException {
|
||||
ObjectMapper mapper = JsonMapper.builder().nodeFactory(new SortedNodeFactory()).build();
|
||||
JsonNode obj1sorted = mapper.reader().with(StreamReadFeature.STRICT_DUPLICATE_DETECTION).readTree(pojoToJson(obj1));
|
||||
|
@ -20,6 +20,7 @@ import org.openmetadata.service.exception.EntityNotFoundException;
|
||||
import org.openmetadata.service.jdbi3.BotRepository;
|
||||
import org.openmetadata.service.jdbi3.UserRepository;
|
||||
import org.openmetadata.service.secrets.SecretsManager;
|
||||
import org.openmetadata.service.util.EntityUtil.Fields;
|
||||
|
||||
@Slf4j
|
||||
public class OpenMetadataServerConnectionBuilder {
|
||||
@ -27,14 +28,14 @@ public class OpenMetadataServerConnectionBuilder {
|
||||
OpenMetadataServerConnection.AuthProvider authProvider;
|
||||
String bot;
|
||||
Object securityConfig;
|
||||
OpenMetadataServerConnection.VerifySSL verifySSL;
|
||||
String openMetadataURL;
|
||||
String clusterName;
|
||||
SecretsManagerProvider secretsManagerProvider;
|
||||
Object airflowSSLConfig;
|
||||
private final OpenMetadataServerConnection.VerifySSL verifySSL;
|
||||
private final String openMetadataURL;
|
||||
private final String clusterName;
|
||||
private final SecretsManagerProvider secretsManagerProvider;
|
||||
private final Object airflowSSLConfig;
|
||||
BotRepository botRepository;
|
||||
UserRepository userRepository;
|
||||
SecretsManager secretsManager;
|
||||
private final SecretsManager secretsManager;
|
||||
|
||||
public OpenMetadataServerConnectionBuilder(
|
||||
SecretsManager secretsManager, OpenMetadataApplicationConfig openMetadataApplicationConfig) {
|
||||
@ -118,14 +119,14 @@ public class OpenMetadataServerConnectionBuilder {
|
||||
|
||||
private User retrieveIngestionBotUser(String botName) {
|
||||
try {
|
||||
Bot bot = botRepository.getByName(null, botName, EntityUtil.Fields.EMPTY_FIELDS);
|
||||
if (bot.getBotUser() == null) {
|
||||
Bot bot1 = botRepository.getByName(null, botName, Fields.EMPTY_FIELDS);
|
||||
if (bot1.getBotUser() == null) {
|
||||
return null;
|
||||
}
|
||||
User user =
|
||||
userRepository.getByName(
|
||||
null,
|
||||
bot.getBotUser().getFullyQualifiedName(),
|
||||
bot1.getBotUser().getFullyQualifiedName(),
|
||||
new EntityUtil.Fields(List.of("authenticationMechanism")));
|
||||
if (user.getAuthenticationMechanism() != null) {
|
||||
user.getAuthenticationMechanism()
|
||||
@ -140,12 +141,6 @@ public class OpenMetadataServerConnectionBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private void addBotNameIfUserExists(User botUser, String bot) {
|
||||
if (botUser != null) {
|
||||
this.bot = bot;
|
||||
}
|
||||
}
|
||||
|
||||
protected Object getAirflowSSLConfig(OpenMetadataServerConnection.VerifySSL verifySSL, SSLConfig sslConfig) {
|
||||
switch (verifySSL) {
|
||||
case NO_SSL:
|
||||
|
@ -17,7 +17,7 @@ import org.passay.WhitespaceRule;
|
||||
|
||||
public class PasswordUtil {
|
||||
|
||||
private static PasswordValidator validator;
|
||||
private static final PasswordValidator VALIDATOR;
|
||||
|
||||
static {
|
||||
List<Rule> rules = new ArrayList<>();
|
||||
@ -33,14 +33,14 @@ public class PasswordUtil {
|
||||
rules.add(new CharacterRule(EnglishCharacterData.Digit, 1));
|
||||
// Rule 3.d: At least one special character
|
||||
rules.add(new CharacterRule(EnglishCharacterData.Special, 1));
|
||||
validator = new PasswordValidator(rules);
|
||||
VALIDATOR = new PasswordValidator(rules);
|
||||
}
|
||||
|
||||
private PasswordUtil() {}
|
||||
|
||||
public static void validatePassword(String pwd) {
|
||||
PasswordData password = new PasswordData(pwd);
|
||||
RuleResult result = validator.validate(password);
|
||||
RuleResult result = VALIDATOR.validate(password);
|
||||
if (!result.isValid()) {
|
||||
throw new RuntimeException(PASSWORD_INVALID_FORMAT);
|
||||
}
|
||||
@ -73,7 +73,6 @@ public class PasswordUtil {
|
||||
CharacterRule splCharRule = new CharacterRule(specialChars);
|
||||
splCharRule.setNumberOfCharacters(2);
|
||||
|
||||
String password = gen.generatePassword(8, splCharRule, lowerCaseRule, upperCaseRule, digitRule);
|
||||
return password;
|
||||
return gen.generatePassword(8, splCharRule, lowerCaseRule, upperCaseRule, digitRule);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.openmetadata.service.exception.PipelineServiceVersionException;
|
||||
|
||||
public class PipelineServiceClientTest {
|
||||
|
||||
MockPipelineServiceClient mockPipelineServiceClient =
|
||||
final MockPipelineServiceClient mockPipelineServiceClient =
|
||||
new MockPipelineServiceClient("user", "password", "https://endpoint.com", "111.11.11.1", 10);
|
||||
|
||||
@Test
|
||||
|
@ -44,7 +44,7 @@ public class HttpServerExtension implements BeforeAllCallback, AfterAllCallback
|
||||
private com.sun.net.httpserver.HttpServer server;
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext extensionContext) throws Exception {
|
||||
public void afterAll(ExtensionContext extensionContext) {
|
||||
if (server != null) {
|
||||
server.stop(0);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import org.apache.commons.io.IOUtils;
|
||||
|
||||
class JsonHandler implements HttpHandler {
|
||||
|
||||
Map<String, MockResponse> pathResponses;
|
||||
final Map<String, MockResponse> pathResponses;
|
||||
|
||||
public JsonHandler(Map<String, MockResponse> pathResponses) {
|
||||
this.pathResponses = pathResponses;
|
||||
|
@ -167,7 +167,7 @@ public abstract class EntityResourceTest<T extends EntityInterface, K extends Cr
|
||||
protected boolean supportsOwner;
|
||||
protected final boolean supportsTags;
|
||||
protected boolean supportsPatch = true;
|
||||
protected boolean supportsSoftDelete;
|
||||
protected final boolean supportsSoftDelete;
|
||||
protected boolean supportsAuthorizedMetadataOperations = true;
|
||||
protected boolean supportsFieldsQueryParam = true;
|
||||
protected boolean supportsEmptyDescription = true;
|
||||
|
@ -53,7 +53,7 @@ public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
||||
}
|
||||
|
||||
@Test
|
||||
void put_entityNonEmptyDescriptionUpdate_200(TestInfo test) throws IOException {
|
||||
void put_entityNonEmptyDescriptionUpdate_200(TestInfo test) {
|
||||
// PUT based updates are categorized as create operation
|
||||
// PUT from a bot to update itself is rejected because of that
|
||||
// TODO turning off the test for now which requires BOT to make update using PUT
|
||||
@ -90,7 +90,7 @@ public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
||||
}
|
||||
|
||||
@Test
|
||||
void put_failIfUserIsNotBot(TestInfo test) throws IOException {
|
||||
void put_failIfUserIsNotBot(TestInfo test) {
|
||||
// create a non bot user
|
||||
User testUser = new UserResourceTest().createUser("bot-test-user", false);
|
||||
EntityReference userRef = Objects.requireNonNull(testUser).getEntityReference();
|
||||
@ -125,23 +125,22 @@ public class BotResourceTest extends EntityResourceTest<Bot, CreateBot> {
|
||||
|
||||
@SneakyThrows // TODO remove
|
||||
@Override
|
||||
public void validateCreatedEntity(Bot entity, CreateBot request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(Bot entity, CreateBot request, Map<String, String> authHeaders) {
|
||||
assertReference(request.getBotUser(), entity.getBotUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(Bot expected, Bot updated, Map<String, String> authHeaders) throws HttpResponseException {
|
||||
public void compareEntities(Bot expected, Bot updated, Map<String, String> authHeaders) {
|
||||
assertReference(expected.getBotUser(), updated.getBotUser());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bot validateGetWithDifferentFields(Bot entity, boolean byName) throws HttpResponseException {
|
||||
public Bot validateGetWithDifferentFields(Bot entity, boolean byName) {
|
||||
return entity; // TODO cleanup
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) throws IOException {}
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) {}
|
||||
|
||||
private void createUser() {
|
||||
botUser = new UserResourceTest().createUser("botUser", true);
|
||||
|
@ -2143,10 +2143,6 @@ public class TableResourceTest extends EntityResourceTest<Table, CreateTable> {
|
||||
}
|
||||
|
||||
private void validateTableConstraints(List<TableConstraint> expected, List<TableConstraint> actual) {
|
||||
if (expected == null || actual == null) {
|
||||
assertEquals(expected, actual);
|
||||
return;
|
||||
}
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
||||
|
@ -494,8 +494,7 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
}
|
||||
|
||||
private void verifyTestCases(
|
||||
ResultList<TestCase> actualTestCases, List<CreateTestCase> expectedTestCases, int expectedCount)
|
||||
throws HttpResponseException {
|
||||
ResultList<TestCase> actualTestCases, List<CreateTestCase> expectedTestCases, int expectedCount) {
|
||||
assertEquals(expectedCount, actualTestCases.getPaging().getTotal());
|
||||
assertEquals(expectedTestCases.size(), actualTestCases.getData().size());
|
||||
Map<String, TestCase> testCaseMap = new HashMap<>();
|
||||
@ -523,8 +522,7 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(TestCase createdEntity, CreateTestCase request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(TestCase createdEntity, CreateTestCase request, Map<String, String> authHeaders) {
|
||||
validateCommonEntityFields(createdEntity, request, getPrincipalName(authHeaders));
|
||||
assertEquals(request.getEntityLink(), createdEntity.getEntityLink());
|
||||
assertEquals(request.getTestSuite(), createdEntity.getTestSuite());
|
||||
@ -534,8 +532,7 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(TestCase expected, TestCase updated, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(TestCase expected, TestCase updated, Map<String, String> authHeaders) {
|
||||
validateCommonEntityFields(expected, updated, getPrincipalName(authHeaders));
|
||||
assertEquals(expected.getEntityLink(), updated.getEntityLink());
|
||||
assertEquals(expected.getTestSuite(), updated.getTestSuite());
|
||||
@ -545,13 +542,13 @@ public class TestCaseResourceTest extends EntityResourceTest<TestCase, CreateTes
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestCase validateGetWithDifferentFields(TestCase entity, boolean byName) throws HttpResponseException {
|
||||
public TestCase validateGetWithDifferentFields(TestCase entity, boolean byName) {
|
||||
// TODO fix this
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) throws IOException {
|
||||
public void assertFieldChange(String fieldName, Object expected, Object actual) {
|
||||
if (expected == actual) {
|
||||
return;
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.http.client.HttpResponseException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.openmetadata.schema.api.tests.CreateTestDefinition;
|
||||
@ -71,24 +70,21 @@ public class TestDefinitionResourceTest extends EntityResourceTest<TestDefinitio
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(
|
||||
TestDefinition createdEntity, CreateTestDefinition request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
TestDefinition createdEntity, CreateTestDefinition request, Map<String, String> authHeaders) {
|
||||
assertEquals(request.getName(), createdEntity.getName());
|
||||
assertEquals(request.getDescription(), createdEntity.getDescription());
|
||||
assertEquals(request.getTestPlatforms(), createdEntity.getTestPlatforms());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(TestDefinition expected, TestDefinition updated, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(TestDefinition expected, TestDefinition updated, Map<String, String> authHeaders) {
|
||||
assertEquals(expected.getName(), updated.getName());
|
||||
assertEquals(expected.getDescription(), updated.getDescription());
|
||||
assertEquals(expected.getTestPlatforms(), updated.getTestPlatforms());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestDefinition validateGetWithDifferentFields(TestDefinition entity, boolean byName)
|
||||
throws HttpResponseException {
|
||||
public TestDefinition validateGetWithDifferentFields(TestDefinition entity, boolean byName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ import static org.openmetadata.service.util.TestUtils.ADMIN_AUTH_HEADERS;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -62,7 +61,7 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
||||
}
|
||||
|
||||
@Test
|
||||
void put_testCaseResults_200(TestInfo test) throws IOException, ParseException {
|
||||
void put_testCaseResults_200(TestInfo test) throws IOException {
|
||||
TestCaseResourceTest testCaseResourceTest = new TestCaseResourceTest();
|
||||
List<EntityReference> testCases1 = new ArrayList<>();
|
||||
List<EntityReference> testCases2 = new ArrayList<>();
|
||||
@ -113,8 +112,7 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
||||
return TestUtils.get(target, TestSuiteResource.TestSuiteList.class, authHeaders);
|
||||
}
|
||||
|
||||
private void verifyTestSuites(ResultList<TestSuite> actualTestSuites, List<CreateTestSuite> expectedTestSuites)
|
||||
throws HttpResponseException {
|
||||
private void verifyTestSuites(ResultList<TestSuite> actualTestSuites, List<CreateTestSuite> expectedTestSuites) {
|
||||
Map<String, TestSuite> testSuiteMap = new HashMap<>();
|
||||
for (TestSuite result : actualTestSuites.getData()) {
|
||||
testSuiteMap.put(result.getName(), result);
|
||||
@ -126,8 +124,7 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyTestCases(List<EntityReference> actualTestCases, List<EntityReference> expectedTestCases)
|
||||
throws HttpResponseException {
|
||||
private void verifyTestCases(List<EntityReference> actualTestCases, List<EntityReference> expectedTestCases) {
|
||||
assertEquals(expectedTestCases.size(), actualTestCases.size());
|
||||
Map<UUID, EntityReference> testCaseMap = new HashMap<>();
|
||||
for (EntityReference result : actualTestCases) {
|
||||
@ -147,21 +144,19 @@ public class TestSuiteResourceTest extends EntityResourceTest<TestSuite, CreateT
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(TestSuite createdEntity, CreateTestSuite request, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(TestSuite createdEntity, CreateTestSuite request, Map<String, String> authHeaders) {
|
||||
assertEquals(request.getName(), createdEntity.getName());
|
||||
assertEquals(request.getDescription(), createdEntity.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(TestSuite expected, TestSuite updated, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(TestSuite expected, TestSuite updated, Map<String, String> authHeaders) {
|
||||
assertEquals(expected.getName(), updated.getName());
|
||||
assertEquals(expected.getDescription(), updated.getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TestSuite validateGetWithDifferentFields(TestSuite entity, boolean byName) throws HttpResponseException {
|
||||
public TestSuite validateGetWithDifferentFields(TestSuite entity, boolean byName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,6 @@ public class WebhookCallbackResource {
|
||||
static class EventDetails {
|
||||
@Getter @Setter long firstEventTime;
|
||||
@Getter @Setter long latestEventTime;
|
||||
@Getter ConcurrentLinkedQueue<ChangeEvent> events = new ConcurrentLinkedQueue<>();
|
||||
@Getter final ConcurrentLinkedQueue<ChangeEvent> events = new ConcurrentLinkedQueue<>();
|
||||
}
|
||||
}
|
||||
|
@ -243,21 +243,19 @@ public class WebhookResourceTest extends EntityResourceTest<Webhook, CreateWebho
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(Webhook webhook, CreateWebhook createRequest, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(Webhook webhook, CreateWebhook createRequest, Map<String, String> authHeaders) {
|
||||
assertEquals(createRequest.getName(), webhook.getName());
|
||||
List<EventFilter> filters = createRequest.getEventFilters();
|
||||
assertEquals(filters, webhook.getEventFilters());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(Webhook expected, Webhook updated, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(Webhook expected, Webhook updated, Map<String, String> authHeaders) {
|
||||
// Patch not supported
|
||||
}
|
||||
|
||||
@Override
|
||||
public Webhook validateGetWithDifferentFields(Webhook entity, boolean byName) throws HttpResponseException {
|
||||
public Webhook validateGetWithDifferentFields(Webhook entity, boolean byName) {
|
||||
return entity; // Nothing to validate
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ public class FeedResourceTest extends OpenMetadataApplicationTest {
|
||||
public static Thread THREAD;
|
||||
public static Map<String, String> AUTH_HEADERS;
|
||||
public static TableResourceTest TABLE_RESOURCE_TEST;
|
||||
public static Comparator<Reaction> REACTION_COMPARATOR =
|
||||
public static final Comparator<Reaction> REACTION_COMPARATOR =
|
||||
(o1, o2) ->
|
||||
o1.getReactionType().equals(o2.getReactionType()) && o1.getUser().getId().equals(o2.getUser().getId())
|
||||
? 0
|
||||
|
@ -220,15 +220,13 @@ public class TypeResourceTest extends EntityResourceTest<Type, CreateType> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(Type createdEntity, CreateType createRequest, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(Type createdEntity, CreateType createRequest, Map<String, String> authHeaders) {
|
||||
assertEquals(createRequest.getSchema(), createdEntity.getSchema());
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(Type expected, Type patched, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(Type expected, Type patched, Map<String, String> authHeaders) {
|
||||
assertEquals(expected.getSchema(), patched.getSchema());
|
||||
// TODO more checks
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ import org.openmetadata.service.util.TestUtils.UpdateType;
|
||||
@Slf4j
|
||||
public class MessagingServiceResourceTest extends EntityResourceTest<MessagingService, CreateMessagingService> {
|
||||
|
||||
public static String KAFKA_BROKERS = "192.168.1.1:0";
|
||||
public static final String KAFKA_BROKERS = "192.168.1.1:0";
|
||||
public static URI SCHEMA_REGISTRY_URL;
|
||||
|
||||
static {
|
||||
|
@ -149,7 +149,7 @@ public class PipelineServiceResourceTest extends EntityResourceTest<PipelineServ
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_put_invalidConnection_as_admin_4xx(TestInfo test) throws IOException {
|
||||
void post_put_invalidConnection_as_admin_4xx(TestInfo test) {
|
||||
RedshiftConnection redshiftConnection = new RedshiftConnection();
|
||||
DatabaseConnection dbConn = new DatabaseConnection().withConfig(redshiftConnection);
|
||||
PipelineConnection pipelineConnection = new PipelineConnection().withConfig(redshiftConnection);
|
||||
|
@ -137,15 +137,13 @@ public class IngestionPipelineResourceTest extends EntityResourceTest<IngestionP
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(
|
||||
IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
IngestionPipeline ingestion, CreateIngestionPipeline createRequest, Map<String, String> authHeaders) {
|
||||
assertEquals(createRequest.getAirflowConfig().getConcurrency(), ingestion.getAirflowConfig().getConcurrency());
|
||||
validateSourceConfig(createRequest.getSourceConfig(), ingestion.getSourceConfig(), ingestion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void compareEntities(IngestionPipeline expected, IngestionPipeline updated, Map<String, String> authHeaders) {
|
||||
assertEquals(expected.getDisplayName(), updated.getDisplayName());
|
||||
assertReference(expected.getService(), updated.getService());
|
||||
assertEquals(expected.getSourceConfig(), updated.getSourceConfig());
|
||||
|
@ -27,7 +27,6 @@ import static org.openmetadata.service.util.TestUtils.TEST_AUTH_HEADERS;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponse;
|
||||
import static org.openmetadata.service.util.TestUtils.assertResponseContains;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
@ -68,7 +67,7 @@ public class TagResourceTest extends OpenMetadataApplicationTest {
|
||||
public static Tag ADDRESS_TAG;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() throws HttpResponseException, JsonProcessingException {
|
||||
public static void setup() throws HttpResponseException {
|
||||
new TagResourceTest().setupTags();
|
||||
}
|
||||
|
||||
|
@ -967,8 +967,7 @@ public class UserResourceTest extends EntityResourceTest<User, CreateUser> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCreatedEntity(User user, CreateUser createRequest, Map<String, String> authHeaders)
|
||||
throws HttpResponseException {
|
||||
public void validateCreatedEntity(User user, CreateUser createRequest, Map<String, String> authHeaders) {
|
||||
assertEquals(createRequest.getName(), user.getName());
|
||||
assertEquals(createRequest.getDisplayName(), user.getDisplayName());
|
||||
assertEquals(createRequest.getTimezone(), user.getTimezone());
|
||||
|
@ -148,12 +148,12 @@ class UsageResourceTest extends OpenMetadataApplicationTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void post_validUsageByName_200_OK(TestInfo test) throws HttpResponseException {
|
||||
void post_validUsageByName_200_OK(TestInfo test) {
|
||||
testValidUsageByName(test, POST);
|
||||
}
|
||||
|
||||
@Test
|
||||
void put_validUsageByName_200_OK(TestInfo test) throws HttpResponseException {
|
||||
void put_validUsageByName_200_OK(TestInfo test) {
|
||||
testValidUsageByName(test, PUT);
|
||||
}
|
||||
|
||||
|
@ -9,10 +9,7 @@ import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.auth0.jwt.interfaces.JWTVerifier;
|
||||
import io.dropwizard.testing.ResourceHelpers;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.Date;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@ -34,7 +31,7 @@ class JWTTokenGeneratorTest {
|
||||
protected JWTTokenGenerator jwtTokenGenerator;
|
||||
|
||||
@BeforeAll
|
||||
public void setup(TestInfo test) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException {
|
||||
public void setup(TestInfo test) {
|
||||
jwtTokenConfiguration = new JWTTokenConfiguration();
|
||||
jwtTokenConfiguration.setJwtissuer("open-metadata.org");
|
||||
jwtTokenConfiguration.setRsaprivateKeyFilePath(rsaPrivateKeyPath);
|
||||
|
@ -30,7 +30,7 @@ class RuleEvaluatorTest {
|
||||
private static EvaluationContext evaluationContext;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() throws NoSuchMethodException {
|
||||
public static void setup() {
|
||||
Entity.registerEntity(User.class, Entity.USER, Mockito.mock(UserDAO.class), Mockito.mock(UserRepository.class));
|
||||
Entity.registerEntity(Team.class, Entity.TEAM, Mockito.mock(TeamDAO.class), Mockito.mock(TeamRepository.class));
|
||||
table = new Table().withName("table");
|
||||
|
@ -62,7 +62,7 @@ public class SubjectContextTest {
|
||||
private static User user;
|
||||
|
||||
@BeforeAll
|
||||
public static void setup() throws NoSuchMethodException {
|
||||
public static void setup() {
|
||||
Entity.registerEntity(User.class, Entity.USER, Mockito.mock(UserDAO.class), Mockito.mock(UserRepository.class));
|
||||
Entity.registerEntity(Team.class, Entity.TEAM, Mockito.mock(TeamDAO.class), Mockito.mock(TeamRepository.class));
|
||||
Entity.registerEntity(
|
||||
|
@ -101,7 +101,7 @@ public final class TestUtils {
|
||||
public static MessagingConnection KAFKA_CONNECTION;
|
||||
public static DashboardConnection SUPERSET_CONNECTION;
|
||||
|
||||
public static MlModelConnection MLFLOW_CONNECTION;
|
||||
public static final MlModelConnection MLFLOW_CONNECTION;
|
||||
|
||||
public static URI PIPELINE_URL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user