提交
This commit is contained in:
+20
-1
@@ -15,9 +15,14 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class OverseasPhase4PermissionSqlContractTest {
|
||||
private static final Pattern CANONICAL = Pattern.compile("platform:overseas-[a-z0-9:-]+");
|
||||
private static final Set<String> CUSTOM_ADMIN_PERMISSIONS = Set.of(
|
||||
"platform:overseas-warehouse:inbound-order:fba-appointment",
|
||||
"platform:overseas-warehouse:inbound-order:smart-dispatch");
|
||||
private static final List<String> REQUIRED = List.of(
|
||||
"platform:overseas-warehouse:last-mile-order:list",
|
||||
"platform:overseas-warehouse:inbound-order:list",
|
||||
"platform:overseas-warehouse:inbound-order:fba-appointment",
|
||||
"platform:overseas-warehouse:inbound-order:smart-dispatch",
|
||||
"platform:overseas-warehouse:relabel-order:status",
|
||||
"platform:overseas-warehouse:pallet:list",
|
||||
"platform:overseas-warehouse:inventory:adjust",
|
||||
@@ -34,9 +39,10 @@ class OverseasPhase4PermissionSqlContractTest {
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
Set<String> catalog = codes(sql);
|
||||
assertThat(sql).contains(REQUIRED.toArray(String[]::new));
|
||||
assertThat(catalog).hasSize(51).noneMatch(code -> code.endsWith(":view"));
|
||||
assertThat(catalog).hasSize(53).noneMatch(code -> code.endsWith(":view"));
|
||||
assertThat(sql).contains("permission_code LIKE 'platform:lastleg:%'", "status='INACTIVE'", "deleted=1");
|
||||
assertThat(sql).doesNotContain(":carton:", ":product:", ":outbound:", ":delivery:");
|
||||
assertCustomAdminGrant(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -48,6 +54,7 @@ class OverseasPhase4PermissionSqlContractTest {
|
||||
.getContentAsString(StandardCharsets.UTF_8));
|
||||
assertThat(codes(sql)).containsAll(moduleCatalog);
|
||||
assertThat(sql).contains("baiyue_iam.iam_permission", "baiyue_iam.iam_role_permission");
|
||||
assertCustomAdminGrant(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,6 +76,18 @@ class OverseasPhase4PermissionSqlContractTest {
|
||||
return values;
|
||||
}
|
||||
|
||||
private static void assertCustomAdminGrant(String sql) {
|
||||
String roleMatch = "UPPER(role.role_code)='PLATFORM_CUSTOM_ADMIN'";
|
||||
int roleIndex = sql.indexOf(roleMatch);
|
||||
assertThat(roleIndex).isGreaterThanOrEqualTo(0);
|
||||
int grantStart = sql.lastIndexOf("INSERT IGNORE INTO", roleIndex);
|
||||
int grantEnd = sql.indexOf(';', roleIndex);
|
||||
assertThat(grantStart).isGreaterThanOrEqualTo(0);
|
||||
assertThat(grantEnd).isGreaterThan(roleIndex);
|
||||
assertThat(codes(sql.substring(grantStart, grantEnd)))
|
||||
.containsExactlyInAnyOrderElementsOf(CUSTOM_ADMIN_PERMISSIONS);
|
||||
}
|
||||
|
||||
private static String repositoryFile(String relativePath) throws Exception {
|
||||
Path path = Path.of(relativePath);
|
||||
if (!Files.exists(path)) path = Path.of("..").resolve(relativePath);
|
||||
|
||||
Reference in New Issue
Block a user