修改问题
这个提交包含在:
+1
-1
@@ -17,7 +17,7 @@ public class LakehouseTableFileReferenceDirectory {
|
||||
}
|
||||
|
||||
public Resolution resolveForIngestion(long actorId, long orgId, long layerId) {
|
||||
return resolve(actorId, orgId, layerId, false);
|
||||
return resolve(actorId, orgId, layerId, LoginHelper.isSuperAdmin(actorId));
|
||||
}
|
||||
|
||||
private Resolution resolve(long actorId, long orgId, long layerId, boolean unrestricted) {
|
||||
|
||||
+2
-2
@@ -83,10 +83,10 @@ public class StorageResourceService {
|
||||
return detail(currentActor(), resourceId);
|
||||
}
|
||||
|
||||
/** Server-derived identity only; ingestion never inherits the administrator scope bypass. */
|
||||
/** Server-derived identity only; use the same owner policy for viewing and ingestion. */
|
||||
public StorageResourceDetailView detailForIngestion(long actorId, long orgId, long resourceId) {
|
||||
if (actorId <= 0 || orgId <= 0) throw new StorageScopeException();
|
||||
return detail(new StorageActor(actorId, orgId, false), resourceId);
|
||||
return detail(new StorageActor(actorId, orgId, LoginHelper.isSuperAdmin(actorId)), resourceId);
|
||||
}
|
||||
|
||||
private StorageResourceDetailView detail(StorageActor actor, long resourceId) {
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ public class StorageTableFileReferenceDirectory {
|
||||
}
|
||||
|
||||
public Resolution resolveForIngestion(long actorId, long orgId, long resourceId, long spaceId) {
|
||||
return resolve(actorId, orgId, resourceId, spaceId, false);
|
||||
return resolve(actorId, orgId, resourceId, spaceId, LoginHelper.isSuperAdmin(actorId));
|
||||
}
|
||||
|
||||
private Resolution resolve(long actorId, long orgId, long resourceId, long spaceId, boolean unrestricted) {
|
||||
@@ -54,7 +54,7 @@ public class StorageTableFileReferenceDirectory {
|
||||
}
|
||||
|
||||
public ObjectResolution resolveObjectForIngestion(long actorId, long orgId, long resourceId, String externalObjectId) {
|
||||
return resolveObject(actorId, orgId, resourceId, externalObjectId, false);
|
||||
return resolveObject(actorId, orgId, resourceId, externalObjectId, LoginHelper.isSuperAdmin(actorId));
|
||||
}
|
||||
|
||||
private ObjectResolution resolveObject(long actorId, long orgId, long resourceId, String externalObjectId,
|
||||
|
||||
+20
-5
@@ -16,27 +16,40 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
class StorageTableFileReferenceDirectoryTest {
|
||||
private static final long ADMIN=cn.aixunkeji.common.core.constant.SystemConstants.SUPER_ADMIN_USER_ID;
|
||||
|
||||
private final StorageResourceRepository repository = mock(StorageResourceRepository.class);
|
||||
private final StorageTableFileReferenceDirectory directory = new StorageTableFileReferenceDirectory(repository);
|
||||
|
||||
@Test void ingestionAlwaysUsesStrictOrganizationEvenForAdministratorId() {
|
||||
@Test void ingestionUsesSameTrustedAdministratorPolicyAsViewing() {
|
||||
when(repository.requireResource(any(), org.mockito.ArgumentMatchers.eq(30L)))
|
||||
.thenThrow(new StorageScopeException());
|
||||
assertThat(directory.resolveForIngestion(1, 20, 30, 40).status())
|
||||
assertThat(directory.resolveForIngestion(ADMIN, 20, 30, 40).status())
|
||||
.isEqualTo(StorageTableFileReferenceDirectory.Status.OUTSIDE_SCOPE);
|
||||
assertThat(directory.resolveObjectForIngestion(1, 20, 30, "sales").status())
|
||||
assertThat(directory.resolveObjectForIngestion(ADMIN, 20, 30, "sales").status())
|
||||
.isEqualTo(StorageTableFileReferenceDirectory.Status.OUTSIDE_SCOPE);
|
||||
var capture = org.mockito.ArgumentCaptor.forClass(StorageActor.class);
|
||||
org.mockito.Mockito.verify(repository, org.mockito.Mockito.times(2))
|
||||
.requireResource(capture.capture(), org.mockito.ArgumentMatchers.eq(30L));
|
||||
assertThat(capture.getAllValues()).allSatisfy(actor -> {
|
||||
assertThat(actor.actorId()).isEqualTo(1);
|
||||
assertThat(actor.actorId()).isEqualTo(ADMIN);
|
||||
assertThat(actor.departmentId()).isEqualTo(20);
|
||||
assertThat(actor.unrestricted()).isFalse();
|
||||
assertThat(actor.unrestricted()).isTrue();
|
||||
});
|
||||
}
|
||||
|
||||
@Test void ordinaryActorCannotUseAdministratorScopeAcrossOrganizations() {
|
||||
when(repository.requireResource(any(), org.mockito.ArgumentMatchers.eq(30L)))
|
||||
.thenAnswer(invocation -> {
|
||||
StorageActor actor=invocation.getArgument(0);
|
||||
assertThat(actor.unrestricted()).isFalse();
|
||||
assertThat(actor.departmentId()).isEqualTo(20);
|
||||
throw new StorageScopeException();
|
||||
});
|
||||
assertThat(directory.resolveForIngestion(8,20,30,40).status()).isEqualTo(StorageTableFileReferenceDirectory.Status.OUTSIDE_SCOPE);
|
||||
assertThat(directory.resolveObjectForIngestion(8,20,30,"sales").status()).isEqualTo(StorageTableFileReferenceDirectory.Status.OUTSIDE_SCOPE);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolvesOwnerResourceSpaceAndReturnsOnlySecretReferenceMetadata() {
|
||||
when(repository.requireResource(any(), org.mockito.ArgumentMatchers.eq(30L))).thenReturn(new StorageResourceView(
|
||||
@@ -53,5 +66,7 @@ class StorageTableFileReferenceDirectoryTest {
|
||||
assertThat(result.status()).isEqualTo(StorageTableFileReferenceDirectory.Status.AUTHORIZED);
|
||||
assertThat(result.secretRef()).isEqualTo("file:///hive-password?version=1");
|
||||
assertThat(result.toString()).doesNotContain("hive-password").contains("REDACTED");
|
||||
assertThat(directory.resolveForIngestion(10L,20L,30L,40L)).isEqualTo(result);
|
||||
assertThat(directory.resolveForIngestion(ADMIN,99L,30L,40L).status()).isEqualTo(StorageTableFileReferenceDirectory.Status.AUTHORIZED);
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户