From 75707c649bbfc3923584f2d2bb693a37d4d72a68 Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Wed, 1 Oct 2025 10:51:08 -0700 Subject: [PATCH 1/8] Add randomFileName method --- src/org/labkey/test/TestFileUtils.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/org/labkey/test/TestFileUtils.java b/src/org/labkey/test/TestFileUtils.java index c983d5237b..8995eecc0d 100644 --- a/src/org/labkey/test/TestFileUtils.java +++ b/src/org/labkey/test/TestFileUtils.java @@ -40,6 +40,7 @@ import org.bouncycastle.openpgp.operator.jcajce.JcePBEDataDecryptorFactoryBuilder; import org.bouncycastle.util.io.Streams; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.openqa.selenium.NotFoundException; import java.io.BufferedInputStream; @@ -76,6 +77,10 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import static org.labkey.test.util.TestDataGenerator.CHARSET_STRING; +import static org.labkey.test.util.TestDataGenerator.randomInt; +import static org.labkey.test.util.TestDataGenerator.randomName; + /** * Static methods for finding and reading test-related files */ @@ -728,4 +733,17 @@ public static String makeLegalFileName(String candidate) { return badChars.matcher(candidate).replaceAll("_"); } + + public static String randomFileName(@NotNull String part, @Nullable String extension) + { + return randomFileName(part, extension, null, null); + } + + public static String randomFileName(@NotNull String part, @Nullable String extension, @Nullable Integer numStartChars, @Nullable Integer numEndChars) + { + String baseName = makeLegalFileName(randomName(part, numStartChars == null ? randomInt(0, 5) : numStartChars, numEndChars == null ? randomInt(0, 5) : numEndChars, CHARSET_STRING, null).name()); + if (extension != null) + return baseName + extension; + return baseName; + } } From 12e224308f06a7d4ffba0f57042cc949468738be Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Wed, 1 Oct 2025 10:51:27 -0700 Subject: [PATCH 2/8] Typo --- src/org/labkey/test/util/TestDataGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/labkey/test/util/TestDataGenerator.java b/src/org/labkey/test/util/TestDataGenerator.java index f6ea32b532..4de7dd5f8b 100644 --- a/src/org/labkey/test/util/TestDataGenerator.java +++ b/src/org/labkey/test/util/TestDataGenerator.java @@ -81,7 +81,7 @@ public class TestDataGenerator public static final char REPEAT_PLACEHOLDER = '\u22EF'; // '⋯' - Used to indicate that the char will be repeated public static final char ALL_CHARS_PLACEHOLDER = '\u2211'; // '∑' - Used to indicate that all characters from the charset should be used public static final String NON_LATIN_STRING = "\u0438\u0418\uC548\u306F"; // "иИ안は" - // chose a Character random from this String + // choose a Character random from this String public static final String CHARSET_STRING = "ABCDEFG01234abcdefvxyz~!@#$%^&*()-+=_{}[]|\\:;\"',.<>" + NON_LATIN_STRING + WIDE_PLACEHOLDER; public static final String ALPHANUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvxyz"; public static final String DOMAIN_SPECIAL_STRING = "+- _.:&()/"; From 144e02f38acd988185693a979953faf3efbb2a08 Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Wed, 1 Oct 2025 13:13:02 -0700 Subject: [PATCH 3/8] Validate attachment audit logs --- src/org/labkey/test/util/AuditLogHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/org/labkey/test/util/AuditLogHelper.java b/src/org/labkey/test/util/AuditLogHelper.java index d37c0f23e7..14bd5d89b5 100644 --- a/src/org/labkey/test/util/AuditLogHelper.java +++ b/src/org/labkey/test/util/AuditLogHelper.java @@ -88,6 +88,7 @@ public enum AuditEvent { ASSAY_AUDIT_EVENT("AssayAuditEvent"), // available with SampleManagement module ASSAY_RESULT_AUDIT_EVENT("AssayResultAuditEvent"), // available with SampleManagement module + ATTACHMENT_AUDIT_EVENT("AttachmentAuditEvent"), EXPERIMENT_AUDIT_EVENT("ExperimentAuditEvent"), FILE_SYSTEM_EVENT("FileSystem"), INVENTORY_AUDIT_EVENT("InventoryAuditEvent"), From 7233661eba87e26c219adce30b1a257002fcb2db Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Wed, 1 Oct 2025 16:26:13 -0700 Subject: [PATCH 4/8] Remove comment --- src/org/labkey/test/util/TestDataGenerator.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/org/labkey/test/util/TestDataGenerator.java b/src/org/labkey/test/util/TestDataGenerator.java index 4de7dd5f8b..412d231d24 100644 --- a/src/org/labkey/test/util/TestDataGenerator.java +++ b/src/org/labkey/test/util/TestDataGenerator.java @@ -81,7 +81,6 @@ public class TestDataGenerator public static final char REPEAT_PLACEHOLDER = '\u22EF'; // '⋯' - Used to indicate that the char will be repeated public static final char ALL_CHARS_PLACEHOLDER = '\u2211'; // '∑' - Used to indicate that all characters from the charset should be used public static final String NON_LATIN_STRING = "\u0438\u0418\uC548\u306F"; // "иИ안は" - // choose a Character random from this String public static final String CHARSET_STRING = "ABCDEFG01234abcdefvxyz~!@#$%^&*()-+=_{}[]|\\:;\"',.<>" + NON_LATIN_STRING + WIDE_PLACEHOLDER; public static final String ALPHANUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvxyz"; public static final String DOMAIN_SPECIAL_STRING = "+- _.:&()/"; From f640d76994c6323d459ba8d693af989471521639 Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Thu, 2 Oct 2025 13:09:45 -0700 Subject: [PATCH 5/8] Add `canSeeAuditLogs` method --- src/org/labkey/test/util/PermissionsHelper.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/org/labkey/test/util/PermissionsHelper.java b/src/org/labkey/test/util/PermissionsHelper.java index ff84ba8be0..64c4ff6b7b 100644 --- a/src/org/labkey/test/util/PermissionsHelper.java +++ b/src/org/labkey/test/util/PermissionsHelper.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import static org.junit.Assert.fail; @@ -45,6 +46,13 @@ public abstract class PermissionsHelper public static final String AUTHOR_ROLE = "Author"; public static final String SUBMITTER_ROLE = "Submitter"; + public static final Set AUDIT_LOG_VIEWER_ROLES = Set.of(SITE_ADMIN_ROLE, APP_ADMIN_ROLE, PROJECT_ADMIN_ROLE, FOLDER_ADMIN_ROLE); + + public static boolean canSeeAuditLogs(String roleName) + { + return AUDIT_LOG_VIEWER_ROLES.contains(roleName); + } + public static String toRole(final String name) { if (name.contains(".")) From c656ba62f628ce86e9d312fc74ad7bb2f9366623 Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Thu, 2 Oct 2025 13:10:08 -0700 Subject: [PATCH 6/8] Add way to set the lookupByAlternateKey property --- src/org/labkey/test/util/query/QueryApiHelper.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/org/labkey/test/util/query/QueryApiHelper.java b/src/org/labkey/test/util/query/QueryApiHelper.java index 1032ef98a4..5db2c0f312 100644 --- a/src/org/labkey/test/util/query/QueryApiHelper.java +++ b/src/org/labkey/test/util/query/QueryApiHelper.java @@ -117,21 +117,34 @@ public RowsResponse moveRows(List> rows, String targetContain } public ImportDataResponse importData(String text) throws IOException, CommandException + { + return importData(text, false); + } + + public ImportDataResponse importData(String text, boolean lookupByAlternateKey) throws IOException, CommandException { ImportDataCommand importDataCommand = new ImportDataCommand(_schema, _query); importDataCommand.setText(text); importDataCommand.setTimeout(_insertTimout); + importDataCommand.setImportLookupByAlternateKey(lookupByAlternateKey); return importDataCommand.execute(_connection, _containerPath); } public ImportDataResponse importData(File file) throws IOException, CommandException + { + return importData(file, false); + } + + public ImportDataResponse importData(File file, boolean importByAlternateKey) throws IOException, CommandException { ImportDataCommand importDataCommand = new ImportDataCommand(_schema, _query); importDataCommand.setFile(file); importDataCommand.setTimeout(_insertTimout); + importDataCommand.setImportLookupByAlternateKey(importByAlternateKey); return importDataCommand.execute(_connection, _containerPath); } + public ImportDataResponse importExperimentData(String text, AuditLogHelper.AuditBehaviorType auditBehaviorType, ImportDataCommand.InsertOption insertOption, boolean isCrossType, boolean isCrossFolder, boolean isAsync) throws IOException, CommandException { ImportExperimentDataCommand importDataCommand = new ImportExperimentDataCommand(_schema, _query, _containerPath); From d201d20d029701847349f3d2bf6e749bfec925f4 Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Thu, 2 Oct 2025 13:10:33 -0700 Subject: [PATCH 7/8] Add way to set the lookupByAlternateKey property for importRows --- .../labkey/test/util/TestDataGenerator.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/org/labkey/test/util/TestDataGenerator.java b/src/org/labkey/test/util/TestDataGenerator.java index 412d231d24..e308b284a1 100644 --- a/src/org/labkey/test/util/TestDataGenerator.java +++ b/src/org/labkey/test/util/TestDataGenerator.java @@ -33,6 +33,7 @@ import org.labkey.remoteapi.domain.DomainResponse; import org.labkey.remoteapi.domain.PropertyDescriptor; import org.labkey.remoteapi.query.Filter; +import org.labkey.remoteapi.query.ImportDataResponse; import org.labkey.remoteapi.query.RowsResponse; import org.labkey.remoteapi.query.SelectRowsResponse; import org.labkey.remoteapi.query.Sort; @@ -920,6 +921,26 @@ public RowsResponse insertRows(Connection cn, List> rows) th return getQueryHelper(cn).insertRows(rows); } + public ImportDataResponse importRows() throws IOException, CommandException + { + return importRows(false); + } + + public ImportDataResponse importRows(boolean lookupByAlternateKey) throws IOException, CommandException + { + return importRows(WebTestHelper.getRemoteApiConnection(), lookupByAlternateKey); + } + + public ImportDataResponse importRows(Connection cn, boolean lookupByAlternateKey) throws IOException, CommandException + { + return importRows(cn, getRows(), lookupByAlternateKey); + } + + public ImportDataResponse importRows(Connection cn, List> rows, boolean lookupByAlternateKey) throws IOException, CommandException + { + return getQueryHelper(cn).importData(TestDataUtils.stringFromRows(TestDataUtils.rowListsFromMaps(rows)), lookupByAlternateKey); + } + public static List shuffleSelect(List allFields, int selectCount) { List shuffled = new ArrayList<>(allFields); From cb406749bfbb687c0218e25f264c23e3ee353f2a Mon Sep 17 00:00:00 2001 From: labkey-susanh Date: Fri, 3 Oct 2025 07:03:00 -0700 Subject: [PATCH 8/8] Add API category --- src/org/labkey/test/categories/API.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/org/labkey/test/categories/API.java diff --git a/src/org/labkey/test/categories/API.java b/src/org/labkey/test/categories/API.java new file mode 100644 index 0000000000..95784add58 --- /dev/null +++ b/src/org/labkey/test/categories/API.java @@ -0,0 +1,5 @@ +package org.labkey.test.categories; + +public abstract class API extends Test +{ +}