Replace the header "Byt lösenord" link with an Inställningar menu for changing email or password. Email changes are two-step: request with password, confirmation link to the new address, then password again on confirm so a wrong inbox cannot take over the account. - Backend: EmailChangeService, V10 email_change_tokens, confirm API - Frontend: ChangeEmailPage, ConfirmEmailChangePage, header dropdown - E2E: account-settings round-trips, Mailpit verification, wrong-password guard - Flyway: V9 restore for dev DBs, CI migration checks, V10 for email tokens Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.7 KiB
Java
45 lines
1.7 KiB
Java
package se.bilhalsning;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.stream.Stream;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
class FlywayMigrationFilesTest {
|
|
|
|
private static final Pattern VERSION_PATTERN = Pattern.compile("^V(\\d+)__.+\\.sql$");
|
|
private static final Path MIGRATION_DIR = Path.of("src/main/resources/db/migration");
|
|
|
|
@Test
|
|
void shouldUseUniqueVersionNumbersAndValidNames() throws IOException {
|
|
assertTrue(
|
|
Files.isDirectory(MIGRATION_DIR),
|
|
() -> "Expected migration directory at " + MIGRATION_DIR.toAbsolutePath());
|
|
|
|
Set<Integer> versions = new HashSet<>();
|
|
|
|
try (Stream<Path> files = Files.list(MIGRATION_DIR)) {
|
|
for (Path file : files.filter(path -> path.getFileName().toString().endsWith(".sql")).toList()) {
|
|
String name = file.getFileName().toString();
|
|
Matcher matcher = VERSION_PATTERN.matcher(name);
|
|
assertTrue(matcher.matches(), () -> "Invalid migration filename: " + name);
|
|
|
|
int version = Integer.parseInt(matcher.group(1));
|
|
assertFalse(
|
|
versions.contains(version),
|
|
() -> "Duplicate Flyway version V" + version + " in " + MIGRATION_DIR);
|
|
versions.add(version);
|
|
}
|
|
}
|
|
|
|
assertFalse(versions.isEmpty(), "Expected at least one schema migration");
|
|
}
|
|
}
|