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

Feat/Payment process task and some process engine refactoring #448

Closed
wants to merge 39 commits into from

Conversation

bjorntore
Copy link
Contributor

Description

Adding payment process task. Refactored the process engine code somewhat.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)
  • All tests run green

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

/// <inheritdoc/>
public async Task Initialize(string taskId, Instance instance, Dictionary<string, string> prefill)
{
_logger.LogDebug("OnStartProcessTask for {InstanceId}", instance.Id);

Check failure

Code scanning / CodeQL

Log entries created from user input High

This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a
user-provided value
.
This log entry depends on a user-provided value.
This log entry depends on a user-provided value.
This log entry depends on a user-provided value.
This log entry depends on a user-provided value.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thoughts? These debugs already existed. I guess debug logs only run on local dev?

Copy link
Member

Choose a reason for hiding this comment

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

We have lots of these issues. The problem is that if you log to standard out with a newline separating log entries, this pattern is problematic, because the user might provide two a new forged log entry between two newlines. That trick won't fool application insights, so I think we can safely ignore these.

The other issue is that C# might have a similar issue as log4j (log4shell), but after java was caught, lots of people checked dotnet for similar issues, and none was reported.

{
private Mock<IProcessTaskDataLocker> _processTaskDataLocker;
private Mock<IProcessTaskFinalizer> _processTaskFinisher;
private Mock<IServiceTask> _pdfServiceTask;

Check notice

Code scanning / CodeQL

Missed 'readonly' opportunity Note test

Field '_pdfServiceTask' can be 'readonly'.
private Mock<IProcessTaskDataLocker> _processTaskDataLocker;
private Mock<IProcessTaskFinalizer> _processTaskFinisher;
private Mock<IServiceTask> _pdfServiceTask;
private Mock<IServiceTask> _eformidlingServiceTask;

Check notice

Code scanning / CodeQL

Missed 'readonly' opportunity Note test

Field '_eformidlingServiceTask' can be 'readonly'.
Comment on lines 99 to 105
foreach (var processTaskType in _processTasks)
{
if (processTaskType.Type == altinnTaskType)
{
return processTaskType;
}
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Where Note

This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
@bjorntore bjorntore linked an issue Feb 20, 2024 that may be closed by this pull request
6 tasks
}

/// <inheritdoc />
public async Task<PaymentStatus?> GetPaymentStatus(Instance instance, string paymentReference, decimal expectedTotalIncVat)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any input on what kinds of verifications we should do to check if the payment is in good health? Right now I'm just doing a simple sum comparison. Charged amount == our local calculation of total inc VAT.

@@ -20,7 +19,7 @@

namespace Altinn.App.PlatformServices.Tests.Implementation;

public class DefaultTaskEventsTests: IDisposable
public class DefaultTaskEventsTests : IDisposable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: Remove file. Consider if more tests should be kept.

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
63.1% Coverage on New Code (required ≥ 65%)
58.42% Condition Coverage on New Code (required ≥ 65%)

See analysis details on SonarCloud

Comment on lines +18 to +42
/// <summary>
/// Removes data elements generated from a task, if the data elements are tagged with the task ID.
/// </summary>
/// <param name="instance"></param>
/// <param name="taskId"></param>
/// <returns></returns>
Task RemoveDataElementsGeneratedFromTask(Instance instance, string taskId);

/// <summary>
/// Remove hidden data from the instance.
/// </summary>
/// <param name="instance"></param>
/// <param name="instanceGuid"></param>
/// <param name="connectedDataTypes"></param>
/// <returns></returns>
Task RemoveHiddenData(Instance instance, Guid instanceGuid, List<DataType>? connectedDataTypes);

/// <summary>
/// Remove shadow fields from the instance.
/// </summary>
/// <param name="instance"></param>
/// <param name="instanceGuid"></param>
/// <param name="connectedDataTypes"></param>
/// <returns></returns>
Task RemoveShadowFields(Instance instance, Guid instanceGuid, List<DataType> connectedDataTypes);
Copy link
Member

Choose a reason for hiding this comment

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

Hvorfor ligger disse metodene i interfacet? De kalles da bare fra Finalize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Det tror jeg var en glipp. Takk!

Comment on lines +19 to +35
/// <summary>
/// Updates presentation texts on the instance for a given data type and data.
/// </summary>
/// <param name="instance"></param>
/// <param name="dataType"></param>
/// <param name="data"></param>
/// <returns></returns>
Task UpdatePresentationTextsOnInstance(Instance instance, string dataType, dynamic data);

/// <summary>
/// Updates data values on the instance for a given data type and data.
/// </summary>
/// <param name="instance"></param>
/// <param name="dataType"></param>
/// <param name="data"></param>
/// <returns></returns>
Task UpdateDataValuesOnInstance(Instance instance, string dataType, object data);
Copy link
Member

Choose a reason for hiding this comment

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

Samme her. De har vel ikke noe i interfacet å gjøre?

IAppModel appModel,
IAppResources appResources,
LayoutEvaluatorStateInitializer layoutEvaluatorStateInitializer,
IOptions<AppSettings>? appSettings = null)
Copy link
Member

Choose a reason for hiding this comment

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

Hvorfor er AppSettings nullable?

@bjorntore
Copy link
Contributor Author

Creating new PR.

@bjorntore bjorntore closed this Mar 1, 2024
@ivarne ivarne deleted the feat/payment-process-task branch October 10, 2024 06:37
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.

Brukerbetaling av en Altinn 3 tjeneste
3 participants