Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
75707c6
Add randomFileName method
labkey-susanh Oct 1, 2025
12e2243
Typo
labkey-susanh Oct 1, 2025
144e02f
Validate attachment audit logs
labkey-susanh Oct 1, 2025
7233661
Remove comment
labkey-susanh Oct 1, 2025
f640d76
Add `canSeeAuditLogs` method
labkey-susanh Oct 2, 2025
c656ba6
Add way to set the lookupByAlternateKey property
labkey-susanh Oct 2, 2025
d201d20
Add way to set the lookupByAlternateKey property for importRows
labkey-susanh Oct 2, 2025
bf35dd7
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 2, 2025
cb40674
Add API category
labkey-susanh Oct 3, 2025
57b3172
Merge from develop
labkey-susanh Oct 6, 2025
3bdb999
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 6, 2025
ef11160
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 7, 2025
f9d3362
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 7, 2025
ff9314f
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 10, 2025
e25cec1
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-tchad Oct 10, 2025
b57013f
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 11, 2025
99a323c
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 15, 2025
c4995a8
Merge remote-tracking branch 'origin/develop' into fb_workflowApiTests
labkey-susanh Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/org/labkey/test/TestFileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,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;
Expand Down Expand Up @@ -73,6 +74,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
*/
Expand Down Expand Up @@ -783,4 +788,17 @@ else if (ch == '-' &&

return new String(ret);
}

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;
}
}
5 changes: 5 additions & 0 deletions src/org/labkey/test/categories/API.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.labkey.test.categories;

public abstract class API extends Test
{
}
1 change: 1 addition & 0 deletions src/org/labkey/test/util/AuditLogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,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"),
Expand Down
8 changes: 8 additions & 0 deletions src/org/labkey/test/util/PermissionsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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<String> 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("."))
Expand Down
22 changes: 21 additions & 1 deletion src/org/labkey/test/util/TestDataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -81,7 +82,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"; // "иИ안は"
// chose 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 = "+- _.:&()/";
Expand Down Expand Up @@ -936,6 +936,26 @@ public RowsResponse insertRows(Connection cn, List<Map<String, Object>> 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<Map<String, Object>> rows, boolean lookupByAlternateKey) throws IOException, CommandException
{
return getQueryHelper(cn).importData(TestDataUtils.stringFromRows(TestDataUtils.rowListsFromMaps(rows)), lookupByAlternateKey);
}

public static <T> List<T> shuffleSelect(List<T> allFields, int selectCount)
{
List<T> shuffled = new ArrayList<>(allFields);
Expand Down
12 changes: 12 additions & 0 deletions src/org/labkey/test/util/query/QueryApiHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,30 @@ public MoveRowsResponse moveRows(MoveRowsCommand moveRowsCommand) throws IOExcep
}

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(_insertTimeout);
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(_insertTimeout);
importDataCommand.setImportLookupByAlternateKey(importByAlternateKey);
return importDataCommand.execute(_connection, _containerPath);
}

Expand Down