Skip to content

Conversation

@GeorgeBarnesUK
Copy link
Contributor

@GeorgeBarnesUK GeorgeBarnesUK commented Aug 11, 2025

Change description

Allows Super Users to perform edits that are not allowed by normal admins. These actions are required as part of incident resolution processes when not having direct edit access to DB:

  • Allow super users to share bookings as if they were another user (required when restoring lost share bookings)
  • Allow super users to create bookings scheduled in the past (required when migrated cases mistakenly recorded in DEMO etc)
  • Allow super users to update cases in the CLOSED state.

@GeorgeBarnesUK GeorgeBarnesUK changed the title Fix share id tests Allow SuperUsers to perform more edit actions Aug 11, 2025
@GeorgeBarnesUK GeorgeBarnesUK changed the title Allow SuperUsers to perform more edit actions S28 3951 Allow SuperUsers to perform more edit actions Aug 11, 2025
@GeorgeBarnesUK GeorgeBarnesUK marked this pull request as ready for review August 11, 2025 09:14
@GeorgeBarnesUK GeorgeBarnesUK requested a review from a team as a code owner August 11, 2025 09:14
Copy link
Contributor

@oliver-scott oliver-scott left a comment

Choose a reason for hiding this comment

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

looks good, just a small suggestion. Looks like there might be some checkstyle fixes needed too

ZoneId.of("Europe/London")).toLocalDate();
var today = LocalDate.now();

if (localDateField.isBefore(today)
Copy link
Contributor

@lydiaralphgov lydiaralphgov Oct 1, 2025

Choose a reason for hiding this comment

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

I think this adds a restriction to the API that wasn't there before, i.e. it adds a guard to make sure bookings are in the future. That's fine, but we need to create a separate ticket for this piece of code and put it in front of Jacob to make sure it's been signed off by service as its a behavioural change. edit: sorry I should have read the whole PR first!

I agree we need the Super User exception to allow us to recover cases.

.orElseThrow(() -> new NotFoundException("Case: " + createBookingDTO.getCaseId()));

if (caseEntity.getState() != CaseState.OPEN) {
if (caseEntity.getState() != CaseState.OPEN && !auth.hasRole("ROLE_SUPER_USER")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree that we should have this exception, as I think we need to avoid modifying closed cases altogether

}
if (foundCase.get().getState() != CaseState.OPEN
&& foundCase.get().getState() == createCaseDTO.getState()
&& !auth.hasRole("ROLE_SUPER_USER")
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto - I don't like this superpower


@DisplayName("Create/update a booking when case is not OPEN but user is Super Admin")
@Test
void upsertCreateBookingCaseNotOpenWithSuperAdmin() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this 😬

Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather re-open the case, create the retrospective booking, then close the case again


@DisplayName("Create a booking in the past as a superuser")
@Test
void upsertBookingInPastSuperuserCreated() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is useful 👍

Copy link
Contributor

@lydiaralphgov lydiaralphgov left a comment

Choose a reason for hiding this comment

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

See comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants