Merge pull request 'test(auth): align SQL contracts with clean initialization' (#2) from test into main
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
+13
-2
@@ -11,10 +11,21 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class AuthLoginIdentifiersSqlContractTest {
|
||||
@Test
|
||||
void backfillsOnlyUniquelyOwnedPhonesAndKeepsDuplicateLegacyPhonesUnbound() throws Exception {
|
||||
void legacyMigrationBackfillsOnlyUniquelyOwnedPhonesAndKeepsDuplicatesUnbound() throws Exception {
|
||||
assertSafeBackfill(new ClassPathResource("db/auth-login-identifiers.sql")
|
||||
.getContentAsString(StandardCharsets.UTF_8));
|
||||
assertSafeBackfill(Files.readString(unifiedSql(), StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void emptyDatabaseInitializationDeclaresPhoneUniquenessWithoutLegacyBackfill() throws Exception {
|
||||
String sql = Files.readString(unifiedSql(), StandardCharsets.UTF_8);
|
||||
|
||||
assertThat(sql)
|
||||
.contains("phone varchar(32) DEFAULT NULL")
|
||||
.contains("UNIQUE KEY uk_auth_account_phone (phone)")
|
||||
.doesNotContain("phone NOT REGEXP '^1[3-9][0-9]{9}$'")
|
||||
.doesNotContain("HAVING COUNT(DISTINCT auth_user_id) = 1")
|
||||
.doesNotContain("ALTER TABLE auth_account");
|
||||
}
|
||||
|
||||
private static void assertSafeBackfill(String sql) {
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@ class InitialAccountSeedSqlContractTest {
|
||||
|
||||
private static void assertAccountSeed(String sql) {
|
||||
assertThat(sql)
|
||||
.contains("(1000001, 'platform_admin'")
|
||||
.contains("'平台系统管理员', 'ACTIVE'")
|
||||
.containsPattern("\\(1000001\\s*,\\s*'platform_admin'")
|
||||
.containsPattern("'平台系统管理员'\\s*,\\s*'ACTIVE'")
|
||||
.contains("password_change_required")
|
||||
.doesNotContain("merchant_admin")
|
||||
.doesNotContain("IT_TEST")
|
||||
|
||||
Reference in New Issue
Block a user