-
-
-
A newer plugin version installed since the data below was persisted which can lead to unexpected behaviour.
- Consider checking if persisted data is still compatible and/or relevant to a newer plugin version. This message will be hidden after the next save.
-
-
-
-
-
No hooks found. Please refer documentation.
-
-
-
-
Error occurred loading data
-
-
-
-
Error occurred loading list of revisions
-
+
+
+
+
+
+
No hooks found. Please refer documentation.
@@ -68,44 +52,13 @@
"/>
-
-
-
-
-
- Revision |
- Date |
- Author |
- Comment |
- Actions |
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
+
\ No newline at end of file
diff --git a/src/test/java/ch/sbb/polarion/extension/interceptor/rest/filter/AuthenticationFilterTest.java b/src/test/java/ch/sbb/polarion/extension/interceptor/rest/filter/AuthenticationFilterTest.java
deleted file mode 100644
index b3a3baf..0000000
--- a/src/test/java/ch/sbb/polarion/extension/interceptor/rest/filter/AuthenticationFilterTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package ch.sbb.polarion.extension.interceptor.rest.filter;
-
-import com.polarion.platform.security.AuthenticationFailedException;
-import com.polarion.platform.security.ISecurityService;
-import com.polarion.platform.security.login.AccessToken;
-import com.polarion.platform.security.login.ILogin;
-import com.polarion.platform.security.login.IToken;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import javax.security.auth.Subject;
-import javax.ws.rs.NotAuthorizedException;
-import javax.ws.rs.container.ContainerRequestContext;
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.*;
-
-@ExtendWith(MockitoExtension.class)
-class AuthenticationFilterTest {
-
- @Mock
- private ContainerRequestContext requestContext;
- @Mock
- private ISecurityService securityService;
- @Mock
- private ILogin login;
- @Mock
- private ILogin.IBase base;
- @Mock
- @SuppressWarnings("rawtypes")
- private ILogin.IUsingAuthenticator authenticator;
- @Mock
- private ILogin.IFinal iFinal;
-
- @Test
- void filterRequestWithoutAuthorizationHeader() {
-
- when(requestContext.getHeaderString("Authorization")).thenReturn(null);
- AuthenticationFilter filter = new AuthenticationFilter(securityService);
-
- assertThatThrownBy(() -> filter.filter(requestContext))
- .isInstanceOf(NotAuthorizedException.class)
- .hasMessageContaining("Authorization header must be provided");
- }
-
- @Test
- void filterRequestWithoutBaererInAuthorizationHeader() {
- when(requestContext.getHeaderString("Authorization")).thenReturn("wrong token");
- AuthenticationFilter filter = new AuthenticationFilter(securityService);
-
- assertThatThrownBy(() -> filter.filter(requestContext))
- .isInstanceOf(NotAuthorizedException.class)
- .hasMessageContaining("Authorization header must be provided");
- }
-
- @Test
- @SuppressWarnings("unchecked")
- void filterRequest() throws IOException, AuthenticationFailedException {
- when(requestContext.getHeaderString("Authorization")).thenReturn("Bearer token");
- when(securityService.login()).thenReturn(login);
- when(login.from("REST")).thenReturn(base);
- when(base.authenticator(any())).thenReturn(authenticator);
- when(authenticator.with((IToken
) any())).thenReturn(iFinal);
-
- Subject subject = new Subject();
- when(iFinal.perform()).thenReturn(subject);
-
- AuthenticationFilter filter = new AuthenticationFilter(securityService);
- filter.filter(requestContext);
- verify(requestContext, times(1)).setProperty("user_subject", subject);
- }
-
-
- @Test
- @SuppressWarnings("unchecked")
- void filterRequestWithFailedAuthentication() throws IOException, AuthenticationFailedException {
- when(requestContext.getHeaderString("Authorization")).thenReturn("Bearer token");
- when(securityService.login()).thenReturn(login);
- when(login.from("REST")).thenReturn(base);
- when(base.authenticator(any())).thenReturn(authenticator);
- when(authenticator.with((IToken) any())).thenReturn(iFinal);
-
- when(iFinal.perform()).thenThrow(new AuthenticationFailedException(""));
-
- AuthenticationFilter filter = new AuthenticationFilter(securityService);
-
- filter.filter(requestContext);
- verify(requestContext, times(1)).abortWith(any());
- }
-}
diff --git a/src/test/java/ch/sbb/polarion/extension/interceptor/rest/filter/LogoutFilterTest.java b/src/test/java/ch/sbb/polarion/extension/interceptor/rest/filter/LogoutFilterTest.java
deleted file mode 100644
index bbddec1..0000000
--- a/src/test/java/ch/sbb/polarion/extension/interceptor/rest/filter/LogoutFilterTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package ch.sbb.polarion.extension.interceptor.rest.filter;
-
-import com.polarion.platform.security.ISecurityService;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import javax.security.auth.Subject;
-import javax.ws.rs.container.ContainerRequestContext;
-import java.io.IOException;
-
-import static org.mockito.Mockito.*;
-
-@ExtendWith(MockitoExtension.class)
-class LogoutFilterTest {
-
- @Mock
- private ContainerRequestContext requestContext;
- @Mock
- private ISecurityService securityService;
-
- @Test
- void successfulLogoutCallIfSubjectExists() throws IOException {
- Subject subject = new Subject();
- when(requestContext.getProperty(AuthenticationFilter.USER_SUBJECT)).thenReturn(subject);
- LogoutFilter filter = new LogoutFilter(securityService);
- filter.filter(requestContext, null);
- verify(securityService, times(1)).logout(subject);
- }
-
- @Test
- void doNotCallLogoutIfThereIsNoSubject() throws IOException {
- when(requestContext.getProperty(AuthenticationFilter.USER_SUBJECT)).thenReturn(null);
- LogoutFilter filter = new LogoutFilter(securityService);
- filter.filter(requestContext, null);
- verify(securityService, times(0)).logout(any());
- }
-}
diff --git a/src/test/java/ch/sbb/polarion/extension/interceptor/util/RequestContextUtilTest.java b/src/test/java/ch/sbb/polarion/extension/interceptor/util/RequestContextUtilTest.java
deleted file mode 100644
index 5a7f098..0000000
--- a/src/test/java/ch/sbb/polarion/extension/interceptor/util/RequestContextUtilTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package ch.sbb.polarion.extension.interceptor.util;
-
-import org.junit.jupiter.api.Test;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-
-import javax.security.auth.Subject;
-import javax.servlet.http.HttpServletRequest;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-class RequestContextUtilTest {
-
- @Test
- public void shouldReturnUserSubject() {
- // Arrange
- ServletRequestAttributes requestAttributes = mock(ServletRequestAttributes.class);
- HttpServletRequest request = mock(HttpServletRequest.class);
- Subject subject = mock(Subject.class);
- when(requestAttributes.getRequest()).thenReturn(request);
- when(request.getAttribute("user_subject")).thenReturn(subject);
- RequestContextHolder.setRequestAttributes(requestAttributes);
-
- // Act
- Subject resultSubject = RequestContextUtil.getUserSubject();
-
- // Assert
- assertThat(resultSubject).isEqualTo(subject);
- }
-
- @Test
- public void shouldThrowIllegalStateExceptionByNullAttributes() {
- assertThatThrownBy(RequestContextUtil::getUserSubject)
- .isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("request attributes");
- }
-}
\ No newline at end of file
diff --git a/src/test/java/ch/sbb/polarion/extension/interceptor/util/ScopeUtilsTest.java b/src/test/java/ch/sbb/polarion/extension/interceptor/util/ScopeUtilsTest.java
deleted file mode 100644
index 47813e0..0000000
--- a/src/test/java/ch/sbb/polarion/extension/interceptor/util/ScopeUtilsTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package ch.sbb.polarion.extension.interceptor.util;
-
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-import java.util.stream.Stream;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-class ScopeUtilsTest {
-
- private static Stream testValuesForGetProjectByScope() {
- return Stream.of(
- Arguments.of("", null),
- Arguments.of("project/elibrary/", "elibrary"),
- Arguments.of("projects/test/", null),
- Arguments.of("invalid", null)
- );
- }
-
- @ParameterizedTest
- @MethodSource("testValuesForGetProjectByScope")
- void getProjectByScope(String scope, String expected) {
- String projectFromScope = ScopeUtils.getProjectFromScope(scope);
- assertEquals(expected, projectFromScope);
- }
-}
\ No newline at end of file