diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/command/User.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/command/User.java index 9d101c5feef5305e244d1684f504ee95edd87b90..3ef47ecb031284de9bd67b48606514d926505abc 100644 --- a/pluto-server/src/main/java/de/itvsh/ozg/pluto/command/User.java +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/command/User.java @@ -2,11 +2,18 @@ package de.itvsh.ozg.pluto.command; import javax.validation.constraints.NotNull; +import de.itvsh.ozg.pluto.common.callcontext.CallContextUser; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.ToString; +/** + * + * @deprecated Use {@link CallContextUser} instead + * + */ +@Deprecated @ToString @Getter @Builder diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextAuthenticationToken.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextAuthenticationToken.java new file mode 100644 index 0000000000000000000000000000000000000000..3263551f1f42a23cff72973023031055b27c13ec --- /dev/null +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextAuthenticationToken.java @@ -0,0 +1,42 @@ +package de.itvsh.ozg.pluto.common.callcontext; + +import java.util.Collection; +import java.util.stream.Collectors; + +import org.springframework.security.authentication.AbstractAuthenticationToken; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public class CallContextAuthenticationToken extends AbstractAuthenticationToken { + + private final CallContextUser user; + + static CallContextAuthenticationToken authenticate(CallContextUser user) { + return new CallContextAuthenticationToken(user); + } + + private CallContextAuthenticationToken(CallContextUser user) { + super(user.getOrganisatorischeEinheitenIds().stream().map(SimpleGrantedAuthority::new).collect(Collectors.toSet())); + this.user = user; + super.setAuthenticated(true); + } + + @Override + public Object getCredentials() { + return null; + } + + @Override + public Object getPrincipal() { + return user; + } + + @Override + public Collection<GrantedAuthority> getAuthorities() { + return user.getOrganisatorischeEinheitenIds().stream().map(SimpleGrantedAuthority::new).collect(Collectors.toUnmodifiableSet()); + } + +} diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptor.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptor.java index 40b1cb990cc2f88e07ccdeac1ee738be39e295b0..6342d627cb95e251ffc0a859d07f2b4f10779bd8 100644 --- a/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptor.java +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptor.java @@ -1,6 +1,13 @@ package de.itvsh.ozg.pluto.common.callcontext; +import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Optional; +import java.util.UUID; +import java.util.stream.StreamSupport; + import org.apache.logging.log4j.CloseableThreadContext; +import org.springframework.security.core.context.SecurityContextHolder; import io.grpc.ForwardingServerCallListener; import io.grpc.Metadata; @@ -9,69 +16,116 @@ import io.grpc.ServerCall; import io.grpc.ServerCall.Listener; import io.grpc.ServerCallHandler; import io.grpc.ServerInterceptor; +import lombok.extern.log4j.Log4j2; import net.devh.boot.grpc.server.interceptor.GrpcGlobalServerInterceptor; +@Log4j2 @GrpcGlobalServerInterceptor class CallContextHandleInterceptor implements ServerInterceptor { private static final String REQUEST_ID_KEY = "requestId"; - static final String KEY_USER_ID = "USER_ID"; - static final String KEY_CLIENT_NAME = "CLIENT_NAME"; - static final String KEY_REQUEST_ID = "REQUEST_ID"; + static final String KEY_USER_ID = "USER_ID-bin"; + static final String KEY_USER_NAME = "USER_NAME-bin"; + static final String KEY_CLIENT_NAME = "CLIENT_NAME-bin"; + static final String KEY_ACCESS_LIMITED_ORGAID = "ACCESS_LIMITED_TO_ORGANISATORISCHEEINHEITENID-bin"; + static final String KEY_REQUEST_ID = "REQUEST_ID-bin"; + + static final String REQUEST_ID_PLACEHOLDER = "no-requestId-given"; @Override public <A, B> Listener<A> interceptCall(ServerCall<A, B> call, Metadata headers, ServerCallHandler<A, B> next) { - var requestId = headers.get(createKeyOf(KEY_REQUEST_ID)); - return new LogContextSettingListener<>(next.startCall(call, headers), requestId); + return new LogContextSettingListener<>(next.startCall(call, headers), headers); } class LogContextSettingListener<A> extends ForwardingServerCallListener.SimpleForwardingServerCallListener<A> { private final String requestId; + private final Metadata headers; - public LogContextSettingListener(ServerCall.Listener<A> delegate, String requestId) { + public LogContextSettingListener(ServerCall.Listener<A> delegate, Metadata headers) { super(delegate); - this.requestId = requestId; + this.headers = headers; + this.requestId = getRequestId(); } @Override public void onMessage(A message) { - try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { - super.onMessage(message); - } + doSurroundOn(() -> super.onMessage(message)); } @Override public void onHalfClose() { - try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { - super.onHalfClose(); - } + doSurroundOn(super::onHalfClose); } @Override public void onCancel() { - try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { - super.onCancel(); - } + doSurroundOn(super::onCancel); } @Override public void onComplete() { - try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { - super.onComplete(); - } + doSurroundOn(super::onComplete); } @Override public void onReady() { + doSurroundOn(super::onReady); + } + + void doSurroundOn(Runnable runnable) { try (CloseableThreadContext.Instance ctc = CloseableThreadContext.put(REQUEST_ID_KEY, requestId)) { - super.onReady(); + startSecurityContext(); + runnable.run(); + } finally { + clearSecurityContext(); } } + + String getRequestId() { + return getFromHeaders(KEY_REQUEST_ID, headers).orElseGet(() -> UUID.randomUUID().toString()); + } + + void startSecurityContext() { + var secContext = SecurityContextHolder.getContext(); + secContext.setAuthentication(CallContextAuthenticationToken.authenticate(createUser())); + + } + + CallContextUser createUser() { + var builder = CallContextUser.builder() + .userName(getFromHeaders(KEY_USER_NAME, headers)) + .organisatorischeEinheitenIds(getCollection(KEY_ACCESS_LIMITED_ORGAID, headers)); + + // TODO throw exception if missing required data as soon all clients are fine + // with using headers for auth data. + getFromHeaders(KEY_USER_ID, headers).ifPresentOrElse(builder::userId, () -> LOG.warn("Missing user id in grpc header.")); + getFromHeaders(KEY_CLIENT_NAME, headers).ifPresentOrElse(builder::clientName, () -> LOG.warn("Missing client name in grpc header.")); + + return builder.build(); + } + + void clearSecurityContext() { + SecurityContextHolder.clearContext(); + } + + } + + // TODO move to a grpcUtil class in common + static Optional<String> getFromHeaders(String key, Metadata headers) { + return Optional.ofNullable(headers.get(createKeyOf(key))).map(val -> new String(val, StandardCharsets.UTF_8)); } - // TODO move to a grpcUtil class - private Key<String> createKeyOf(String key) { - return Key.of(key, Metadata.ASCII_STRING_MARSHALLER); + // TODO move to a grpcUtil class in common + static Collection<String> getCollection(String key, Metadata headers) { + return StreamSupport.stream(headers.getAll(createKeyOf(key)).spliterator(), false) + .map(bytes -> new String(bytes, StandardCharsets.UTF_8)) + .toList(); } + + // TODO move to a grpcUtil class in common + static Key<byte[]> createKeyOf(String key) { + return Key.of(key, Metadata.BINARY_BYTE_MARSHALLER); + } + } diff --git a/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextUser.java b/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextUser.java new file mode 100644 index 0000000000000000000000000000000000000000..7a37d14d040876302598bdb7596106710622ca67 --- /dev/null +++ b/pluto-server/src/main/java/de/itvsh/ozg/pluto/common/callcontext/CallContextUser.java @@ -0,0 +1,32 @@ +package de.itvsh.ozg.pluto.common.callcontext; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Optional; + +import org.springframework.security.core.AuthenticatedPrincipal; + +import lombok.Builder; +import lombok.Getter; +import lombok.Singular; + +@Builder +@Getter +public class CallContextUser implements AuthenticatedPrincipal, Serializable { + + private static final long serialVersionUID = 1L; + + private final String clientName; + + private final String userId; + @Builder.Default + private final transient Optional<String> userName = Optional.empty(); + @Singular + private final Collection<String> organisatorischeEinheitenIds; + + @Override + public String getName() { + return clientName; + } + +} diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CallContextTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CallContextTestFactory.java deleted file mode 100644 index f88d280ade48a5520492721e2cefd2bbb06aaf30..0000000000000000000000000000000000000000 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CallContextTestFactory.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.itvsh.ozg.pluto.command; - -public class CallContextTestFactory { - - public static final User USER = UserTestFactory.create(); - public static final String CLIENT = "goofy"; - - public static CallContext create() { - return createBuilder().build(); - } - - public static CallContext.CallContextBuilder createBuilder() { - return CallContext.builder() - .user(USER) - .client(CLIENT); - } -} diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CommandServiceTest.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CommandServiceTest.java index f05e7f09f239243e27d8f29f8e1df47f4a02f4b5..867e48de8a6f2bb18bdbb18ba466009d81657302 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CommandServiceTest.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CommandServiceTest.java @@ -19,6 +19,7 @@ import org.mockito.Mock; import org.mockito.Spy; import org.springframework.context.ApplicationEventPublisher; +import de.itvsh.ozg.pluto.common.callcontext.CallContextTestFactory; import de.itvsh.ozg.pluto.vorgang.Vorgang.Status; import de.itvsh.ozg.pluto.vorgang.VorgangTestFactory; diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CreateCommandRequestTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CreateCommandRequestTestFactory.java index 0418a09acb0f8f5f00d4fa616ebaba014717e4f6..82872dff279699c8fb5d3897068b5f995ef50533 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CreateCommandRequestTestFactory.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/CreateCommandRequestTestFactory.java @@ -1,5 +1,6 @@ package de.itvsh.ozg.pluto.command; +import de.itvsh.ozg.pluto.common.callcontext.CallContextTestFactory; import de.itvsh.ozg.pluto.vorgang.VorgangTestFactory; public class CreateCommandRequestTestFactory { diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/UserTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/UserTestFactory.java index 5e7d626ac6a5d8a62572d5312e55316ff623a6db..7e39cc8638a7c265602dce66e96db94dd0fce5a7 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/UserTestFactory.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/command/UserTestFactory.java @@ -6,6 +6,7 @@ public class UserTestFactory { public static final String ID = UUID.randomUUID().toString(); public static final String NAME = "Udo Jürgens"; + public static final String ORGANISATORISCHE_EINHEITEN_ID = UUID.randomUUID().toString(); public static User create() { return createBuilder().build(); diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptorTest.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fd84fdda0fd4fba9204cca7b60f047435cced8e0 --- /dev/null +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextHandleInterceptorTest.java @@ -0,0 +1,174 @@ +package de.itvsh.ozg.pluto.common.callcontext; + +import static de.itvsh.ozg.pluto.common.callcontext.CallContextHandleInterceptor.*; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +import de.itvsh.ozg.pluto.command.UserTestFactory; +import de.itvsh.ozg.pluto.common.callcontext.CallContextHandleInterceptor.LogContextSettingListener; +import io.grpc.Metadata; +import io.grpc.ServerCall; + +class CallContextHandleInterceptorTest { + + @InjectMocks + private CallContextHandleInterceptor interceptor; + + @Mock + private ServerCall.Listener<Object> delegate; + + @Nested + class TestCallListener { + private LogContextSettingListener<?> listener; + private Metadata headers = CallContextTestFactory.createMetadata(); + + @BeforeEach + void createListener() { + listener = spy(interceptor.new LogContextSettingListener<>(delegate, headers)); + } + + @Nested + class TestGetRequestId { + @Test + void shouldReturnIdFromHeader() { + var reqId = listener.getRequestId(); + + assertThat(reqId).isEqualTo(CallContextTestFactory.REQUEST_ID); + } + + @Test + void shouldReturnNewRequestIdIfNoGiven() { + headers.removeAll(createKeyOf(KEY_REQUEST_ID)); + + var reqId = listener.getRequestId(); + + assertThat(reqId).isNotBlank().isNotEqualTo(CallContextTestFactory.REQUEST_ID); + } + + } + + @Nested + class TestHeadersToUser { + @Test + void shouldFilledUser() { + var user = buildListener().createUser(); + + assertThat(user).usingRecursiveComparison().isEqualTo(CallContextUserTestFactory.create()); + } + + @Test + void shouldFillOrgaIdCollection() { + Metadata metadata = CallContextTestFactory.createMetadata(); + metadata.put(CallContextHandleInterceptor.createKeyOf(KEY_ACCESS_LIMITED_ORGAID), "orgaid_2".getBytes()); + + var user = buildListener(metadata).createUser(); + + assertThat(user.getOrganisatorischeEinheitenIds()).hasSize(2).contains(UserTestFactory.ORGANISATORISCHE_EINHEITEN_ID, "orgaid_2"); + } + } + + @Nested + class TestDoSurround { + + private Runnable mockRunnable = mock(Runnable.class); + + @Test + void shouldRunRunnable() { + listener.doSurroundOn(mockRunnable); + + verify(mockRunnable).run(); + } + + @Test + void shouldStartSecurityContext() { + listener.doSurroundOn(mockRunnable); + + verify(listener).startSecurityContext(); + } + + @Test + void shouldClearSecurityContext() { + listener.doSurroundOn(mockRunnable); + + verify(listener).clearSecurityContext(); + } + + @Test + void shouldClearSecurityContextOnException() { + var testException = new RuntimeException() { + }; + + assertThatThrownBy(() -> listener.doSurroundOn(() -> { + throw testException; + })).isSameAs(testException); + + verify(listener).clearSecurityContext(); + } + } + + @Nested + class TestOnFunctions { + + private LogContextSettingListener<Object> listener; + + @BeforeEach + void initListener() { + listener = buildListener(); + } + + @Test + void onMessageShouldCallSurround() { + Object message = mock(Object.class); + + listener.onMessage(message); + + verify(listener).doSurroundOn(any()); + } + + @Test + void onHalfCloseShouldCallSurround() { + listener.onHalfClose(); + + verify(listener).doSurroundOn(any()); + } + + @Test + void onCancelShouldCallSurround() { + listener.onCancel(); + + verify(listener).doSurroundOn(any()); + } + + @Test + void onCompleteShouldCallSurround() { + listener.onComplete(); + + verify(listener).doSurroundOn(any()); + } + + @Test + void onReadyShouldCallSurround() { + listener.onReady(); + + verify(listener).doSurroundOn(any()); + } + } + + private LogContextSettingListener<Object> buildListener() { + return buildListener(headers); + } + + private LogContextSettingListener<Object> buildListener(Metadata headers) { + return spy(interceptor.new LogContextSettingListener<Object>(delegate, headers)); + } + + } + +} diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..a8c0e91f8e1af6ea354b402c8a6df4fae85157a2 --- /dev/null +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextTestFactory.java @@ -0,0 +1,52 @@ +package de.itvsh.ozg.pluto.common.callcontext; + +import static de.itvsh.ozg.pluto.command.UserTestFactory.*; +import static de.itvsh.ozg.pluto.common.callcontext.CallContextHandleInterceptor.*; + +import java.util.Map; +import java.util.Set; +import java.util.UUID; + +import de.itvsh.ozg.pluto.command.CallContext; +import de.itvsh.ozg.pluto.command.User; +import de.itvsh.ozg.pluto.command.UserTestFactory; +import io.grpc.Metadata; + +public class CallContextTestFactory { + + public static final User USER = UserTestFactory.create(); + public static final String CLIENT = "goofy"; + + public static final String REQUEST_ID = UUID.randomUUID().toString(); + + public static CallContext create() { + return createBuilder().build(); + } + + public static CallContext.CallContextBuilder createBuilder() { + return CallContext.builder() + .user(USER) + .client(CLIENT); + } + + public static Map<String, Object> createContextMap() { + return Map.of( + KEY_USER_ID, UserTestFactory.ID, + KEY_USER_NAME, UserTestFactory.NAME, + KEY_CLIENT_NAME, CLIENT, + KEY_ACCESS_LIMITED_ORGAID, Set.of(UserTestFactory.ORGANISATORISCHE_EINHEITEN_ID), + KEY_REQUEST_ID, REQUEST_ID); + } + + public static Metadata createMetadata() { + var result = new Metadata(); + result.put(CallContextHandleInterceptor.createKeyOf(KEY_USER_ID), ID.getBytes()); + result.put(CallContextHandleInterceptor.createKeyOf(KEY_USER_NAME), NAME.getBytes()); + result.put(CallContextHandleInterceptor.createKeyOf(KEY_CLIENT_NAME), CLIENT.getBytes()); + result.put(CallContextHandleInterceptor.createKeyOf(KEY_ACCESS_LIMITED_ORGAID), ORGANISATORISCHE_EINHEITEN_ID.getBytes()); + result.put(CallContextHandleInterceptor.createKeyOf(KEY_REQUEST_ID), REQUEST_ID.getBytes()); + + return result; + } + +} diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextUserTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextUserTestFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..4aeb8415b4de1310e3495b9ae2d1bfb353aff8c9 --- /dev/null +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/common/callcontext/CallContextUserTestFactory.java @@ -0,0 +1,20 @@ +package de.itvsh.ozg.pluto.common.callcontext; + +import java.util.Optional; + +import de.itvsh.ozg.pluto.command.UserTestFactory; + +public class CallContextUserTestFactory { + + static CallContextUser create() { + return createBuilder().build(); + } + + static CallContextUser.CallContextUserBuilder createBuilder() { + return CallContextUser.builder() + .clientName(CallContextTestFactory.CLIENT) + .userId(UserTestFactory.ID) + .userName(Optional.of(UserTestFactory.NAME)) + .organisatorischeEinheitenId(UserTestFactory.ORGANISATORISCHE_EINHEITEN_ID); + } +} diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFilePersistanceWrapperTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFilePersistanceWrapperTestFactory.java index f2584dc8719099d5aabdbc7bf07b9ee22591995f..46dfe92d2c43d02ee608dbede989826cc8d96789 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFilePersistanceWrapperTestFactory.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFilePersistanceWrapperTestFactory.java @@ -1,6 +1,6 @@ package de.itvsh.ozg.pluto.files; -import de.itvsh.ozg.pluto.command.CallContextTestFactory; +import de.itvsh.ozg.pluto.common.callcontext.CallContextTestFactory; class BinaryFilePersistanceWrapperTestFactory { diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFileRepositoryImplTest.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFileRepositoryImplTest.java index 14fa9c8da0be10ee8c90e8ce7fd10da6a3cbb58a..1412e61807a22800c572750d10a256e0447b045e 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFileRepositoryImplTest.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/BinaryFileRepositoryImplTest.java @@ -24,7 +24,7 @@ import org.springframework.data.mongodb.util.BsonUtils; import com.mongodb.client.gridfs.GridFSFindIterable; import com.mongodb.client.gridfs.model.GridFSFile; -import de.itvsh.ozg.pluto.command.CallContextTestFactory; +import de.itvsh.ozg.pluto.common.callcontext.CallContextTestFactory; class BinaryFileRepositoryImplTest { diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadStreamObserverTest.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadStreamObserverTest.java index 8d009a500afc4b8a493f0d7a8bfec0b2fa764e45..8e3491e08df90c9f07b585b5e3d702e755d0e7a7 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadStreamObserverTest.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadStreamObserverTest.java @@ -1,9 +1,12 @@ package de.itvsh.ozg.pluto.files; -import static org.assertj.core.api.Assertions.*; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.IOException; import java.io.PipedInputStream; @@ -21,7 +24,7 @@ import org.mockito.Mock; import com.google.protobuf.ByteString; import de.itvsh.ozg.mail.common.errorhandling.TechnicalException; -import de.itvsh.ozg.pluto.command.CallContextTestFactory; +import de.itvsh.ozg.pluto.common.callcontext.CallContextTestFactory; import de.itvsh.ozg.pluto.grpc.binaryFile.GrpcUploadBinaryFileRequest; import de.itvsh.ozg.pluto.grpc.binaryFile.GrpcUploadBinaryFileResponse; import de.itvsh.ozg.pluto.vorgang.IncomingFileTestFactory; diff --git a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadedFilesReferenceTestFactory.java b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadedFilesReferenceTestFactory.java index b5e80ac1aaad792e5d04e6f0b07af092cc23d204..a944b1d5a7f219a3300297a59e1970a6f3ea4c37 100644 --- a/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadedFilesReferenceTestFactory.java +++ b/pluto-server/src/test/java/de/itvsh/ozg/pluto/files/UploadedFilesReferenceTestFactory.java @@ -1,6 +1,6 @@ package de.itvsh.ozg.pluto.files; -import de.itvsh.ozg.pluto.command.CallContextTestFactory; +import de.itvsh.ozg.pluto.common.callcontext.CallContextTestFactory; import de.itvsh.ozg.pluto.vorgang.VorgangTestFactory; public class UploadedFilesReferenceTestFactory {