diff --git a/pom.xml b/pom.xml
index f0828c9..c0d5c29 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
ch.sbb.polarion.extensions
ch.sbb.polarion.extension.generic
- 7.0.0
+ 7.0.1
ch.sbb.polarion.extension.pdf-exporter
diff --git a/src/main/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsService.java b/src/main/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsService.java
index a890ea2..8b728a1 100644
--- a/src/main/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsService.java
+++ b/src/main/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsService.java
@@ -156,7 +156,12 @@ public record JobState(
private boolean isJobLogoutRequired() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
- return (requestAttributes != null) &&
- (requestAttributes.getAttribute(LogoutFilter.ASYNC_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST) == Boolean.TRUE);
+ if (requestAttributes != null) {
+ if (requestAttributes.getAttribute(LogoutFilter.XSRF_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST) == Boolean.TRUE) {
+ return false;
+ }
+ return requestAttributes.getAttribute(LogoutFilter.ASYNC_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST) == Boolean.TRUE;
+ }
+ return false;
}
}
diff --git a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsServiceTest.java b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsServiceTest.java
index c6da96c..ecba89c 100644
--- a/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsServiceTest.java
+++ b/src/test/java/ch/sbb/polarion/extension/pdf/exporter/converter/PdfConverterJobsServiceTest.java
@@ -62,6 +62,7 @@ public void tearDown() {
@Test
void shouldStartJobAndGetStatus() {
prepareSecurityServiceSubject(subject);
+ when(requestAttributes.getAttribute(LogoutFilter.XSRF_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(Boolean.FALSE);
when(requestAttributes.getAttribute(LogoutFilter.ASYNC_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(Boolean.TRUE);
ExportParams exportParams = ExportParams.builder().build();
when(pdfConverter.convertToPdf(exportParams, null)).thenReturn("test pdf".getBytes());
@@ -86,6 +87,7 @@ void shouldStartJobAndGetStatus() {
@Test
void shouldReturnFailInExceptionalCase() {
prepareSecurityServiceSubject(subject);
+ when(requestAttributes.getAttribute(LogoutFilter.XSRF_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(Boolean.FALSE);
when(requestAttributes.getAttribute(LogoutFilter.ASYNC_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(Boolean.TRUE);
ExportParams exportParams = ExportParams.builder().build();
when(pdfConverter.convertToPdf(exportParams, null)).thenThrow(new RuntimeException("test error"));
@@ -131,11 +133,16 @@ void shouldAcceptNullSubject() {
verify(securityService, never()).logout(null);
}
- @Test
- void shouldNotLogoutWithoutLogoutProperty() {
+ @ParameterizedTest
+ @CsvSource({
+ "true,true",
+ "true,false",
+ "false,false"
+ })
+ void shouldNotLogoutWithoutAsyncSkipLogoutProperty(boolean xsrfSkipLogout, boolean asyncSkipLogout) {
prepareSecurityServiceSubject(subject);
- when(requestAttributes.getAttribute(LogoutFilter.ASYNC_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(null);
-
+ lenient().when(requestAttributes.getAttribute(LogoutFilter.XSRF_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(xsrfSkipLogout);
+ lenient().when(requestAttributes.getAttribute(LogoutFilter.ASYNC_SKIP_LOGOUT, RequestAttributes.SCOPE_REQUEST)).thenReturn(asyncSkipLogout);
ExportParams exportParams = ExportParams.builder().build();
when(pdfConverter.convertToPdf(exportParams, null)).thenReturn("test pdf".getBytes());
@@ -147,7 +154,7 @@ void shouldNotLogoutWithoutLogoutProperty() {
JobState jobState = pdfConverterJobsService.getJobState(jobId);
assertThat(jobState.isCompletedExceptionally()).isFalse();
assertThat(jobState.isCancelled()).isFalse();
- verify(securityService, never()).logout(null);
+ verify(securityService, never()).logout(subject);
}
@ParameterizedTest