-
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
Add GET endpoint to trigger copy of instance #224
Conversation
catch (Exception altinnAppException) | ||
{ | ||
throw new ServiceException(HttpStatusCode.InternalServerError, $"App.GetAppModelType failed: {altinnAppException.Message}", altinnAppException); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause
test/Altinn.App.Api.Tests/Controllers/InstancesController_CopyInstanceTests.cs
Fixed
Show fixed
Hide fixed
Doesn’t mutating apis usually try to avoid using the GET method? |
To explain the GET suggestion it is due to technical challenges in Altinn2. We need to have a discussion in the team as to how we should solve this. |
There are two standard ways this could work without xsrf issues.
I get that the first might be limited by altinn2 capabilities, but the manual confirmation step is just as simple on the altinn 2 side. It should probably be implemented in app-frontend-react, but could just be a simple form a user might click submit on. |
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.
Not happy with mutating GET endpoint, but as the old system has limitations we would need to accept technical debt somewhere. By accepting the dept here we would not introduce dept in both frontend and backend
See also the suggestion in Altinn/app-frontend-react#286
Personally I think frontend should ask the user for a confirmation that they want to copy the instance (unless altinn2 is able to provide a signed assertion), so that there isn't any risk that third party websites can trigger copies with user cookies without user involvement. |
_instantiationValidator.Setup(v => v.Validate(It.IsAny<Instance>())).ReturnsAsync(instantiationValidationResult); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance("ttd", "copy-instance", instanceOwnerPartyId, instanceGuid); |
Check warning
Code scanning / CodeQL
Call to obsolete method
_appMetadata.Setup(a => a.GetApplicationMetadata()).ReturnsAsync(application); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance("ttd", "copy-instance", 343234, Guid.NewGuid()); |
Check warning
Code scanning / CodeQL
Call to obsolete method
.ReturnsAsync(CreateXacmlResponse("Deny")); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance("ttd", "copy-instance", 343234, Guid.NewGuid()); |
Check warning
Code scanning / CodeQL
Call to obsolete method
.ReturnsAsync(instance); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance("ttd", "copy-instance", instanceOwnerPartyId, instanceGuid); |
Check warning
Code scanning / CodeQL
Call to obsolete method
_processEngine.Setup(p => p.StartTask(It.IsAny<ProcessChangeContext>())); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance(Org, AppName, InstanceOwnerPartyId, instanceGuid); |
Check warning
Code scanning / CodeQL
Call to obsolete method
.ReturnsAsync(CreateApplicationMetadata($"{Org}/{AppName}", false)); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance("ttd", "copy-instance", 343234, Guid.NewGuid()); |
Check warning
Code scanning / CodeQL
Call to obsolete method
_httpContextMock.Setup(httpContext => httpContext.User).Returns(PrincipalUtil.GetOrgPrincipal("ttd")); | ||
|
||
// Act | ||
ActionResult actual = await SUT.CopyInstance("ttd", "copy-instance", 343234, Guid.NewGuid()); |
Check warning
Code scanning / CodeQL
Call to obsolete method
SonarCloud Quality Gate failed. |
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.
Description
Adding a new GET endpoint in InstanceController. The new endpoint is intended to be an easy to access function to create a new instance based on an existing instance. Data is copied from one to the other based on CopyInstanceSettings.
Related Issue(s)
Verification
Documentation