Skip to content

Commit

Permalink
fix: proper url when tenant is null (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin authored Oct 12, 2023
1 parent 9f9ad6a commit c33c286
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/io/kestra/storage/s3/S3Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ public List<URI> deleteByPrefix(String tenantId, URI storagePrefix) throws IOExc
}

private String getPath(String tenantId, URI uri) {
if (tenantId == null) {
return uri.getPath();
}
return "/" + tenantId + uri.getPath();
}
private static URI createUri(String key) {
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/io/kestra/storage/s3/S3StorageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ void get() throws Exception {
String prefix = IdUtils.create();
String tenantId = IdUtils.create();

get(tenantId, prefix);
}

@Test
void getNoTenant() throws Exception {
String prefix = IdUtils.create();
String tenantId = null;

get(tenantId, prefix);
}

private void get(String tenantId, String prefix) throws Exception {
URL resource = S3StorageTest.class.getClassLoader().getResource("application.yml");
String content = CharStreams.toString(new InputStreamReader(new FileInputStream(Objects.requireNonNull(resource).getFile())));

Expand Down Expand Up @@ -147,6 +159,18 @@ void deleteByPrefix() throws Exception {
String prefix = IdUtils.create();
String tenantId = IdUtils.create();

deleteByPrefix(prefix, tenantId);
}

@Test
void deleteByPrefixNoTenant() throws Exception {
String prefix = IdUtils.create();
String tenantId = null;

deleteByPrefix(prefix, tenantId);
}

private void deleteByPrefix(String prefix, String tenantId) throws Exception {
URL resource = S3StorageTest.class.getClassLoader().getResource("application.yml");

List<String> path = Arrays.asList(
Expand Down

0 comments on commit c33c286

Please sign in to comment.