Skip to content

Commit 98b9c41

Browse files
committed
Simple signing integration test
1 parent 085f32b commit 98b9c41

13 files changed

+1180
-7
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using Altinn.App.Api.Models;
2+
using Altinn.Platform.Storage.Interface.Models;
3+
using Xunit.Abstractions;
4+
5+
namespace Altinn.App.Integration.Tests.Singning;
6+
7+
[Trait("Category", "Integration")]
8+
public class SimpleTests(ITestOutputHelper _output, AppFixtureClassFixture _classFixture)
9+
: IClassFixture<AppFixtureClassFixture>
10+
{
11+
public enum Auth
12+
{
13+
OldUser,
14+
OldServiceOwner,
15+
User,
16+
ServiceOwner,
17+
SystemUser,
18+
SelfIdentifiedUser,
19+
}
20+
21+
[Theory]
22+
[CombinatorialData]
23+
public async Task Full([CombinatorialValues(Auth.SystemUser)] Auth auth)
24+
{
25+
await using var fixtureScope = await _classFixture.Get(_output, TestApps.Basic, "signing-simple");
26+
var fixture = fixtureScope.Fixture;
27+
var verifier = fixture.ScopedVerifier;
28+
verifier.UseTestCase(new { auth });
29+
30+
var token = auth switch
31+
{
32+
Auth.SystemUser => await fixture.Auth.GetSystemUserToken(
33+
systemId: "913312465_sbs",
34+
systemUserId: "d111dbab-d619-4f15-bf29-58fe570a9ae6",
35+
scope: "altinn:instances.read altinn:instances.write"
36+
),
37+
_ => throw new NotSupportedException($"Auth {auth} is not supported"),
38+
};
39+
40+
var instanceOwner = auth switch
41+
{
42+
Auth.SystemUser => new InstanceOwner { OrganisationNumber = "950474084" },
43+
_ => throw new NotSupportedException($"Auth {auth} is not supported"),
44+
};
45+
46+
using var instantiationResponse = await fixture.Instances.PostSimplified(
47+
token,
48+
new InstansiationInstance
49+
{
50+
InstanceOwner = instanceOwner,
51+
Prefill = new() { ["property1"] = "1" },
52+
}
53+
);
54+
55+
using var instantiationData = await instantiationResponse.Read<Instance>();
56+
var instance = instantiationData.Data.Model;
57+
Assert.NotNull(instance);
58+
var scrubbers = new Scrubbers(StringScrubber: Scrubbers.InstanceStringScrubber(instance));
59+
await verifier.Verify(instantiationData, snapshotName: "Instance", scrubbers: scrubbers);
60+
61+
using var processNextResponse = await fixture.Instances.ProcessNext(
62+
token,
63+
instantiationData,
64+
new ProcessNext { Action = "sign" }
65+
);
66+
using var processNextData = await processNextResponse.Read<AppProcessState>();
67+
68+
await verifier.Verify(processNextData, snapshotName: "ProcessNext", scrubbers: scrubbers);
69+
70+
using var download = await fixture.Instances.Download(token, instantiationData);
71+
await download.Verify(verifier);
72+
73+
await verifier.Verify(fixture.GetSnapshotAppLogs(), snapshotName: "Logs");
74+
}
75+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
HttpResponse: {
3+
Version: 1.1,
4+
Content: {
5+
Headers: {
6+
Content-Type: [
7+
application/json; charset=utf-8
8+
]
9+
}
10+
},
11+
StatusCode: Created,
12+
ReasonPhrase: Created,
13+
Headers: {
14+
Date: <date>,
15+
Server: [
16+
Kestrel
17+
],
18+
Cache-Control: [
19+
no-store, no-cache
20+
],
21+
Location: [
22+
https://app:5005/ttd/basic/instances/500700/<instanceGuid>
23+
],
24+
Transfer-Encoding: [
25+
chunked
26+
],
27+
Request-Context: [
28+
appId=
29+
],
30+
X-Frame-Options: [
31+
deny
32+
],
33+
X-Content-Type-Options: [
34+
nosniff
35+
],
36+
X-XSS-Protection: [
37+
0
38+
],
39+
Referrer-Policy: [
40+
no-referrer
41+
]
42+
},
43+
TrailingHeaders: {},
44+
RequestMessage: {
45+
Version: 1.1,
46+
Content: {
47+
Headers: {
48+
Content-Type: [
49+
application/json
50+
],
51+
Content-Length: [
52+
192
53+
]
54+
}
55+
},
56+
Method: {
57+
Method: POST
58+
},
59+
RequestUri: http://local.altinn.cloud:<localtestPort>/ttd/basic/instances/create,
60+
Headers: {
61+
Authorization: [
62+
Bearer <token>
63+
],
64+
User-Agent: [
65+
Altinn.App.Integration.Tests
66+
]
67+
}
68+
},
69+
IsSuccessStatusCode: true
70+
},
71+
Response: {
72+
Id: 500700/<instanceGuid>,
73+
InstanceOwner: {
74+
PartyId: 500700,
75+
OrganisationNumber: 950474084
76+
},
77+
AppId: ttd/basic,
78+
Org: ttd,
79+
SelfLinks: {
80+
Apps: https://app:5005/ttd/basic/instances/500700/<instanceGuid>,
81+
Platform: https://platform.local.altinn.cloud/storage/api/v1/instances/500700/<instanceGuid>
82+
},
83+
VisibleAfter: DateTime_1,
84+
Process: {
85+
Started: DateTime_2,
86+
StartEvent: StartEvent_1,
87+
CurrentTask: {
88+
Flow: 2,
89+
Started: DateTime_3,
90+
ElementId: Task_1,
91+
Name: Fyll ut og signer,
92+
AltinnTaskType: signing,
93+
FlowType: CompleteCurrentMoveToNext
94+
}
95+
},
96+
Status: {
97+
IsArchived: false,
98+
IsSoftDeleted: false,
99+
IsHardDeleted: false,
100+
ReadStatus: Read
101+
},
102+
Data: [
103+
{
104+
Id: <dataElementId[0]>,
105+
InstanceGuid: <instanceGuid>,
106+
DataType: model,
107+
ContentType: application/xml,
108+
BlobStoragePath: ttd/basic/<instanceGuid>/data/<dataElementId[0]>,
109+
SelfLinks: {
110+
Apps: https://app:5005/ttd/basic/instances/500700/<instanceGuid>/data/<dataElementId[0]>,
111+
Platform: https://platform./storage/api/v1/instances/500700/<instanceGuid>/data/<dataElementId[0]>
112+
},
113+
Size: 176,
114+
Locked: false,
115+
IsRead: true,
116+
Created: DateTime_4,
117+
CreatedBy: 950474084,
118+
LastChanged: DateTime_4,
119+
LastChangedBy: 950474084
120+
}
121+
],
122+
Created: DateTime_1,
123+
CreatedBy: 950474084,
124+
LastChanged: DateTime_1,
125+
LastChangedBy: 950474084
126+
}
127+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
HttpResponse: {
3+
Version: 1.1,
4+
Content: {
5+
Headers: {
6+
Content-Type: [
7+
application/json; charset=utf-8
8+
]
9+
}
10+
},
11+
StatusCode: OK,
12+
ReasonPhrase: OK,
13+
Headers: {
14+
Date: <date>,
15+
Server: [
16+
Kestrel
17+
],
18+
Cache-Control: [
19+
no-store, no-cache
20+
],
21+
Transfer-Encoding: [
22+
chunked
23+
],
24+
Request-Context: [
25+
appId=
26+
],
27+
X-Frame-Options: [
28+
deny
29+
],
30+
X-Content-Type-Options: [
31+
nosniff
32+
],
33+
X-XSS-Protection: [
34+
0
35+
],
36+
Referrer-Policy: [
37+
no-referrer
38+
]
39+
},
40+
TrailingHeaders: {},
41+
RequestMessage: {
42+
Version: 1.1,
43+
Content: {
44+
Headers: {
45+
Content-Type: [
46+
application/json
47+
],
48+
Content-Length: [
49+
41
50+
]
51+
}
52+
},
53+
Method: {
54+
Method: PUT
55+
},
56+
RequestUri: http://local.altinn.cloud:<localtestPort>/ttd/basic/instances/500700/<instanceGuid>/process/next,
57+
Headers: {
58+
Authorization: [
59+
Bearer <token>
60+
],
61+
User-Agent: [
62+
Altinn.App.Integration.Tests
63+
]
64+
}
65+
},
66+
IsSuccessStatusCode: true
67+
},
68+
Response: {
69+
Started: DateTime_1,
70+
StartEvent: StartEvent_1,
71+
Ended: DateTime_2,
72+
EndEvent: EndEvent_1
73+
}
74+
}

0 commit comments

Comments
 (0)