mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-10 19:51:00 +00:00
(improvement)(Headless) Fix model list auth checking (#883)
* (improvement)(Headless) Fix model list auth check * (improvement)(Headless) Fix row permission --------- Co-authored-by: jolunoluo
This commit is contained in:
@@ -306,11 +306,16 @@ public class ModelServiceImpl implements ModelService {
|
||||
List<Long> domainIds = domainService.getDomainAuthSet(user, authType)
|
||||
.stream().map(DomainResp::getId)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(domainIds)) {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
if (domainId != null) {
|
||||
if (domainIds.contains(domainId)) {
|
||||
domainIds = Lists.newArrayList(domainId);
|
||||
} else {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
}
|
||||
ModelFilter modelFilter = new ModelFilter();
|
||||
modelFilter.setIncludesDetail(false);
|
||||
modelFilter.setDomainIds(domainIds);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class SchemaAuthTest extends BaseTest {
|
||||
@Test
|
||||
public void test_getModelList_alice() {
|
||||
User user = DataUtils.getUserAlice();
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, 0L, AuthType.ADMIN);
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, null, AuthType.ADMIN);
|
||||
List<Long> expectedModelIds = Lists.newArrayList(1L, 4L);
|
||||
Assertions.assertEquals(expectedModelIds,
|
||||
modelResps.stream().map(ModelResp::getId).collect(Collectors.toList()));
|
||||
@@ -48,7 +48,7 @@ public class SchemaAuthTest extends BaseTest {
|
||||
@Test
|
||||
public void test_getVisibleModelList_alice() {
|
||||
User user = DataUtils.getUserAlice();
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, 0L, AuthType.VISIBLE);
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, null, AuthType.VISIBLE);
|
||||
List<Long> expectedModelIds = Lists.newArrayList(1L, 4L);
|
||||
Assertions.assertEquals(expectedModelIds,
|
||||
modelResps.stream().map(ModelResp::getId).collect(Collectors.toList()));
|
||||
@@ -75,7 +75,7 @@ public class SchemaAuthTest extends BaseTest {
|
||||
@Test
|
||||
public void test_getModelList_jack() {
|
||||
User user = DataUtils.getUserJack();
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, 0L, AuthType.ADMIN);
|
||||
List<ModelResp> modelResps = modelService.getModelListWithAuth(user, null, AuthType.ADMIN);
|
||||
List<Long> expectedModelIds = Lists.newArrayList(1L, 2L, 3L);
|
||||
Assertions.assertEquals(expectedModelIds,
|
||||
modelResps.stream().map(ModelResp::getId).collect(Collectors.toList()));
|
||||
|
||||
@@ -77,4 +77,4 @@ logging:
|
||||
|
||||
inMemoryEmbeddingStore:
|
||||
persistent:
|
||||
path: d://
|
||||
path: /tmp
|
||||
|
||||
Reference in New Issue
Block a user