Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create configuration for locking the Submission for a flow after it is submitted #437

Merged
merged 21 commits into from
Nov 30, 2023

Conversation

spokenbird
Copy link
Contributor

No description provided.

@spokenbird
Copy link
Contributor Author

This PR adds the ability to configure locking down a submission such that it can no longer be edited after the submission has been submitted (which adds a submittedAt time-stamp to the submission object).

This is achieved by adding configuration to the application.yaml file like so:

 lock-after-submitted:
   - flow: ubi
     redirect: success

and by adding an afterSubmitPages section to your flows-config.yaml file's landmarks section for the flow you are locking like so:

landmarks:
  firstScreen: howThisWorks
  afterSubmitPages:
    - nextSteps
    - success

The changes in this PR will cause a user who was already submitted their application to be redirected to the redirect indicated in the lock-after-submitted section, unless the page they are accessing is one of those listed in the afterSubmitPages.

Note that this PR does not actually lock down the Submission object, or any rows in the Submission DB table, but rather just prevents the user from POSTing any data or GETing any screen not indicated in afterSubmitPages.

Additional changes in this PR include a refactor of the FlowsConfigurationFactory and the SessionContinuityInterceptor.

The FlowsConfigurationFactory will now validate flows before adding them to application context. It does this by checking if the flow is configured to be disabled, and if so, it will not add it to the application context. Furthermore, it will now validate that landmarks have been correctly set if both if a flow is configured to lock it's submissions after submit, or if a flow has enabled the session continuity interceptor.

If submission locking is enabled for a flow, the FlowsConfigurationFactory will throw an error when validating the FlowConfiguration for that flow if it does not find an afterSubmitPages or landmarks section.

It will do the same when the SessionContinuityInterceptor is enabled but no landmarks firstScreen has been configured for the given flow.

These errors occur during the applications build time and as such will fail when the SNE attempts to run an application that has been misconfigured, with error messages alerting them to the issue and steps needed to remediate the problem.

@bseeger
Copy link
Contributor

bseeger commented Nov 21, 2023

Hi - I can look at this early next week.

private SessionContinuityInterceptorConfiguration sessionContinuityInterceptorConfiguration;
private ClassPathResource classPathResource;

String AFTER_SUBIT_MISCONFIGURATION_ERROR = "You have enabled submission locking for the flow testFlow but the afterSubmitPages landmark is not set in your flow configuration yaml file.";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix typo SUBIT

// The factory should throw an exception when it tries to validate the flow since there is no landmarks section but session continuity interception is enabled
FlowConfigurationException errorThrownForNoLandmarkSectionAtAll = assertThrows(FlowConfigurationException.class,
() -> flowsConfigurationFactory.validateLandmarksFirstScreen(flowConfig));
assertThat(errorThrownForNoLandmarkSectionAtAll.getMessage()).isEqualTo(FIRST_SCREEN_MISCONFIGURATION_ERROR);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update these to use assertEquals

@spokenbird spokenbird removed the request for review from bseeger November 28, 2023 01:19
@spokenbird spokenbird merged commit 722d670 into main Nov 30, 2023
3 checks passed
@spokenbird spokenbird deleted the configure-submission-locking branch November 30, 2023 00:17
An example of a time you might include a non-static page in the list of allowed pages is if you have
a page that is used to collect feedback from the user after they have submitted their application. In
this scenario you can include the feedback page in the list of allowed pages so that the user can
can submit their feedback after they have submitted their application. The data would be saved
Copy link
Contributor

Choose a reason for hiding this comment

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

user can can submit should read user can submit

*
* @param screen The current screen name.
* @param submission The submission object.
* @param flowName
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this say: @param flowName The name of the flow? It feels self explanatory but I think we should still explain what it is.

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.

3 participants