Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add java checks on 'rp-beta-runner-set' #2122

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/drill-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Drill4J checks

on:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- '.github/**'
- README.md
- gradle.properties
push:
branches:
- master
- develop
paths-ignore:
- '.github/**'
- README.md
- gradle.properties

jobs:
call-java-checks:
name: Call Java Checks
uses: reportportal/.github/.github/workflows/java-checks.yaml@main
with:
runs-on: 'rp-beta-runner-set'
drill-agent-enabled: 'false' #disable Drill4J agent to check tests without Drill4J
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
import com.epam.ta.reportportal.dao.IntegrationRepository;
import com.epam.ta.reportportal.entity.EmailSettingsEnum;
import com.epam.ta.reportportal.entity.integration.Integration;
import com.epam.ta.reportportal.util.email.EmailService;
import com.epam.ta.reportportal.entity.integration.IntegrationType;
import com.epam.ta.reportportal.model.integration.IntegrationRQ;
import com.epam.ta.reportportal.util.email.MailServiceFactory;
import com.google.common.collect.Maps;
import com.mchange.lang.IntegerUtils;
Expand Down Expand Up @@ -60,9 +61,9 @@ public class EmailServerIntegrationService extends BasicIntegrationServiceImpl {
* Constructs an EmailServerIntegrationService with the specified dependencies.
*
* @param integrationRepository the repository for integration entities
* @param pluginBox the plugin box for managing plugins
* @param basicTextEncryptor the text encryptor for encrypting sensitive data
* @param emailServiceFactory the factory for creating email services
* @param pluginBox the plugin box for managing plugins
* @param basicTextEncryptor the text encryptor for encrypting sensitive data
* @param emailServiceFactory the factory for creating email services
*/
public EmailServerIntegrationService(
IntegrationRepository integrationRepository,
Expand Down Expand Up @@ -160,31 +161,56 @@ public Map<String, Object> retrieveUpdatedParams(
}

@Override
public boolean checkConnection(Integration integration) {
Optional<EmailService> emailService = emailServiceFactory.getEmailService(integration);
final boolean isIntegrationCreated = integration.getId() == null;
public Integration createIntegration(IntegrationRQ integrationRq,
IntegrationType integrationType) {
Integration integration = super.createIntegration(integrationRq, integrationType);
sendConnectionTestEmail(integration, true);
return integration;
}

@Override
public Integration updateIntegration(Integration integration, IntegrationRQ integrationRq) {
Integration updatedIntegration = super.updateIntegration(integration, integrationRq);
sendConnectionTestEmail(updatedIntegration, false);
return updatedIntegration;
}

if (emailService.isPresent()) {
@Override
public boolean checkConnection(Integration integration) {
return emailServiceFactory.getEmailService(integration).map(emailService -> {
try {
emailService.get().testConnection();
if (BooleanUtils.toBoolean(
EmailSettingsEnum.AUTH_ENABLED
.getAttribute(integration.getParams().getParams())
.orElse("false"))) {
emailService.get().sendConnectionTestEmail(isIntegrationCreated);
}
emailService.testConnection();
} catch (MessagingException ex) {
LOGGER.error("Cannot send email to user", ex);
LOGGER.error("Connection to email server failed", ex);
fail()
.withError(
EMAIL_CONFIGURATION_IS_INCORRECT,
"Email configuration is incorrect. Please, check your configuration. "
+ ex.getMessage());
return false;
}
} else {
return false;
}
return true;
}).orElse(false);
}

return true;
private void sendConnectionTestEmail(Integration integration, boolean isNewIntegration) {
boolean isAuthEnabled = BooleanUtils.toBoolean(
EmailSettingsEnum.AUTH_ENABLED
.getAttribute(integration.getParams().getParams())
.orElse("false"));
emailServiceFactory.getEmailService(integration).ifPresent(emailService -> {
if (isAuthEnabled) {
try {
emailService.sendConnectionTestEmail(isNewIntegration);
} catch (MessagingException ex) {
LOGGER.error("Cannot send email to user", ex);
fail()
.withError(
EMAIL_CONFIGURATION_IS_INCORRECT,
"Email configuration is incorrect. Please, check your configuration. "
+ ex.getMessage());
}
}
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,15 @@ public void sendCreateUserConfirmationEmail(CreateUserRQFull req, String basicUr
* Send email to user with connection test result. If email address is not valid, exception will
* be thrown.
*
* @param isCreated - flag that indicates if integration was created or updated. Used to determine
* email subject.
* @param isNewIntegration - flag that indicates if integration was created or updated.
* @throws AddressException - if email address is not valid or not exist.
*/
public void sendConnectionTestEmail(boolean isCreated)
public void sendConnectionTestEmail(boolean isNewIntegration)
throws AddressException {
InternetAddress sender =
getFrom().orElseThrow(() -> new AddressException("Sender email address is not exist"));
String subject =
isCreated ? "Email server integration creation" : "Email server integration updated";
isNewIntegration ? "Email server integration creation" : "Email server integration updated";
MimeMessagePreparator preparator =
mimeMessage -> {
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, true, "utf-8");
Expand Down
Loading