新增门禁:实现访问授权编排
This commit is contained in:
1 parent
bb16b0b875
commit
20c5d494cf
22 files changed
+2306
-7
No files matched your search
+76
@@ -0,0 +1,76 @@
|
||||
package com.ruoyi.web.controller.train;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Locale;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 009 Migration 静态规范契约测试
|
||||
* 校验 009_dorm_authorization_orchestration.sql 的幂等扩展性、字段健全性与敏感数据规避
|
||||
*/
|
||||
public class DormAuthorizationOrchestrationMigrationContractTest
|
||||
{
|
||||
private File migrationFile;
|
||||
private String sqlContent;
|
||||
|
||||
@Before
|
||||
public void setUp() throws IOException
|
||||
{
|
||||
File direct = new File("../sql/system/kingbase/009_dorm_authorization_orchestration.sql");
|
||||
if (direct.exists()) {
|
||||
migrationFile = direct;
|
||||
} else {
|
||||
migrationFile = new File("sql/system/kingbase/009_dorm_authorization_orchestration.sql");
|
||||
}
|
||||
assertTrue("009 migration script must exist: " + migrationFile.getAbsolutePath(), migrationFile.exists());
|
||||
sqlContent = new String(Files.readAllBytes(migrationFile.toPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColumnsAddedWithIdempotentClause()
|
||||
{
|
||||
String lower = sqlContent.toLowerCase(Locale.ROOT);
|
||||
assertTrue("Must alter table train_dorm_auth", lower.contains("alter table train_dorm_auth"));
|
||||
assertTrue("Must use ADD COLUMN IF NOT EXISTS for credential_type",
|
||||
lower.contains("add column if not exists credential_type"));
|
||||
assertTrue("Must use ADD COLUMN IF NOT EXISTS for auth_status",
|
||||
lower.contains("add column if not exists auth_status"));
|
||||
assertTrue("Must use ADD COLUMN IF NOT EXISTS for latest_operation_id",
|
||||
lower.contains("add column if not exists latest_operation_id"));
|
||||
assertTrue("Must use ADD COLUMN IF NOT EXISTS for operation_version",
|
||||
lower.contains("add column if not exists operation_version"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testZeroPlaintextPasswordColumns()
|
||||
{
|
||||
String lower = sqlContent.toLowerCase(Locale.ROOT);
|
||||
assertFalse("Must NOT add any plain password column", lower.contains("add column if not exists password"));
|
||||
assertFalse("Must NOT add secret column", lower.contains("add column if not exists secret"));
|
||||
assertFalse("Must NOT add plain_password column", lower.contains("plain_password"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoDestructiveDmlOrDrop()
|
||||
{
|
||||
String lower = sqlContent.toLowerCase(Locale.ROOT);
|
||||
assertFalse("Must not drop table", lower.contains("drop table"));
|
||||
assertFalse("Must not drop column", lower.contains("drop column"));
|
||||
assertFalse("Must not truncate table", lower.contains("truncate"));
|
||||
assertFalse("Must not delete rows", lower.contains("delete from"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIndexesCreatedIdempotently()
|
||||
{
|
||||
String lower = sqlContent.toLowerCase(Locale.ROOT);
|
||||
assertTrue("Must have CREATE INDEX IF NOT EXISTS", lower.contains("create index if not exists"));
|
||||
assertTrue("Must index auth_status", lower.contains("idx_dorm_auth_status"));
|
||||
assertTrue("Must index latest_operation_id", lower.contains("idx_dorm_auth_latest_op"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user