Skip to content

Commit b615d16

Browse files
committed
Update SecurityConfigIntegrationTest.java & application-integration-test.yml
1 parent ab6a802 commit b615d16

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

backend/src/integrationTest/java/com/example/phoebe/integration/config/SecurityConfigIntegrationTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ class SecurityConfigIntegrationTest extends BaseIntegrationTest {
4040
private static final String ADMIN_NEWS_ENDPOINT = "/api/admin/news";
4141
private static final String AUTH_HEADER_NAME = "Authorization";
4242

43-
private static final String ADMIN_USERNAME = "admin_test";
44-
private static final String ADMIN_PASSWORD = "admin123_secure_for_tests";
45-
private static final String EDITOR_USERNAME = "editor_test";
43+
// Credentials from V3__insert_sample_data.sql
44+
private static final String ADMIN_USERNAME = "admin";
45+
private static final String ADMIN_PASSWORD = "admin";
46+
47+
// Editor is not in V3, so we create it manually
48+
private static final String EDITOR_USERNAME = "editor_integration";
4649
private static final String EDITOR_PASSWORD = "editor123_secure_for_tests";
50+
4751
private static final String TEST_PASSWORD = "testpassword_for_encoder";
4852

4953
@Autowired
@@ -63,23 +67,28 @@ class SecurityConfigIntegrationTest extends BaseIntegrationTest {
6367

6468
@BeforeEach
6569
void setUp() {
70+
// Only delete extra users, NOT the 'admin' from V3
71+
// But to keep tests isolated, we delete all and recreate minimal set
6672
userRepository.deleteAll();
6773
roleRepository.deleteAll();
6874

75+
// Recreate roles (V3 inserts them, but we ensure consistency)
6976
Role adminRole = new Role("ADMIN", "Administrator role");
7077
Role editorRole = new Role("EDITOR", "Editor role");
7178
adminRole = roleRepository.save(adminRole);
7279
editorRole = roleRepository.save(editorRole);
7380

81+
// Re-create 'admin' exactly as in V3
7482
User admin = new User(
7583
ADMIN_USERNAME,
7684
passwordEncoder.encode(ADMIN_PASSWORD),
77-
"admin@test.com",
85+
"admin@example.com",
7886
true
7987
);
8088
admin.setRoles(Set.of(adminRole));
8189
userRepository.save(admin);
8290

91+
// Create editor manually (not in V3)
8392
User editor = new User(
8493
EDITOR_USERNAME,
8594
passwordEncoder.encode(EDITOR_PASSWORD),
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
spring:
22
jpa:
33
hibernate:
4-
ddl-auto: none
5-
show-sql: false
6-
database-platform: org.hibernate.dialect.MySQL8Dialect
4+
ddl-auto: validate
5+
database-platform: org.hibernate.dialect.MySQLDialect
6+
7+
flyway:
8+
enabled: true
9+
locations:
10+
- classpath:db/migration/common
11+
- classpath:db/migration/mysql
712

813
sql:
914
init:
10-
mode: never
11-
12-
flyway:
13-
enabled: false
15+
mode: never

0 commit comments

Comments
 (0)