Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions test/Altinn.App.Integration.Tests/Signing/Simple.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using Altinn.App.Api.Models;
using Altinn.Platform.Storage.Interface.Models;
using Xunit.Abstractions;

namespace Altinn.App.Integration.Tests.Singning;

[Trait("Category", "Integration")]
public class SimpleTests(ITestOutputHelper _output, AppFixtureClassFixture _classFixture)
: IClassFixture<AppFixtureClassFixture>
{
public enum Auth
{
OldUser,
OldServiceOwner,
User,
ServiceOwner,
SystemUser,
SelfIdentifiedUser,
}

[Theory]
[CombinatorialData]
public async Task Full([CombinatorialValues(Auth.User, Auth.SystemUser)] Auth auth)
{
await using var fixtureScope = await _classFixture.Get(_output, TestApps.Basic, "signing-simple");
var fixture = fixtureScope.Fixture;
var verifier = fixture.ScopedVerifier;
verifier.UseTestCase(new { auth });

var token = auth switch
{
Auth.User => await fixture.Auth.GetUserToken(1337, authenticationLevel: 3, scope: "altinn:portal/enduser"),
Auth.SystemUser => await fixture.Auth.GetSystemUserToken(
systemId: "913312465_sbs",
systemUserId: "d111dbab-d619-4f15-bf29-58fe570a9ae6",
scope: "altinn:instances.read altinn:instances.write"
),
_ => throw new NotSupportedException($"Auth {auth} is not supported"),
};

var instanceOwner = auth switch
{
Auth.User => new InstanceOwner { PartyId = "501337" },
Auth.SystemUser => new InstanceOwner { OrganisationNumber = "950474084" },
_ => throw new NotSupportedException($"Auth {auth} is not supported"),
};

using var instantiationResponse = await fixture.Instances.PostSimplified(
token,
new InstansiationInstance
{
InstanceOwner = instanceOwner,
Prefill = new() { ["property1"] = "1" },
}
);

using var instantiationData = await instantiationResponse.Read<Instance>();
var instance = instantiationData.Data.Model;
Assert.NotNull(instance);
var scrubbers = new Scrubbers(StringScrubber: Scrubbers.InstanceStringScrubber(instance));
await verifier.Verify(instantiationData, snapshotName: "Instance", scrubbers: scrubbers);

using var processNextResponse = await fixture.Instances.ProcessNext(
token,
instantiationData,
new ProcessNext { Action = "sign" }
);
using var processNextData = await processNextResponse.Read<AppProcessState>();

await verifier.Verify(processNextData, snapshotName: "ProcessNext", scrubbers: scrubbers);

using var download = await fixture.Instances.Download(token, instantiationData);
await download.Verify(verifier);

await verifier.Verify(fixture.GetSnapshotAppLogs(), snapshotName: "Logs");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
HttpResponse: {
Version: 1.1,
Content: {
Headers: {
Content-Type: [
application/json; charset=utf-8
]
}
},
StatusCode: Created,
ReasonPhrase: Created,
Headers: {
Date: <date>,
Server: [
Kestrel
],
Cache-Control: [
no-store, no-cache
],
Location: [
https://app:5005/ttd/basic/instances/500700/<instanceGuid>
],
Transfer-Encoding: [
chunked
],
Request-Context: [
appId=
],
X-Frame-Options: [
deny
],
X-Content-Type-Options: [
nosniff
],
X-XSS-Protection: [
0
],
Referrer-Policy: [
no-referrer
]
},
TrailingHeaders: {},
RequestMessage: {
Version: 1.1,
Content: {
Headers: {
Content-Type: [
application/json
],
Content-Length: [
192
]
}
},
Method: {
Method: POST
},
RequestUri: http://local.altinn.cloud:<localtestPort>/ttd/basic/instances/create,
Headers: {
Authorization: [
Bearer <token>
],
User-Agent: [
Altinn.App.Integration.Tests
]
}
},
IsSuccessStatusCode: true
},
Response: {
Id: 500700/<instanceGuid>,
InstanceOwner: {
PartyId: 500700,
OrganisationNumber: 950474084
},
AppId: ttd/basic,
Org: ttd,
SelfLinks: {
Apps: https://app:5005/ttd/basic/instances/500700/<instanceGuid>,
Platform: https://platform.local.altinn.cloud/storage/api/v1/instances/500700/<instanceGuid>
},
VisibleAfter: DateTime_1,
Process: {
Started: DateTime_2,
StartEvent: StartEvent_1,
CurrentTask: {
Flow: 2,
Started: DateTime_3,
ElementId: Task_1,
Name: Fyll ut og signer,
AltinnTaskType: signing,
FlowType: CompleteCurrentMoveToNext
}
},
Status: {
IsArchived: false,
IsSoftDeleted: false,
IsHardDeleted: false,
ReadStatus: Read
},
Data: [
{
Id: <dataElementId[0]>,
InstanceGuid: <instanceGuid>,
DataType: model,
ContentType: application/xml,
BlobStoragePath: ttd/basic/<instanceGuid>/data/<dataElementId[0]>,
SelfLinks: {
Apps: https://app:5005/ttd/basic/instances/500700/<instanceGuid>/data/<dataElementId[0]>,
Platform: https://platform./storage/api/v1/instances/500700/<instanceGuid>/data/<dataElementId[0]>
},
Comment on lines +109 to +112
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Broken Platform SelfLink host ("https://platform./...") — likely scrubber/formatting bug; fix snapshot (and source if applicable).

Apps link uses app:5005 and Platform link earlier uses platform.local.altinn.cloud, but Data[0].SelfLinks.Platform drops the host. This will mask a real defect or make the test assert an invalid URL.

Apply this diff in the snapshot (and ensure the producer code/scrubber emits consistent hosts):

-          Platform: https://platform./storage/api/v1/instances/500700/<instanceGuid>/data/<dataElementId[0]>
+          Platform: https://platform.local.altinn.cloud/storage/api/v1/instances/500700/<instanceGuid>/data/<dataElementId[0]>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
SelfLinks: {
Apps: https://app:5005/ttd/basic/instances/500700/<instanceGuid>/data/<dataElementId[0]>,
Platform: https://platform./storage/api/v1/instances/500700/<instanceGuid>/data/<dataElementId[0]>
},
SelfLinks: {
Apps: https://app:5005/ttd/basic/instances/500700/<instanceGuid>/data/<dataElementId[0]>,
Platform: https://platform.local.altinn.cloud/storage/api/v1/instances/500700/<instanceGuid>/data/<dataElementId[0]>
},
🤖 Prompt for AI Agents
In
test/Altinn.App.Integration.Tests/Signing/_snapshots/SimpleTests.Full_auth=SystemUser_0_Instance.verified.txt
around lines 109 to 112, the Platform SelfLinks host was scrubbed to
"https://platform./" which is invalid; update the snapshot to use the correct
host (match the other links, e.g. "https://platform.local.altinn.cloud/...") and
run the test to confirm; additionally, check and fix the scrubber/producer that
generates SelfLinks so it preserves or consistently replaces the platform host
(adjust the scrubber replacement rule or source generation to emit the full host
instead of "platform.").

Size: 176,
Locked: false,
IsRead: true,
Created: DateTime_4,
CreatedBy: 950474084,
LastChanged: DateTime_4,
LastChangedBy: 950474084
}
],
Created: DateTime_1,
CreatedBy: 950474084,
LastChanged: DateTime_1,
LastChangedBy: 950474084
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
HttpResponse: {
Version: 1.1,
Content: {
Headers: {
Content-Type: [
application/problem+json; charset=utf-8
]
}
},
StatusCode: InternalServerError,
ReasonPhrase: Internal Server Error,
Headers: {
Date: <date>,
Server: [
Kestrel
],
Cache-Control: [
no-store, no-cache
],
Transfer-Encoding: [
chunked
],
Request-Context: [
appId=
],
X-Frame-Options: [
deny
],
X-Content-Type-Options: [
nosniff
],
X-XSS-Protection: [
0
],
Referrer-Policy: [
no-referrer
]
},
TrailingHeaders: {},
RequestMessage: {
Version: 1.1,
Content: {
Headers: {
Content-Type: [
application/json
],
Content-Length: [
41
]
}
},
Method: {
Method: PUT
},
RequestUri: http://local.altinn.cloud:<localtestPort>/ttd/basic/instances/500700/<instanceGuid>/process/next,
Headers: {
Authorization: [
Bearer <token>
],
User-Agent: [
Altinn.App.Integration.Tests
]
}
},
IsSuccessStatusCode: false
},
Response: {}
}
Loading
Loading