Skip to content

Commit

Permalink
fix: Core should allow access to the folder appdata for read and writ… (
Browse files Browse the repository at this point in the history
  • Loading branch information
astsiapanay authored Feb 21, 2025
1 parent eeaed7f commit de4a991
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,9 @@ public static Map<ResourceDescriptor, Set<ResourceAccessType>> getAppResourceAcc
}

String parentPath = resource.getParentPath();
String filePath;
if (resource.isFolder()) {
filePath = parentPath;
} else {
filePath = parentPath == null
? resource.getName()
: parentPath + ResourceDescriptor.PATH_SEPARATOR + resource.getName();
}
String filePath = parentPath == null
? resource.getName()
: parentPath + ResourceDescriptor.PATH_SEPARATOR + resource.getName();

if (filePath != null && filePath.startsWith(appPath)) {
result.put(resource, ResourceAccessType.ALL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public void testGetAppResourceAccess_AppDataFile() {
assertEquals(ResourceAccessType.ALL, result.get(descriptor));
}

@Test
public void testGetAppResourceAccess_AppDataFolder() {
ProxyContext context = mock(ProxyContext.class);
ApiKeyData apiKeyData = new ApiKeyData();
apiKeyData.setPerRequestKey("key");
when(context.getApiKeyData()).thenReturn(apiKeyData);
when(context.getUserSub()).thenReturn("user");
when(context.getSourceDeployment()).thenReturn("app");
ResourceDescriptor descriptor = new ResourceDescriptor(ResourceTypes.FILE, "app", List.of("appdata"), "bucket", "Users/user/", true);

Map<ResourceDescriptor, Set<ResourceAccessType>> result = AccessService.getAppResourceAccess(Set.of(descriptor), context);

assertTrue(result.containsKey(descriptor));
assertEquals(ResourceAccessType.ALL, result.get(descriptor));
}

@Test
public void testGetAppResourceAccess_DeploymentNameHasSpecialChars() {
ProxyContext context = mock(ProxyContext.class);
Expand Down

0 comments on commit de4a991

Please sign in to comment.