Skip to content

Commit

Permalink
update: datasafe-business-impl-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
AssahBismarkabah committed Aug 13, 2024
1 parent 092025e commit 5b1fed5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import static de.adorsys.datasafe.business.impl.inbox.actions.DefaultInboxActionsModule_ProvideRootBucketFactory.provideRootBucket;
import static org.assertj.core.api.Assertions.assertThat;

/**
Expand Down Expand Up @@ -83,19 +84,21 @@ void listingPrivatePathWithUnicode(WithStorageProvider.StorageDescriptor descrip

@ParameterizedTest
@MethodSource("allStorages")
// Updated BasicFunctionaltyUT8IT.java
void readInboxContentWithUnicodeUsingUnicodePath(WithStorageProvider.StorageDescriptor descriptor) {
init(descriptor);

john = registerUser("john");
jane = registerUser("jane");


String unicodeMessage = "привет мир!";
writeDataToInbox(john, jane, " привет/prüfungsdokument=/файл:&? с пробелом.док", unicodeMessage);
String filePath = provideRootBucket() + "/привет/prüfungsdokument=/файл:&? с пробелом.док"; // Updated

writeDataToInbox(john, jane, filePath, unicodeMessage);

String inboxContentJane = readInboxUsingPrivateKey(
jane,
BasePrivateResource.forPrivate(" привет/prüfungsdokument=/файл:&? с пробелом.док")
BasePrivateResource.forPrivate(filePath)
);

assertThat(inboxContentJane).isEqualTo(unicodeMessage);
Expand All @@ -108,23 +111,25 @@ void listingInboxPathWithUnicode(WithStorageProvider.StorageDescriptor descripto

registerJohnAndJane();

writeDataToInbox(john, jane, "prüfungsdokument.doc+doc", MESSAGE_ONE);
writeDataToInbox(john, jane, "уровень1/?файл+doc", MESSAGE_ONE);
writeDataToInbox(john, jane, "уровень1/уровень 2=+/&файл пробел+плюс", MESSAGE_ONE);
String rootBucket = provideRootBucket();
writeDataToInbox(john, jane, rootBucket + "/prüfungsdokument.doc+doc", MESSAGE_ONE);
writeDataToInbox(john, jane, rootBucket + "/уровень1/?файл+doc", MESSAGE_ONE);
writeDataToInbox(john, jane, rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс", MESSAGE_ONE);

assertInboxSpaceList(jane, "", "prüfungsdokument.doc+doc", "уровень1/?файл+doc", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "./", "prüfungsdokument.doc+doc", "уровень1/?файл+doc", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, ".", "prüfungsdokument.doc+doc", "уровень1/?файл+doc", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "", rootBucket + "/prüfungsdokument.doc+doc", rootBucket + "/уровень1/?файл+doc", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "./", rootBucket + "/prüfungsdokument.doc+doc", rootBucket + "/уровень1/?файл+doc", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, ".", rootBucket + "/prüfungsdokument.doc+doc", rootBucket + "/уровень1/?файл+doc", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");

assertInboxSpaceList(jane, "prüfungsdokument.doc+doc", "prüfungsdokument.doc+doc");
assertInboxSpaceList(jane, "./prüfungsdokument.doc+doc", "prüfungsdokument.doc+doc");
assertInboxSpaceList(jane, rootBucket + "/prüfungsdokument.doc+doc", rootBucket + "/prüfungsdokument.doc+doc");
assertInboxSpaceList(jane, "./" + rootBucket + "/prüfungsdokument.doc+doc", rootBucket + "/prüfungsdokument.doc+doc");

assertInboxSpaceList(jane, "уровень1/уровень 2=+", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "уровень1/уровень 2=+/", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "./уровень1/уровень 2=+", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "./уровень1/уровень 2=+/", "уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, rootBucket + "/уровень1/уровень 2=+", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, rootBucket + "/уровень1/уровень 2=+/", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "./" + rootBucket + "/уровень1/уровень 2=+", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");
assertInboxSpaceList(jane, "./" + rootBucket + "/уровень1/уровень 2=+/", rootBucket + "/уровень1/уровень 2=+/&файл пробел+плюс");
}


private void init(StorageDescriptor descriptor) {
DefaultDatasafeServices datasafeServices = DatasafeServicesProvider
.defaultDatasafeServices(descriptor.getStorageService().get(), descriptor.getLocation());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static de.adorsys.datasafe.business.impl.e2e.Const.MESSAGE_ONE;
import static de.adorsys.datasafe.business.impl.e2e.Const.PRIVATE_FILE_PATH;
import static de.adorsys.datasafe.business.impl.e2e.Const.SHARED_FILE_PATH;
import static de.adorsys.datasafe.business.impl.inbox.actions.DefaultInboxActionsModule_ProvideRootBucketFactory.provideRootBucket;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down Expand Up @@ -66,7 +67,9 @@ void testMultipleRecipientsSharing(WithStorageProvider.StorageDescriptor descrip
UserIDAuth jane = registerUser("jane");
UserIDAuth jamie = registerUser("jamie");

String multiShareFile = "multishare.txt";
String rootBucket = provideRootBucket(); // Added
String multiShareFile = rootBucket + "/multishare.txt"; // Updated

multishareFiles(sender, john, jane, jamie, multiShareFile);

Stream.of(john, jane, jamie).forEach(
Expand All @@ -78,6 +81,7 @@ void testMultipleRecipientsSharing(WithStorageProvider.StorageDescriptor descrip
);
}


@ParameterizedTest
@MethodSource("allStorages")
void testWriteToPrivateListPrivateReadPrivateAndSendToAndReadFromInbox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Stream;

import static de.adorsys.datasafe.business.impl.inbox.actions.DefaultInboxActionsModule_ProvideRootBucketFactory.provideRootBucket;
import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down Expand Up @@ -79,25 +80,30 @@ void testPrivateDocumentContentTamperResistance() {
}
}

// Updated DataTamperingResistanceIT.java
@Test
@SneakyThrows
void testInboxDocumentContentTamperResistance() {
String rootBucket = provideRootBucket();
String fullFileName = rootBucket + "/" + FILENAME;

try (OutputStream os = writeToInbox.write(
WriteInboxRequest.forDefaultPublic(jane, Collections.singleton(john.getUserID()), FILENAME))
WriteInboxRequest.forDefaultPublic(jane, Collections.singleton(john.getUserID()), fullFileName))
) {
os.write(FILE_TEXT.getBytes(StandardCharsets.UTF_8));
}

AbsoluteLocation<ResolvedResource> inboxFile = getFirstFileInInbox(john);
tamperFileByReplacingOneByteOfEncryptedMessage(inboxFile);

try (InputStream is = readFromInbox.read(ReadRequest.forDefaultPrivate(john, FILENAME))) {
try (InputStream is = readFromInbox.read(ReadRequest.forDefaultPrivate(john, fullFileName))) {
assertThatThrownBy(
() -> ByteStreams.copy(is, ByteStreams.nullOutputStream())
).isInstanceOf(InvalidCipherTextIOException.class).hasCauseInstanceOf(AEADBadTagException.class);
}
}


@ParameterizedTest(name = "{arguments}")
@ValueSource(strings = {FILENAME, DIR_AND_FILENAME, DIR_DIR_AND_FILENAME})
@SneakyThrows
Expand Down

0 comments on commit 5b1fed5

Please sign in to comment.