-
Notifications
You must be signed in to change notification settings - Fork 11
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
implements default signing task validator #1046
base: feature/signing
Are you sure you want to change the base?
Conversation
/publish |
…nd added function docs
/publish |
PR release:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🥇
src/Altinn.App.Core/Features/Validation/Default/SigningTaskValidator.cs
Outdated
Show resolved
Hide resolved
src/Altinn.App.Core/Features/Validation/Default/SigningTaskValidator.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
_processReader.GetAltinnTaskExtension(taskId)?.SignatureConfiguration | ||
); | ||
|
||
if (signingConfiguration == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (signingConfiguration == null) | |
if (signingConfiguration is null) |
} | ||
|
||
var (getAppMetadataError, appMetadata) = await CatchError(_appMetadata.GetApplicationMetadata()); | ||
if (getAppMetadataError != null || appMetadata == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (getAppMetadataError != null || appMetadata == null) | |
if (getAppMetadataError is not null || appMetadata is null) |
var (getSigneeContextsError, signeeContexts) = await CatchError( | ||
_signingService.GetSigneeContexts(cachedDataMutator, signingConfiguration) | ||
); | ||
if (getSigneeContextsError != null || signeeContexts == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (getSigneeContextsError != null || signeeContexts == null) | |
if (getSigneeContextsError is not null || signeeContexts is null) |
return []; | ||
} | ||
|
||
var allHaveSigned = signeeContexts.All(signeeContext => signeeContext.SignDocument != null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var allHaveSigned = signeeContexts.All(signeeContext => signeeContext.SignDocument != null); | |
var allHaveSigned = signeeContexts.All(signeeContext => signeeContext.SignDocument is not null); |
/// <summary> | ||
/// Catch exceptions from a task and return them as a tuple with the result. | ||
/// </summary> | ||
private static async Task<Tuple<Exception?, T?>> CatchError<T>(Task<T> task) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an internal utility?
|
||
AltinnSignatureConfiguration? signingConfiguration = taskConfig?.SignatureConfiguration; | ||
|
||
return signingConfiguration?.RunDefaultValidator == true && taskConfig?.TaskType == "signing"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a "TaskTypeConst" similar to LanguageConst, but I consider it outside the scope of this pr. I will create and issue for it.
Quality Gate passedIssues Measures |
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex, $"Error while fetching signing configuration for task {taskId}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log message will be noisy and confusing if a ProcessElement is missing the TaskExtension tag, because this ShouldRunForTask
runs on all tasks (also those that are not signature tasks)
/// </summary> | ||
public Task<bool> HasRelevantChanges(IInstanceDataAccessor dataAccessor, string taskId, DataElementChanges changes) | ||
{ | ||
throw new NotImplementedException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can add the documentation as a message, so that it is easier to understand why this is not implemented.
throw new NotImplementedException(); | |
throw new UnreachableException("HasRelevantChanges should never be called because NoIncrementalValidation is true."); |
This might need to import using System.Diagnostics;
if (signingConfiguration == null) | ||
{ | ||
_logger.LogError($"No signing configuration found for task {taskId}"); | ||
return []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was checked by ShouldRunForTask, so throw here as well.
); | ||
|
||
var (getSigneeContextsError, signeeContexts) = await CatchError( | ||
_signingService.GetSigneeContexts(cachedDataMutator, signingConfiguration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to get the signeeContexts from the dataAccessor
instead of instantiating a Mutator
in a validator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would need to update the signatures in the signing service to use IInstanceDataAccessor
Description
Default validator for all signing tasks. Runs by default if not
runDefaultValidator="false"
inprocess.bpmn
.Should it be called
runDefaultValidations
instead? 🤷♀️Verification
Documentation