Skip to content

[Feat]: User / Administrator login #49#120

Merged
pol-rivero merged 5 commits intoUdL-EPS-SoftArch-Igualada:mainfrom
MireiaTerri:feature_userAdmin
Mar 16, 2026
Merged

[Feat]: User / Administrator login #49#120
pol-rivero merged 5 commits intoUdL-EPS-SoftArch-Igualada:mainfrom
MireiaTerri:feature_userAdmin

Conversation

@MireiaTerri
Copy link
Contributor

Closes #49

Copilot AI review requested due to automatic review settings March 16, 2026 15:25
@udl-softarch udl-softarch bot added the pr-not-ready This PR cannot be merged until you have reviewed the code analysis results. label Mar 16, 2026
@udl-softarch
Copy link

udl-softarch bot commented Mar 16, 2026

Thank you for your PR @MireiaTerri! Now, you should wait for the automated code analysis by CodeRabbit, Copilot and SonarQube.
Please review all warnings carefully, as some of them might be false positives.

Once you are confident that you have fixed all the detected issues and this PR is ready to be merged, add a comment with exactly one word: ready.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 16, 2026

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Administrator account management (create, retrieve, update, delete).
    • Login and identity endpoints with a new Login feature.
  • Removed

    • Record management UI/API flows and related test scenarios removed.
  • Security

    • All mutating operations now require Administrator privileges; anonymous/user access rules adjusted.
    • Default admin account seeded on startup.
  • Tests

    • End-to-end scenarios added/updated to validate admin flows and access control.

Walkthrough

Replaces Record-related domain, repository, handlers, and tests with an Administrator subclass and repository; seeds the DB with a default admin; tightens security so POST/PUT/PATCH/DELETE require ADMIN; and adds/updates Cucumber stepdefs and feature files for admin login and administrator CRUD.

Changes

Cohort / File(s) Summary
Domain model
src/main/java/cat/udl/eps/softarch/fll/domain/User.java, src/main/java/cat/udl/eps/softarch/fll/domain/Administrator.java, src/main/java/cat/udl/eps/softarch/fll/domain/Record.java
Adds JPA joined-inheritance on User; introduces Administrator (ROLE_ADMIN). Deletes the Record entity and its factory/validation.
Repositories
src/main/java/cat/udl/eps/softarch/fll/repository/AdministratorRepository.java, src/main/java/cat/udl/eps/softarch/fll/repository/RecordRepository.java
Adds AdministratorRepository with findByIdContaining(...); deletes RecordRepository.
Config & DB init
src/main/java/cat/udl/eps/softarch/fll/config/WebSecurityConfig.java, src/main/java/cat/udl/eps/softarch/fll/config/DBInitialization.java
WebSecurityConfig now requires ADMIN for POST/PUT/PATCH/DELETE globally; DBInitialization now injects AdministratorRepository and seeds a default admin.
Event handlers
src/main/java/cat/udl/eps/softarch/fll/handler/RecordEventHandler.java
Removes RecordEventHandler and its timestamping handlers.
Tests — new stepdefs
src/test/java/cat/udl/eps/softarch/fll/steps/AdminAccessControlStepDefs.java, src/test/java/cat/udl/eps/softarch/fll/steps/LoginStepDefs.java, src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java
Adds step definitions for admin access control, login/identity checks, and administrator CRUD flows.
Tests — deleted/removed record tests
src/test/java/cat/udl/eps/softarch/fll/steps/ManageRecordStepDefs.java, src/test/java/cat/udl/eps/softarch/fll/domain/RecordValidationTest.java, src/test/resources/features/ManageRecord.feature
Removes record-focused integration stepdefs, unit tests, and feature file tied to the deleted Record entity.
Tests — modified stepdefs
src/test/java/.../steps/* (multiple files: AssignCoachStepDefs.java, AwardAndMatchStepDefs.java, ManageJudgeStepDefs.java, ManageScientificProjectStepDefs.java, ManageAdministratorStepDefs.java, ManageRecordStepDefs.java (deleted), etc.)
Centralizes or changes authentication usage across many stepdefs (switch to Authentication helper or httpBasic) and adjusts request construction accordingly.
Gherkin features — new
src/test/resources/features/AdminAccessControl.feature, src/test/resources/features/Login.feature, src/test/resources/features/ManageAdministrator.feature
Adds features for admin access control, login scenarios, and administrator management.
Gherkin features — updated
src/test/resources/features/* (many features)
Updates many feature backgrounds and scenarios to use admin/password (replacing demo/user variants), adds logout and auth-related assertions where applicable.
Test helpers
src/test/java/cat/udl/eps/softarch/fll/steps/AuthenticationStepDefs.java
Adds iLogout() to clear stored credentials for tests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title '[Feat]: User / Administrator login #49' clearly and specifically describes the main change—implementing a login system for Administrator users, which is the core objective of this PR.
Description check ✅ Passed The PR description 'Closes #49' directly references the linked issue and is related to the changeset's objectives, though minimal in detail.
Linked Issues check ✅ Passed All coding requirements from issue #49 are met: Record class removed, Administrator entity created, CRUD endpoints implemented, DBInitialization updated with admin seed, WebSecurityConfig restricted POST/PUT/PATCH/DELETE to admins, comprehensive Cucumber tests added for login and administrator management, and existing tests updated to verify access control.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #49 requirements. The PR updates step definitions, feature files, and test authentication to implement the login and administrator access control system as specified.
Code Style ✅ Passed Code adheres to English language requirement with clear variable naming, no non-English comments, and appropriate indentation levels throughout all modified files.
Has Tests ✅ Passed The pull request contains comprehensive tests covering 17 scenarios across three feature files with both success and failure cases validating CRUD, authentication, and access control.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.

Change the reviews.profile setting to assertive to make CodeRabbit's nitpick more issues in your PRs.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements administrator-based authentication/authorization and introduces an Administrator subtype of User, while removing the template Record example.

Changes:

  • Add Administrator entity + AdministratorRepository, seed a default admin, and enforce admin-only write operations in WebSecurityConfig.
  • Remove the template Record domain/repository/handlers/tests.
  • Update/add Cucumber features and step definitions for login, administrator CRUD, and access control.

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/main/java/cat/udl/eps/softarch/fll/config/WebSecurityConfig.java Restricts POST/PUT/PATCH/DELETE to ROLE_ADMIN; adds/keeps specific GET rules.
src/main/java/cat/udl/eps/softarch/fll/config/DBInitialization.java Seeds default admin user and keeps demo for tests.
src/main/java/cat/udl/eps/softarch/fll/domain/User.java Enables JPA inheritance for User subclasses.
src/main/java/cat/udl/eps/softarch/fll/domain/Administrator.java Adds Administrator subtype with ROLE_ADMIN authorities.
src/main/java/cat/udl/eps/softarch/fll/repository/AdministratorRepository.java Exposes Admin CRUD/search repository via Spring Data REST.
src/main/java/cat/udl/eps/softarch/fll/domain/Record.java Removes template Record entity.
src/main/java/cat/udl/eps/softarch/fll/repository/RecordRepository.java Removes template Record repository.
src/main/java/cat/udl/eps/softarch/fll/handler/RecordEventHandler.java Removes template Record event handler.
src/test/java/cat/udl/eps/softarch/fll/domain/RecordValidationTest.java Removes template Record validation tests.
src/test/java/cat/udl/eps/softarch/fll/steps/ManageRecordStepDefs.java Removes Cucumber step definitions for Record.
src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java Adds steps for admin CRUD requests/assertions.
src/test/java/cat/udl/eps/softarch/fll/steps/LoginStepDefs.java Adds steps for /identity checks.
src/test/java/cat/udl/eps/softarch/fll/steps/AdminAccessControlStepDefs.java Adds steps for public read checks (editions list).
src/test/java/cat/udl/eps/softarch/fll/steps/SearchVenueStepDefs.java Switches to shared auth helper; currently has duplicate imports.
src/test/java/cat/udl/eps/softarch/fll/steps/ManageJudgeStepDefs.java Switches to shared auth helper; currently has duplicate imports.
src/test/java/cat/udl/eps/softarch/fll/steps/AssignCoachStepDefs.java Switches to shared auth helper; currently has duplicate imports.
src/test/java/cat/udl/eps/softarch/fll/steps/AwardAndMatchStepDefs.java Uses basic auth for setup; keeps shared auth for requests.
src/test/resources/features/Login.feature Adds login/identity scenarios for admin and regular users.
src/test/resources/features/ManageAdministrator.feature Adds admin CRUD access-control scenarios (missing update coverage).
src/test/resources/features/AdminAccessControl.feature Adds basic admin-vs-user-vs-anon access control scenarios.
src/test/resources/features/ManageRecord.feature Removes Record feature.
src/test/resources/features/Award.feature Adjusts scenarios to log in as admin (reduces public-read coverage).
src/test/resources/features/MatchResult.feature Adjusts scenarios to log in as admin (reduces public-read coverage).
src/test/resources/features/assign_coach.feature Adds admin login background.
src/test/resources/features/TeamMember.feature Uses admin login in background.
src/test/resources/features/TeamEditionRegistration.feature Uses admin login in background.
src/test/resources/features/SearchVenue.feature Uses admin login in background.
src/test/resources/features/RoundSearchByEdition.feature Uses admin login in scenarios.
src/test/resources/features/RegisterUser.feature Adjusts authenticated-registration scenario to use an actually registered user.
src/test/resources/features/MatchTableAssignment.feature Uses admin login in background.
src/test/resources/features/MatchScoreRegistration.feature Uses admin login in scenarios.
src/test/resources/features/MatchAssignment.feature Uses admin login in background.
src/test/resources/features/ManageVenue.feature Uses admin login across scenarios.
src/test/resources/features/ManageScientificProject.feature Uses admin login across scenarios.
src/test/resources/features/ManageMediaContent.feature Uses admin login in background.
src/test/resources/features/ManageJudge.feature Uses admin login in background.
src/test/resources/features/ManageFloater.feature Uses admin login in background.
src/test/resources/features/ManageEdition.feature Uses admin login in background.
src/test/resources/features/EditionVolunteers.feature Uses admin login in scenarios.
src/test/resources/features/EditionLifecycle.feature Uses admin login in background.
src/test/resources/features/EditionCompetitionTables.feature Uses admin login in scenarios.
src/test/resources/features/Coach.feature Updates admin password used in background.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/resources/features/Coach.feature (1)

6-14: ⚠️ Potential issue | 🔴 Critical

The test will fail with the new security configuration because it uses a regular User instead of an Administrator.

The step "There is a registered user with username 'admin'..." creates a plain User entity with ROLE_USER (from RegisterStepDefs.java:36-41). However, the coach creation endpoint requires a POST request, which is restricted to users with ROLE_ADMIN per WebSecurityConfig.java:34: .requestMatchers(HttpMethod.POST, "/**").hasRole("ADMIN").

Since User.getAuthorities() returns ROLE_USER and Administrator.getAuthorities() returns ROLE_ADMIN, the test will receive a 403 Forbidden response when attempting to create a coach with a non-administrator user.

Change the step definition to create an Administrator, or update the feature file to use a step that explicitly creates an admin user with the appropriate role.

🧹 Nitpick comments (16)
src/test/resources/features/Award.feature (1)

6-6: Optional: move repeated login step into Background

The same Given I login as "admin"... step is duplicated across all scenarios. Using Background would keep the feature shorter and easier to maintain.

Also applies to: 11-11, 19-19, 26-26, 34-34

src/test/java/cat/udl/eps/softarch/fll/steps/SearchVenueStepDefs.java (1)

6-7: Remove duplicate hasSize static import.

hasSize is imported twice; keep a single import to avoid redundancy.

Proposed cleanup
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.hasSize;
src/test/resources/features/MatchTableAssignment.feature (1)

8-9: Unnecessary user registration in Background.

Line 8 registers a user with username "user", but line 9 logs in as "admin" (seeded by DBInitialization). The registered "user" is never referenced in any scenario and appears to be leftover from before the admin-based authentication change.

Consider removing the unused user registration to keep the test setup minimal and clear:

Suggested fix
 	Background:
 		Given the match table assignment system is empty
-		And There is a registered user with username "user" and password "password" and email "user@sample.app"
 		And I login as "admin" with password "password"
src/test/resources/features/MatchAssignment.feature (1)

8-9: Unnecessary user registration in Background.

Same issue as in MatchTableAssignment.feature: Line 8 registers "user" but line 9 logs in as "admin". The registered user is not used in any scenario.

Suggested fix
 	Background:
 		Given the match assignment system is empty
-		And There is a registered user with username "user" and password "password" and email "user@sample.app"
 		And I login as "admin" with password "password"
src/test/resources/features/MatchResult.feature (1)

11-12: Potentially redundant user registration.

Line 11 attempts to register "admin", but DBInitialization already seeds the admin user at startup. Per the RegisterStepDefs implementation, if the user already exists, the registration is skipped. This means the email "admin@fll.udl.cat" specified here may not be applied.

Consider removing the redundant registration step for clarity, or verify that the scenario doesn't depend on the specific email value:

Suggested fix
   Scenario: Direct MatchResult creation is disabled
-    Given There is a registered user with username "admin" and password "password" and email "admin@fll.udl.cat"
-    And I login as "admin" with password "password"
+    Given I login as "admin" with password "password"
     And The dependencies exist
src/test/resources/features/ManageEdition.feature (1)

7-8: Unnecessary user registration in Background.

Line 7 registers a user with username "user", but line 8 logs in as "admin". The registered "user" is not referenced in any scenario. This is the same pattern seen in MatchTableAssignment.feature and MatchAssignment.feature.

Suggested fix
   Background:
-    Given There is a registered user with username "user" and password "password" and email "user@sample.app"
-    And I login as "admin" with password "password"
+    Given I login as "admin" with password "password"
src/test/resources/features/ManageMediaContent.feature (1)

2-8: Update feature description and consider removing unused user registration.

Two minor inconsistencies:

  1. Line 3 says "As a user" but the test now logs in as "admin". Consider updating to "As an admin" for consistency.
  2. Line 7 registers a "user" that appears unused since line 8 logs in as "admin".
📝 Suggested update
 Feature: Manage MediaContent
     In order to manage media content
-    As a user
+    As an admin
     I want to be able to create, retrieve, update and delete media content

   Background:
-    Given There is a registered user with username "user" and password "password" and email "user@sample.app"
-    And I login as "admin" with password "password"
+    Given I login as "admin" with password "password"
src/test/resources/features/RoundSearchByEdition.feature (1)

6-22: LGTM - consider extracting login to Background.

The authentication change to "admin" is correct. As an optional improvement, the repeated login step on lines 7 and 18 could be moved to a Background section to reduce duplication.

♻️ Optional DRY refactor
+  Background:
+    Given I login as "admin" with password "password"
+
   Scenario: Retrieve all rounds for an edition
-    Given I login as "admin" with password "password"
-    And An edition exists with year 2025 and venue "Test Venue" and description "Round search test"
+    Given An edition exists with year 2025 and venue "Test Venue" and description "Round search test"
     ...

   Scenario: Returns empty list when edition has no rounds
-    Given I login as "admin" with password "password"
-    And An edition exists with year 2026 and venue "Empty Venue" and description "No rounds edition"
+    Given An edition exists with year 2026 and venue "Empty Venue" and description "No rounds edition"
src/test/resources/features/ManageVenue.feature (1)

2-7: Update feature description and consider using Background for shared login.

Two improvements to consider:

  1. Line 3 says "As a user" but all scenarios now log in as "admin" - update for consistency.
  2. The login step is repeated in all 6 scenarios. Moving it to a Background section would reduce duplication.
♻️ Suggested refactor
 Feature: Manage Venue
     In order to manage venues
-    As a user
+    As an admin
     I want to be able to create, retrieve, edit and delete venues

+    Background:
+        Given I login as "admin" with password "password"
+
     Scenario: Create a venue
-        Given I login as "admin" with password "password"
-        And There is no venue with name "My Venue"
+        Given There is no venue with name "My Venue"
         ...

Apply the same pattern to remove the login step from the remaining 5 scenarios.

src/test/resources/features/EditionLifecycle.feature (1)

6-8: Consider removing the unused user registration step.

Line 7 registers a "user" but line 8 logs in as "admin" (seeded by DBInitialization). The scenarios don't appear to reference the registered "user", so this step may be unnecessary setup.

♻️ Suggested cleanup
   Background:
-    Given There is a registered user with username "user" and password "password" and email "user@sample.app"
-    And I login as "admin" with password "password"
+    Given I login as "admin" with password "password"
src/test/resources/features/TeamEditionRegistration.feature (1)

6-8: Consider removing the unused user registration step.

Line 7 registers a "user" but line 8 logs in as "admin" instead. None of the 8 scenarios in this feature reference the registered "user"—all scenarios operate with admin credentials and use separate test teams like "LegoStars", "Team19", "RacerA", and "RacerB". Removing this unused registration would simplify the Background setup without affecting any test behavior.

src/test/resources/features/ManageAdministrator.feature (1)

1-5: Consider adding update and public read scenarios.

The feature description mentions "update" but no update (PUT/PATCH) scenario is included. Additionally, per the requirements, reads should be public—a scenario verifying anonymous retrieval of administrators would strengthen coverage.

src/main/java/cat/udl/eps/softarch/fll/config/WebSecurityConfig.java (1)

34-37: Consider extracting the "ADMIN" literal to a constant.

The role name "ADMIN" is duplicated 4 times. Extracting it to a constant improves maintainability and addresses the SonarCloud finding.

Proposed refactor
 public class WebSecurityConfig {
+	private static final String ROLE_ADMIN = "ADMIN";
+
 	`@Value`("${allowed-origins}")
 	String[] allowedOrigins;

 	`@Bean`
 	protected SecurityFilterChain securityFilterChain(HttpSecurity http) {
 		http.authorizeHttpRequests(auth -> auth
 				.requestMatchers(HttpMethod.GET, "/identity").authenticated()
 				.requestMatchers(HttpMethod.GET, "/users").authenticated()
 				.requestMatchers(HttpMethod.GET, "/editions/*/volunteers").authenticated()
 				.requestMatchers(HttpMethod.POST, "/users").anonymous()
 				.requestMatchers(HttpMethod.POST, "/users/*").denyAll()
-				.requestMatchers(HttpMethod.POST, "/**").hasRole("ADMIN")
-				.requestMatchers(HttpMethod.PUT, "/**").hasRole("ADMIN")
-				.requestMatchers(HttpMethod.PATCH, "/**").hasRole("ADMIN")
-				.requestMatchers(HttpMethod.DELETE, "/**").hasRole("ADMIN")
+				.requestMatchers(HttpMethod.POST, "/**").hasRole(ROLE_ADMIN)
+				.requestMatchers(HttpMethod.PUT, "/**").hasRole(ROLE_ADMIN)
+				.requestMatchers(HttpMethod.PATCH, "/**").hasRole(ROLE_ADMIN)
+				.requestMatchers(HttpMethod.DELETE, "/**").hasRole(ROLE_ADMIN)
src/main/java/cat/udl/eps/softarch/fll/domain/Administrator.java (1)

19-24: Consider including ROLE_USER for admin users.

The Administrator returns only ROLE_ADMIN. If any endpoints or logic check specifically for ROLE_USER, administrators would be excluded. A common pattern is to grant admins both roles.

Optional: Grant both roles to administrators
 	`@Override`
 	`@JsonValue`(value = false)
 	`@JsonProperty`(access = JsonProperty.Access.READ_ONLY)
 	public Collection<? extends GrantedAuthority> getAuthorities() {
-		return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_ADMIN");
+		return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_ADMIN,ROLE_USER");
 	}
src/main/java/cat/udl/eps/softarch/fll/config/DBInitialization.java (2)

30-40: Remove inline comments from this class.

Please replace these with self-explanatory structure (e.g., extracted private methods), since inline comments are disallowed here.

As per coding guidelines, "**/*.{java,ts,tsx,js,jsx,py,go,rb,cs}: Code must be self-documenting with clear variable names and types; inline comments are not allowed (Javadoc is permitted)".


39-48: Flatten the nested if to reduce branching.

This can be expressed as a single guard condition and keeps initializeDatabase() easier to scan.

Suggested refactor
-		if (Arrays.asList(activeProfiles.split(",")).contains("test")) {
-			// Testing instances
-			if (!userRepository.existsById("demo")) {
-				User user = new User();
-				user.setEmail("demo@sample.app");
-				user.setId("demo");
-				user.setPassword(defaultPassword);
-				user.encodePassword();
-				userRepository.save(user);
-			}
-		}
+		if (Arrays.asList(activeProfiles.split(",")).contains("test")
+				&& !userRepository.existsById("demo")) {
+			User user = new User();
+			user.setEmail("demo@sample.app");
+			user.setId("demo");
+			user.setPassword(defaultPassword);
+			user.encodePassword();
+			userRepository.save(user);
+		}

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ace61e2b-bc22-4c6a-9b07-e2adadbbc21c

📥 Commits

Reviewing files that changed from the base of the PR and between af7c540 and 51ea200.

📒 Files selected for processing (42)
  • src/main/java/cat/udl/eps/softarch/fll/config/DBInitialization.java
  • src/main/java/cat/udl/eps/softarch/fll/config/WebSecurityConfig.java
  • src/main/java/cat/udl/eps/softarch/fll/domain/Administrator.java
  • src/main/java/cat/udl/eps/softarch/fll/domain/Record.java
  • src/main/java/cat/udl/eps/softarch/fll/domain/User.java
  • src/main/java/cat/udl/eps/softarch/fll/handler/RecordEventHandler.java
  • src/main/java/cat/udl/eps/softarch/fll/repository/AdministratorRepository.java
  • src/main/java/cat/udl/eps/softarch/fll/repository/RecordRepository.java
  • src/test/java/cat/udl/eps/softarch/fll/domain/RecordValidationTest.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/AdminAccessControlStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/AssignCoachStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/AwardAndMatchStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/LoginStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageJudgeStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageRecordStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/SearchVenueStepDefs.java
  • src/test/resources/features/AdminAccessControl.feature
  • src/test/resources/features/Award.feature
  • src/test/resources/features/Coach.feature
  • src/test/resources/features/EditionCompetitionTables.feature
  • src/test/resources/features/EditionLifecycle.feature
  • src/test/resources/features/EditionVolunteers.feature
  • src/test/resources/features/Login.feature
  • src/test/resources/features/ManageAdministrator.feature
  • src/test/resources/features/ManageEdition.feature
  • src/test/resources/features/ManageFloater.feature
  • src/test/resources/features/ManageJudge.feature
  • src/test/resources/features/ManageMediaContent.feature
  • src/test/resources/features/ManageRecord.feature
  • src/test/resources/features/ManageScientificProject.feature
  • src/test/resources/features/ManageVenue.feature
  • src/test/resources/features/MatchAssignment.feature
  • src/test/resources/features/MatchResult.feature
  • src/test/resources/features/MatchScoreRegistration.feature
  • src/test/resources/features/MatchTableAssignment.feature
  • src/test/resources/features/RegisterUser.feature
  • src/test/resources/features/RoundSearchByEdition.feature
  • src/test/resources/features/SearchVenue.feature
  • src/test/resources/features/TeamEditionRegistration.feature
  • src/test/resources/features/TeamMember.feature
  • src/test/resources/features/assign_coach.feature
💤 Files with no reviewable changes (6)
  • src/main/java/cat/udl/eps/softarch/fll/handler/RecordEventHandler.java
  • src/main/java/cat/udl/eps/softarch/fll/repository/RecordRepository.java
  • src/test/java/cat/udl/eps/softarch/fll/domain/RecordValidationTest.java
  • src/main/java/cat/udl/eps/softarch/fll/domain/Record.java
  • src/test/resources/features/ManageRecord.feature
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageRecordStepDefs.java

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/java/cat/udl/eps/softarch/fll/steps/ManageScientificProjectStepDefs.java (1)

79-80: Hardcoded admin credentials are duplicated across setup calls.

This creates brittle test coupling and scattered auth config. Extract one helper for privileged setup auth and reuse it.

♻️ Suggested refactor
+import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic;
+import org.springframework.test.web.servlet.request.RequestPostProcessor;
...
+	private RequestPostProcessor adminAuth() {
+		return httpBasic("admin", "password");
+	}
...
-						.with(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic("admin", "password")))
+						.with(adminAuth()))
...
-						.with(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic("admin", "password")))
+						.with(adminAuth()))
...
-						.with(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic("admin", "password")));
+						.with(adminAuth()));
...
-						.with(org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.httpBasic("admin", "password")));
+						.with(adminAuth()));

Also applies to: 103-104, 207-213, 225-231


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1df07e85-d598-4abf-bb6a-1d9d9b3a428f

📥 Commits

Reviewing files that changed from the base of the PR and between 51ea200 and d267cf0.

📒 Files selected for processing (11)
  • src/test/java/cat/udl/eps/softarch/fll/steps/AssignCoachStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/AuthenticationStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageJudgeStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageScientificProjectStepDefs.java
  • src/test/java/cat/udl/eps/softarch/fll/steps/SearchVenueStepDefs.java
  • src/test/resources/features/Award.feature
  • src/test/resources/features/ManageAdministrator.feature
  • src/test/resources/features/ManageScientificProject.feature
  • src/test/resources/features/MatchResult.feature
  • src/test/resources/features/TeamMember.feature
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/test/java/cat/udl/eps/softarch/fll/steps/SearchVenueStepDefs.java
  • src/test/resources/features/TeamMember.feature
  • src/test/resources/features/MatchResult.feature
  • src/test/resources/features/ManageScientificProject.feature
  • src/test/resources/features/ManageAdministrator.feature
  • src/test/java/cat/udl/eps/softarch/fll/steps/AssignCoachStepDefs.java

Copilot AI review requested due to automatic review settings March 16, 2026 18:17
@sonarqubecloud
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java (1)

70-73: Add an explicit success status assertion in the retrieval assertion step.

theRetrievedAdministratorHasEmail checks only the payload field. Adding status().isOk() makes failures clearer and tighter.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f428fc1e-bccc-45b6-be2e-ee50bbc8ec9b

📥 Commits

Reviewing files that changed from the base of the PR and between d267cf0 and 416ec02.

📒 Files selected for processing (1)
  • src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java

@MireiaTerri
Copy link
Contributor Author

Ready

@udl-softarch udl-softarch bot removed the pr-not-ready This PR cannot be merged until you have reviewed the code analysis results. label Mar 16, 2026
@udl-softarch udl-softarch bot requested a review from pol-rivero March 16, 2026 18:25
@udl-softarch
Copy link

udl-softarch bot commented Mar 16, 2026

This PR is now marked as ready to be merged.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements administrator support and access control so that write operations require an admin login, while removing the template “Record” example entity and updating/adding Cucumber coverage for login/admin flows.

Changes:

  • Adds Administrator as a User subtype, exposes it via AdministratorRepository, and seeds a default admin in DBInitialization.
  • Tightens WebSecurityConfig to require ROLE_ADMIN for POST/PUT/PATCH/DELETE across the API.
  • Updates many Cucumber scenarios/step defs to authenticate via the shared AuthenticationStepDefs flow; adds new login/admin CRUD/access-control features; removes Record-related code/tests.

Reviewed changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/test/resources/features/assign_coach.feature Logs in before coach assignment scenario.
src/test/resources/features/TeamMember.feature Switches background login to admin for write operations.
src/test/resources/features/TeamEditionRegistration.feature Switches background login to admin.
src/test/resources/features/SearchVenue.feature Switches background login to admin.
src/test/resources/features/RoundSearchByEdition.feature Switches scenarios to log in as admin.
src/test/resources/features/RegisterUser.feature Adjusts “already authenticated” case to use an existing user.
src/test/resources/features/MatchTableAssignment.feature Switches background login to admin.
src/test/resources/features/MatchScoreRegistration.feature Switches scenarios to log in as admin.
src/test/resources/features/MatchResult.feature Uses admin login for the “direct creation disabled” check.
src/test/resources/features/MatchAssignment.feature Switches background login to admin.
src/test/resources/features/ManageVenue.feature Switches venue CRUD scenarios to admin login.
src/test/resources/features/ManageScientificProject.feature Switches scenarios to admin login for project writes.
src/test/resources/features/ManageRecord.feature Removes Record feature (template cleanup).
src/test/resources/features/ManageMediaContent.feature Switches background login to admin.
src/test/resources/features/ManageJudge.feature Switches background login to admin.
src/test/resources/features/ManageFloater.feature Switches background login to admin.
src/test/resources/features/ManageEdition.feature Switches background login to admin.
src/test/resources/features/ManageAdministrator.feature Adds Administrator CRUD/authorization scenarios.
src/test/resources/features/Login.feature Adds login + identity verification scenarios.
src/test/resources/features/EditionVolunteers.feature Switches scenarios to admin login where needed.
src/test/resources/features/EditionLifecycle.feature Switches background login to admin.
src/test/resources/features/EditionCompetitionTables.feature Switches scenarios to admin login.
src/test/resources/features/Coach.feature Normalizes admin credentials to password.
src/test/resources/features/Award.feature Uses admin for writes and logs out to verify public reads.
src/test/resources/features/AdminAccessControl.feature Adds new access-control feature scenarios (admin-only writes / public reads).
src/test/java/cat/udl/eps/softarch/fll/steps/SearchVenueStepDefs.java Uses shared authentication helper instead of mock user principal.
src/test/java/cat/udl/eps/softarch/fll/steps/ManageScientificProjectStepDefs.java Adjusts auth usage and adds setup helpers for dependencies.
src/test/java/cat/udl/eps/softarch/fll/steps/ManageRecordStepDefs.java Removes Record step definitions (template cleanup).
src/test/java/cat/udl/eps/softarch/fll/steps/ManageJudgeStepDefs.java Uses shared authentication helper instead of mock user principal.
src/test/java/cat/udl/eps/softarch/fll/steps/ManageAdministratorStepDefs.java Adds step definitions for Administrator CRUD flows.
src/test/java/cat/udl/eps/softarch/fll/steps/LoginStepDefs.java Adds identity-check step definitions for login feature.
src/test/java/cat/udl/eps/softarch/fll/steps/AwardAndMatchStepDefs.java Updates dependency-setup requests to authenticate as admin.
src/test/java/cat/udl/eps/softarch/fll/steps/AuthenticationStepDefs.java Adds logout step (clears basic-auth credentials).
src/test/java/cat/udl/eps/softarch/fll/steps/AssignCoachStepDefs.java Uses shared authentication helper instead of mock user principal.
src/test/java/cat/udl/eps/softarch/fll/steps/AdminAccessControlStepDefs.java Adds step to retrieve editions list for access-control feature.
src/test/java/cat/udl/eps/softarch/fll/domain/RecordValidationTest.java Removes Record unit test (template cleanup).
src/main/java/cat/udl/eps/softarch/fll/repository/RecordRepository.java Removes Record repository (template cleanup).
src/main/java/cat/udl/eps/softarch/fll/repository/AdministratorRepository.java Adds Administrator repository (Spring Data REST exposure).
src/main/java/cat/udl/eps/softarch/fll/handler/RecordEventHandler.java Removes Record event handler (template cleanup).
src/main/java/cat/udl/eps/softarch/fll/domain/User.java Enables JPA inheritance to support Administrator subtype.
src/main/java/cat/udl/eps/softarch/fll/domain/Record.java Removes Record entity (template cleanup).
src/main/java/cat/udl/eps/softarch/fll/domain/Administrator.java Adds Administrator subtype with ROLE_ADMIN authorities.
src/main/java/cat/udl/eps/softarch/fll/config/WebSecurityConfig.java Enforces admin-only access for write operations globally.
src/main/java/cat/udl/eps/softarch/fll/config/DBInitialization.java Seeds a default admin user; removes Record seeding.

You can also share your feedback on Copilot code review. Take the survey.

@pol-rivero
Copy link
Member

Fantastic effort!
The only remaining warning I would consider important is the duplicated "ADMIN" in WebSecurityConfig.java‎, but I'll fix it myself after merging because this PR is already large.

@pol-rivero pol-rivero merged commit a8994a0 into UdL-EPS-SoftArch-Igualada:main Mar 16, 2026
7 of 8 checks passed
@MireiaTerri
Copy link
Contributor Author

Thanks☺️

@coderabbitai coderabbitai bot mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: User / Administrator login

3 participants