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

fix : enable to display published news images selected from existing upload for non members - EXO-65111 #875

Merged
merged 2 commits into from
Jul 7, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ private void updateNewsImagesPermissions(News news, SessionProvider sessionProvi
if (matcher.find()) {
updateNewsImagesPermissions(news, sessionProvider,space, IMAGE_SRC_REGEX);
} else {
String existingUploadImagesSrcRegex = "src=\"" + RestUtils.getBaseRestUrl() + "/jcr/?(.+)?\"";
String existingUploadImagesSrcRegex = "src=\"" + CommonsUtils.getCurrentDomain() + "/" + PortalContainer.getCurrentPortalContainerName() + "/" + CommonsUtils.getRestContextName() + "/jcr/?(.+)?\"";
updateNewsImagesPermissions(news, sessionProvider,space, existingUploadImagesSrcRegex);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class JcrNewsStorageTest {

private static final MockedStatic<PortalContainer> PORTAL_CONTAINER = mockStatic(PortalContainer.class);

private static final MockedStatic<RestUtils> REST_UTILS = mockStatic(RestUtils.class);

@Mock
RepositoryService repositoryService;
Expand Down Expand Up @@ -163,7 +162,6 @@ public class JcrNewsStorageTest {
public static void afterRunBare() throws Exception { // NOSONAR
COMMONS_UTILS.close();
PORTAL_CONTAINER.close();
REST_UTILS.close();
}

@Test
Expand Down Expand Up @@ -1170,8 +1168,12 @@ public void shouldPublishNews() throws Exception {
//
ExtendedNode existingUploadedNewsImageNode = mock(ExtendedNode.class);
String nodePath = "Groups/spaces/test/testimage";
String baseRestUrl = "https://exoplatform.com/portal/rest";
REST_UTILS.when(() -> RestUtils.getBaseRestUrl()).thenReturn(baseRestUrl);
String currentDomainName = "https://exoplatform.com";
String currentPortalContainerName = "portal";
String restContextName = "rest";
COMMONS_UTILS.when(() -> CommonsUtils.getRestContextName()).thenReturn(restContextName);
PORTAL_CONTAINER.when(() -> PortalContainer.getCurrentPortalContainerName()).thenReturn(currentPortalContainerName);
COMMONS_UTILS.when(() -> CommonsUtils.getCurrentDomain()).thenReturn(currentDomainName);
news.setBody("news body with image src=\"https://exoplatform.com/portal/rest/jcr/repository/collaboration/Groups/spaces/test/testimage\"");
when(session.getItem(nullable(String.class))).thenReturn(existingUploadedNewsImageNode);
when(jcrNewsStorageSpy.getNodeByPath(nodePath, sessionProvider)).thenReturn(existingUploadedNewsImageNode);
Expand Down