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

Merge hotfix/5.11.1 #1973

Merged
merged 31 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9701da3
Add caffeine cache manager
IvanKustau Sep 6, 2023
7024166
added github.run_number to rc build
hlebkanonik Sep 6, 2023
3dcf60a
EPMRPP-86400 || Fix the problem with 'undefined' for exported filenam…
IvanKustau Sep 14, 2023
30612d7
tag latest added
hlebkanonik Sep 29, 2023
5f92284
Update rc.yaml
hlebkanonik Sep 29, 2023
f056315
Create dockerhub-release.yaml
hlebkanonik Oct 2, 2023
e25059f
github.event.pull_request.base.ref
hlebkanonik Oct 2, 2023
f88d8ab
rewrite target regestry envs
hlebkanonik Oct 2, 2023
13d6e16
modified: .github/workflows/dockerhub-release.yaml
hlebkanonik Oct 2, 2023
929006d
Merge pull request #1813 from reportportal/rc/5.10.0
IvanKustau Oct 2, 2023
9013748
Update to release version
IvanKustau Oct 2, 2023
68ebccd
Merge remote-tracking branch 'origin/rc/5.10.0' into rc/5.10.0
IvanKustau Oct 2, 2023
a3e183f
Merge pull request #1814 from reportportal/rc/5.10.0
IvanKustau Oct 2, 2023
ef9d00b
[Gradle Release Plugin] - new version commit: '5.10.1'.
autoreportportal Oct 2, 2023
f0e8cbb
Hotfix 5.10.1 (#1837)
APiankouski Oct 25, 2023
afb083d
[Gradle Release Plugin] - new version commit: '5.10.2'.
autoreportportal Oct 25, 2023
3c970ce
Release 5.11.0 (#1899)
pbortnik Mar 1, 2024
6f65e2d
5.11.0 || Update gradle wrapper jar
pbortnik Mar 1, 2024
0c426d5
5.11.0 || Fix unit tests
pbortnik Mar 1, 2024
4d0e3e9
EPMRPP-89755 || Sort parameters in alphabetical order
APiankouski Mar 25, 2024
6b0ec09
EPMRPP-89932 || Add possibility to configure autocomplete suggestions…
APiankouski Mar 26, 2024
375862e
Merge pull request #1957 from reportportal/EPMRPP-89932
APiankouski Mar 26, 2024
53f8a90
EPMRPP-89924 || Security vulnerabilities fix (#1958)
IvanKustau Mar 28, 2024
fbc5e29
EPMRPP-89958 || Remove update of parent test item if it has status an…
IvanKustau Apr 1, 2024
00435ff
EPMRPP-89932 || Add possibility to configure autocomplete suggestions…
APiankouski Apr 1, 2024
d328565
Fix test
APiankouski Apr 2, 2024
b78ea18
EPMRPP-90309 || Empty content is returned for Admin user via API when…
APiankouski Apr 5, 2024
9d71a7f
Update release versions
IvanKustau Apr 10, 2024
b39dadd
Merge pull request #1969 from reportportal/hotfix/5.11.1
IvanKustau Apr 18, 2024
9f4b2cc
[Gradle Release Plugin] - new version commit: '5.11.2'.
autoreportportal Apr 18, 2024
f61d886
Merge hotfix/5.11.1 to develop
IvanKustau Apr 22, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:

env:
GH_USER_NAME: github.actor
RELEASE_VERSION: 5.11.0
RELEASE_VERSION: 5.11.1
REPOSITORY_URL: 'https://maven.pkg.github.com/'

jobs:
Expand Down
30 changes: 21 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ext['spring-boot.version'] = '2.5.15'

dependencyManagement {
imports {
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + '5.11.6' : 'com.epam.reportportal:commons-bom:5.11.6')
mavenBom(releaseMode ? 'com.epam.reportportal:commons-bom:' + '5.11.7' : 'com.epam.reportportal:commons-bom:5.11.7')
mavenBom('io.zonky.test.postgres:embedded-postgres-binaries-bom:16.2.0')
}
}
Expand All @@ -66,12 +66,12 @@ dependencies {
if (releaseMode) {
implementation 'com.epam.reportportal:commons-dao'
implementation 'com.epam.reportportal:commons'
implementation 'com.epam.reportportal:plugin-api'
implementation 'com.epam.reportportal:plugin-api:5.11.1'
} else {
implementation 'com.github.reportportal:commons-dao:495edfb'
implementation 'com.github.reportportal:commons-dao:073aa934a5'
implementation 'com.github.reportportal:commons-reporting:d99e842'
implementation 'com.github.reportportal:commons:d7f9bec'
implementation 'com.github.reportportal:plugin-api:3ecb915657'
implementation 'com.github.reportportal:plugin-api:17962f8c32'
}

implementation 'org.springframework.boot:spring-boot-starter-aop'
Expand All @@ -83,12 +83,19 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-batch'

implementation 'org.springframework:spring-jdbc:6.1.5'
//Fix CVE-2023-34050
implementation 'org.springframework.amqp:spring-amqp:2.4.17'

//Fix CVE-2023-40827, CVE-2023-40828, CVE-2023-40826
implementation 'org.springframework:spring-webmvc:5.3.33'
implementation 'org.springframework:spring-web:5.3.33'

implementation 'com.opencsv:opencsv:5.8'

// Fix CVE-2021-41079, CVE-2022-23181, CVE-2021-33037, CVE-2021-30640, CVE-2022-42252
implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.82'
implementation 'org.apache.tomcat.embed:tomcat-embed-el:9.0.82'
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.82'
// Fix CVE-2023-46589, CVE-2024-24549
implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.86'
implementation 'org.apache.tomcat.embed:tomcat-embed-el:9.0.86'
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.86'
//

//https://nvd.nist.gov/vuln/detail/CVE-2020-5411
Expand Down Expand Up @@ -131,10 +138,15 @@ dependencies {
implementation 'org.codehaus.jettison:jettison:1.5.4'
// Fix CVE-2020-15522
implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'org.apache.commons:commons-compress:1.25.0'
// Fix CVE-2024-25710, CVE-2024-26308
implementation 'org.apache.commons:commons-compress:1.26.0'
implementation 'org.yaml:snakeyaml:1.33'
implementation 'org.hibernate:hibernate-core:5.6.15.Final'

//Fix CVE-2023-6378, CVE-2023-6481, CVE-2023-6378, CVE-2023-6481
implementation 'ch.qos.logback:logback-classic:1.2.13'
implementation 'ch.qos.logback:logback-core:1.2.13'

// Metrics
implementation 'io.micrometer:micrometer-registry-prometheus:1.8.13'

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=5.11.0
version=5.11.2
description=EPAM ReportPortal. Main API Service
dockerPrepareEnvironment=
dockerJavaOpts=-Xmx1g -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=70 -Djava.security.egd=file:/dev/./urandom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import org.pf4j.PluginException;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;

/**
Expand All @@ -35,9 +35,9 @@ public interface PluginLoader {
*
* @param pluginPath Plugin's path
* @return {@link PluginInfo} with {@link PluginInfo#getId()} and {@link PluginInfo#getVersion()}
* @throws PluginException if there is an issue in loading the plugin or the plugin is not found in the specified path
* @throws PluginRuntimeException if there is an issue in loading the plugin or the plugin is not found in the specified path

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 127).

*/
PluginInfo extractPluginInfo(Path pluginPath) throws PluginException;
PluginInfo extractPluginInfo(Path pluginPath) throws PluginRuntimeException;

/**
* Creates the {@link IntegrationTypeDetails} object based on the params of the plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import org.apache.commons.lang3.StringUtils;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginDescriptorFinder;
import org.pf4j.PluginException;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -87,7 +87,7 @@ public PluginLoaderImpl(DataStore dataStore, IntegrationTypeRepository integrati

@Override
@NotNull
public PluginInfo extractPluginInfo(Path pluginPath) throws PluginException {
public PluginInfo extractPluginInfo(Path pluginPath) throws PluginRuntimeException {
PluginDescriptor pluginDescriptor = pluginDescriptorFinder.find(pluginPath);
return new PluginInfo(pluginDescriptor.getPluginId(), pluginDescriptor.getVersion());
}
Expand All @@ -99,8 +99,7 @@ public IntegrationTypeDetails resolvePluginDetails(PluginInfo pluginInfo) {
.flatMap(it -> ofNullable(it.getDetails())).flatMap(
typeDetails -> IntegrationTypeProperties.VERSION.getValue(typeDetails.getDetails())
.map(String::valueOf)).ifPresent(
version -> BusinessRule.expect(version, v -> !v.equalsIgnoreCase(
pluginInfo.getVersion()))
version -> BusinessRule.expect(version, v -> !v.equalsIgnoreCase(pluginInfo.getVersion()))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 102).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'lambda arguments' has incorrect indentation level 12, expected level should be one of the following: 18, 20.

.verify(
ErrorType.PLUGIN_UPLOAD_ERROR, Suppliers.formattedSupplier(
"Plugin with ID = '{}' of the same VERSION = '{}' "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static com.epam.ta.reportportal.entity.enums.StatusEnum.FAILED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.INFO;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.PASSED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.SKIPPED;
import static com.epam.ta.reportportal.entity.enums.StatusEnum.WARN;
import static com.epam.ta.reportportal.ws.converter.converters.TestItemConverter.TO_ACTIVITY_RESOURCE;
import static java.util.Optional.ofNullable;
Expand Down Expand Up @@ -92,9 +93,9 @@ private boolean isParentStatusUpdateRequired(TestItem parent) {
return parent.getItemResults().getStatus() != StatusEnum.IN_PROGRESS
&& parent.getItemResults().getStatus() != PASSED
&& parent.getItemResults().getStatus() != FAILED
&& parent.getItemResults().getStatus() != SKIPPED
&& !testItemRepository.hasItemsInStatusByParent(parent.getItemId(), parent.getPath(),
StatusEnum.IN_PROGRESS.name()
);
StatusEnum.IN_PROGRESS.name());
}

private StatusEnum resolveStatus(Long itemId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.epam.ta.reportportal.commons.querygen.Queryable;
import com.epam.ta.reportportal.entity.jasper.ReportFormat;
import com.epam.ta.reportportal.entity.project.Project;
import com.epam.ta.reportportal.entity.user.UserRole;
import com.epam.ta.reportportal.model.project.ProjectResource;
import com.epam.ta.reportportal.model.user.SearchUserResource;
import com.epam.ta.reportportal.model.user.UserResource;
Expand Down Expand Up @@ -88,6 +89,7 @@ public interface GetProjectHandler {
* @return List of found user resources
*/
Iterable<SearchUserResource> getUserNames(String value,
UserRole userRole,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'UserRole' has incorrect indentation level 5, expected level should be 6.

ReportPortalUser.ProjectDetails projectDetails, Pageable pageable);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.epam.ta.reportportal.entity.project.ProjectInfo;
import com.epam.ta.reportportal.entity.user.User;
import com.epam.reportportal.rules.exception.ReportPortalException;
import com.epam.ta.reportportal.entity.user.UserRole;
import com.epam.ta.reportportal.model.project.ProjectResource;
import com.epam.ta.reportportal.model.user.SearchUserResource;
import com.epam.ta.reportportal.model.user.UserResource;
Expand All @@ -60,6 +61,7 @@
import org.jooq.Operator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
Expand All @@ -82,6 +84,9 @@ public class GetProjectHandlerImpl implements GetProjectHandler {

private final ProjectConverter projectConverter;

@Value("${rp.environment.variable.user.suggestions:true}")
boolean isUserSuggestions;

@Autowired
public GetProjectHandlerImpl(ProjectRepository projectRepository, UserRepository userRepository,
@Qualifier("projectJasperReportHandler")
Expand Down Expand Up @@ -161,10 +166,12 @@ private void checkBusinessRuleLessThan1Symbol(String value) {

@Override
public Iterable<SearchUserResource> getUserNames(String value,
ReportPortalUser.ProjectDetails projectDetails, Pageable pageable) {
UserRole userRole,ReportPortalUser.ProjectDetails projectDetails, Pageable pageable) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck> reported by reviewdog 🐶
',' is not followed by whitespace.

checkBusinessRuleLessThan1Symbol(value);

final CompositeFilterCondition userCondition = getUserSearchCondition(value);
final CompositeFilterCondition userCondition =
(userRole.equals(UserRole.ADMINISTRATOR) || isUserSuggestions)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

? getUserSearchSuggestCondition(value) : getUserSearchCondition(value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 119).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.


final Filter filter = Filter.builder().withTarget(User.class).withCondition(userCondition)
.withCondition(
Expand All @@ -176,13 +183,18 @@ public Iterable<SearchUserResource> getUserNames(String value,
.apply(userRepository.findByFilterExcludingProjects(filter, pageable));
}

private CompositeFilterCondition getUserSearchCondition(String value) {
return new CompositeFilterCondition(
List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_USER),
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_FULL_NAME),
new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_EMAIL)
), Operator.AND);
}
private CompositeFilterCondition getUserSearchSuggestCondition(String value) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'method def modifier' has incorrect indentation level 8, expected level should be 2.

return new CompositeFilterCondition(List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_USER),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 142).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'method def' child has incorrect indentation level 16, expected level should be 4.

new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_FULL_NAME),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 119).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

new FilterCondition(Operator.OR, Condition.CONTAINS, false, value, CRITERIA_EMAIL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 114).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

), Operator.AND);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'method def rcurly' has incorrect indentation level 8, expected level should be 2.


private CompositeFilterCondition getUserSearchCondition(String value) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'method def modifier' has incorrect indentation level 8, expected level should be 2.

return new CompositeFilterCondition(List.of(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'method def' child has incorrect indentation level 16, expected level should be 4.

new FilterCondition(Operator.OR, Condition.EQUALS, false, value, CRITERIA_EMAIL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 100 characters (found 112).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

), Operator.AND);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck> reported by reviewdog 🐶
Line contains a tab character.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [reviewdog] <com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck> reported by reviewdog 🐶
'method def rcurly' has incorrect indentation level 8, expected level should be 2.


@Override
public List<String> getAllProjectNames() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.pf4j.PluginException;
import org.pf4j.PluginManager;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginState;
import org.pf4j.PluginWrapper;
import org.slf4j.Logger;
Expand Down Expand Up @@ -385,7 +385,7 @@ private PluginInfo resolvePluginInfo(final String fileName, InputStream fileStre
BusinessRule.expect(validatePluginMetaInfo(newPluginInfo), equalTo(Boolean.TRUE))
.verify(ErrorType.PLUGIN_UPLOAD_ERROR, "Plugin version should be specified.");
return newPluginInfo;
} catch (PluginException e) {
} catch (PluginRuntimeException e) {
removeUploadingPlugin(fileName);
throw new ReportPortalException(ErrorType.PLUGIN_UPLOAD_ERROR, e.getMessage());
}
Expand Down Expand Up @@ -746,7 +746,7 @@ private PluginState loadPreviousPlugin(PluginWrapper previousPlugin,
previousPlugin.getPluginId())
.get()
)));
} catch (PluginException e) {
} catch (PluginRuntimeException e) {
throw new ReportPortalException(ErrorType.PLUGIN_UPLOAD_ERROR,
Suppliers.formattedSupplier("Unable to reload previousPlugin with id = '{}': '{}'",
previousPlugin.getPluginId(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ public ReportPortalExtensionFactory(String resourcesDir, PluginManager pluginMan
}

@Override
public Object create(Class<?> extensionClass) {
public <T> T create(Class<T> extensionClass) {
PluginWrapper pluginWrapper = pluginManager.whichPlugin(extensionClass);
if (beanFactory.containsSingleton(pluginWrapper.getPluginId())) {
return beanFactory.getSingleton(pluginWrapper.getPluginId());
return extensionClass.cast(beanFactory.getSingleton(pluginWrapper.getPluginId()));
} else {
return createExtension(extensionClass, pluginWrapper);
return extensionClass.cast(createExtension(extensionClass, pluginWrapper));
}
}

private Object createExtension(Class<?> extensionClass, PluginWrapper pluginWrapper) {
private <T> T createExtension(Class<T> extensionClass, PluginWrapper pluginWrapper) {
Map<String, Object> initParams = getInitParams(pluginWrapper);
Object plugin = createPlugin(extensionClass, initParams);
T plugin = createPlugin(extensionClass, initParams);
beanFactory.autowireBean(plugin);
beanFactory.initializeBean(plugin, pluginWrapper.getDescriptor().getPluginId());
beanFactory.registerSingleton(pluginWrapper.getDescriptor().getPluginId(), plugin);
Expand All @@ -66,7 +66,7 @@ private Object createExtension(Class<?> extensionClass, PluginWrapper pluginWrap
return plugin;
}

private Object createPlugin(Class<?> extensionClass, Map<String, Object> initParams) {
private <T> T createPlugin(Class<T> extensionClass, Map<String, Object> initParams) {
try {
return extensionClass.getDeclaredConstructor(Map.class).newInstance(initParams);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,10 @@ public List<String> getProjectUsers(@PathVariable String projectName,
@ResponseStatus(OK)
@PreAuthorize(PROJECT_MANAGER)
public Iterable<SearchUserResource> searchForUser(@PathVariable String projectName,
@RequestParam(value = "term") String term, Pageable pageable,
@AuthenticationPrincipal ReportPortalUser user) {
return getProjectHandler.getUserNames(term,
projectExtractor.extractProjectDetails(user, projectName), pageable
);
@RequestParam(value = "term") String term,
Pageable pageable, @AuthenticationPrincipal ReportPortalUser user) {
return getProjectHandler.getUserNames(term, user.getUserRole(),
projectExtractor.extractProjectDetails(user, projectName), pageable);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import org.junit.jupiter.api.Test;
import org.pf4j.PluginDescriptor;
import org.pf4j.PluginDescriptorFinder;
import org.pf4j.PluginException;
import org.pf4j.PluginManager;
import org.pf4j.PluginRuntimeException;
import org.pf4j.PluginWrapper;

/**
Expand Down Expand Up @@ -72,7 +72,7 @@ class PluginLoaderTest {
);

@Test
void shouldExtractPluginIdWhenExists() throws PluginException {
void shouldExtractPluginIdWhenExists() throws PluginRuntimeException {

Path path = Paths.get("dir", FILE_NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.TestPropertySource;

/**
* @author <a href="mailto:[email protected]">Ihar Kahadouski</a>
*/
@ExtendWith(MockitoExtension.class)
@TestPropertySource(properties = {"rp.environment.variable.user.suggestions=true"})
class GetProjectHandlerImplTest {

@Mock
private ProjectRepository projectRepository;

@Spy
@InjectMocks
private GetProjectHandlerImpl handler;

Expand Down Expand Up @@ -124,17 +128,11 @@ void getUserNamesByIncorrectTerm() {
);
}

@Test
void getUserNamesNegative() {
ReportPortalException exception = assertThrows(
ReportPortalException.class, () -> handler.getUserNames("",
new ReportPortalUser.ProjectDetails(1L, "superadmin_personal",
ProjectRole.PROJECT_MANAGER
), PageRequest.of(0, 10)
));
assertEquals(
"Incorrect filtering parameters. Length of the filtering string '' is less than 1 symbol",
exception.getMessage()
);
}
@Test
void getUserNamesNegative() {
ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.getUserNames("", UserRole.ADMINISTRATOR,
new ReportPortalUser.ProjectDetails(1L, "superadmin_personal", ProjectRole.PROJECT_MANAGER),
PageRequest.of(0, 10)));
assertEquals("Incorrect filtering parameters. Length of the filtering string '' is less than 1 symbol", exception.getMessage());
}
}
Loading
Loading