[Developer] #619 focus POC on KB VPD permissions

This commit is contained in:
devmrko
2026-07-07 16:02:22 +09:00
parent ef944a6758
commit 2ef04e6ab2
18 changed files with 1238 additions and 167 deletions

View File

@@ -221,6 +221,83 @@ class PermissionServiceTest {
.hasMessageContaining("값이 필요");
}
@Test
void acceptsKbFilterConditionCodesWithoutAStaticRuleValue() {
var command = new PermissionSetCommand(
10L,
1L,
"SELECT",
"ALLOW",
List.of(
new RuleCommand("DEPT_CODE", "OWN_CONTRACT", null),
new RuleCommand("OWNER_EMP_NO", "CHANNEL_CUSTOMER", null)
),
List.of()
);
permissionService.savePermissionSet(command);
FakePermissionMapper mapper = (FakePermissionMapper) permissionMapper;
assertThat(mapper.insertedRules)
.extracting(PermissionRule::ruleType)
.containsExactly("OWN_CONTRACT", "CHANNEL_CUSTOMER");
assertThat(mapper.insertedRules)
.extracting(PermissionRule::ruleValue)
.containsExactly("", "");
}
@Test
void acceptsStaticSqlPredicateAlongsideAContextCondition() {
var command = new PermissionSetCommand(
10L,
1L,
"SELECT",
"ALLOW",
List.of(
new RuleCommand("DEPT_CODE", "OWN_CONTRACT", null),
new RuleCommand(null, "STATIC_SQL", "DEPT_CODE IN ('HR', 'FIN')")
),
List.of()
);
permissionService.savePermissionSet(command);
FakePermissionMapper mapper = (FakePermissionMapper) permissionMapper;
assertThat(mapper.insertedRules)
.extracting(PermissionRule::ruleType)
.containsExactly("OWN_CONTRACT", "STATIC_SQL");
assertThat(mapper.insertedRules)
.extracting(PermissionRule::ruleValue)
.containsExactly("", "DEPT_CODE IN ('HR', 'FIN')");
}
@Test
void rejectsStaticSqlStatementOrUnknownColumn() {
var statementCommand = new PermissionSetCommand(
10L,
1L,
"SELECT",
"ALLOW",
List.of(new RuleCommand(null, "STATIC_SQL", "DEPT_CODE = 'HR'; DELETE FROM CB_APP_USER")),
List.of()
);
var unknownColumnCommand = new PermissionSetCommand(
10L,
1L,
"SELECT",
"ALLOW",
List.of(new RuleCommand(null, "STATIC_SQL", "UNSUPPORTED_COLUMN = 'HR'")),
List.of()
);
assertThatThrownBy(() -> permissionService.savePermissionSet(statementCommand))
.isInstanceOf(AppException.class)
.hasMessageContaining("단일 WHERE");
assertThatThrownBy(() -> permissionService.savePermissionSet(unknownColumnCommand))
.isInstanceOf(AppException.class)
.hasMessageContaining("보호 객체 컬럼");
}
@Test
void acceptsMultipleVisibleColumns() {
var command = new PermissionSetCommand(

View File

@@ -157,14 +157,16 @@ class GuidedFlowTemplateTest {
}
@Test
void permissionWizardExplainsTagRulesAndOrSemantics() throws IOException {
void permissionWizardExplainsConditionCodeAndStaticSqlSemantics() throws IOException {
String html = template("permissions.html");
String javascript = Files.readString(Path.of("src/main/resources/static/js/app.js"));
assertThat(html)
.contains("value=\"TAG\">특정 기술 태그")
.contains("TECH_TAG")
.contains("태그를 여러 개 추가하면")
.contains("value=\"OWN_CUSTOMER\">본인 담당 고객")
.contains("value=\"STATIC_SQL\">정적 SQL 조건식")
.contains("행 규칙의 두 가지 적용 방식 보기")
.contains("한 권한 안의 규칙은 모두 AND")
.contains("서로 다른 역할의 ALLOW 권한은 OR")
.contains("data-wizard-validation")
.contains("다른 조건 규칙은 한 권한에 함께 저장할 수 없습니다")
.contains("저장 영향")