test(e2e): seed read-only "reader" user in e2e profile
Adds a "Leser" group (READ_ALL only) and "reader" / "reader123" user to the deterministic e2e seed so the permissions spec can log in as a read-only user without relying on admin-created test data. Refs #48 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -81,7 +81,8 @@ public class DataInitializer {
|
|||||||
@Profile("e2e")
|
@Profile("e2e")
|
||||||
public CommandLineRunner initE2EData(PersonRepository personRepo,
|
public CommandLineRunner initE2EData(PersonRepository personRepo,
|
||||||
DocumentRepository docRepo,
|
DocumentRepository docRepo,
|
||||||
TagRepository tagRepo) {
|
TagRepository tagRepo,
|
||||||
|
PasswordEncoder passwordEncoder) {
|
||||||
return args -> {
|
return args -> {
|
||||||
if (personRepo.count() > 0) {
|
if (personRepo.count() > 0) {
|
||||||
log.info("E2E seed: Daten bereits vorhanden, überspringe.");
|
log.info("E2E seed: Daten bereits vorhanden, überspringe.");
|
||||||
@@ -165,8 +166,21 @@ public class DataInitializer {
|
|||||||
.receivers(Set.of(otto))
|
.receivers(Set.of(otto))
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
log.info("E2E seed: {} Personen, {} Tags, {} Dokumente erstellt.",
|
// ── Read-only user (for permissions E2E tests) ───────────────────
|
||||||
personRepo.count(), tagRepo.count(), docRepo.count());
|
// Username: reader / Password: reader123
|
||||||
|
// Has only READ_ALL — used to assert write controls are absent.
|
||||||
|
UserGroup leserGroup = groupRepository.save(UserGroup.builder()
|
||||||
|
.name("Leser")
|
||||||
|
.permissions(Set.of("READ_ALL"))
|
||||||
|
.build());
|
||||||
|
userRepository.save(AppUser.builder()
|
||||||
|
.username("reader")
|
||||||
|
.password(passwordEncoder.encode("reader123"))
|
||||||
|
.groups(Set.of(leserGroup))
|
||||||
|
.build());
|
||||||
|
|
||||||
|
log.info("E2E seed: {} Personen, {} Tags, {} Dokumente, {} Benutzer erstellt.",
|
||||||
|
personRepo.count(), tagRepo.count(), docRepo.count(), userRepository.count());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user