Skip to content

Commit c274d8a

Browse files
committed
Ensure non-sensitive title is passed onto manifest.
Manifest is part of document bundle sent to the server. A Portal.Job object might be newed up with a non-sensitive title, but this was lost in the mapping from Portal.Job to Manifest. This resulted in a bug which made it impossible for consumers of our dotnet client library to create portal jobs with non-sensitive tiles. Non-sensitive titles are titles that may be added in addition to "regular" titles. Non-sensitive titles may be displayed in contexts where we cannot ensure that people viewing are authorized, such as in email notificaitons sent to signers.
1 parent 569c48e commit c274d8a

File tree

2 files changed

+67
-10
lines changed

2 files changed

+67
-10
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using System;
2+
using Digipost.Signature.Api.Client.Core.Tests.Utilities;
3+
using Digipost.Signature.Api.Client.Portal.Internal.AsicE;
4+
using Digipost.Signature.Api.Client.Portal.Tests.Utilities;
5+
using Xunit;
6+
7+
namespace Digipost.Signature.Api.Client.Portal.Tests.Internal.AsicE
8+
{
9+
public class PortalAsiceGeneratorTests
10+
{
11+
public class ToManifestMethod : PortalAsiceGeneratorTests
12+
{
13+
[Fact]
14+
public void Creates_manifest_with_expected_attributes()
15+
{
16+
// Arrange
17+
var job = new Job(
18+
"Job title",
19+
DomainUtility.GetSinglePortalDocument(),
20+
DomainUtility.GetSigners(2),
21+
"Reference",
22+
CoreDomainUtility.GetSender())
23+
{
24+
Description = "Job description",
25+
NonSensitiveTitle = "Non-sensitive title",
26+
Availability = new Availability
27+
{
28+
Activation = new DateTime(2025, 6, 6),
29+
AvailableFor = TimeSpan.FromDays(7)
30+
},
31+
AuthenticationLevel = Core.Enums.AuthenticationLevel.Four,
32+
IdentifierInSignedDocuments = Core.Enums.IdentifierInSignedDocuments.PersonalIdentificationNumberAndName
33+
};
34+
35+
// Act
36+
var manifest = PortalAsiceGenerator.ToManifest(job);
37+
38+
// Assert
39+
Assert.Equal(job.Title, manifest.Title);
40+
Assert.Equal(job.Documents, manifest.Documents);
41+
Assert.Equal(job.Signers, manifest.Signers);
42+
Assert.Equal(job.Sender, manifest.Sender);
43+
Assert.Equal(job.Description, manifest.Description);
44+
Assert.Equal(job.NonSensitiveTitle, manifest.NonSensitiveTitle);
45+
Assert.Equal(job.Availability, manifest.Availability);
46+
Assert.Equal(job.AuthenticationLevel, manifest.AuthenticationLevel);
47+
Assert.Equal(job.IdentifierInSignedDocuments, manifest.IdentifierInSignedDocuments);
48+
}
49+
}
50+
}
51+
52+
}
Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using System.Security.Cryptography.X509Certificates;
1+
using System.Security.Cryptography.X509Certificates;
32
using Digipost.Signature.Api.Client.Core;
43
using Digipost.Signature.Api.Client.Core.Internal.Asice;
54
using Digipost.Signature.Api.Client.Core.Internal.Asice.AsiceSignature;
@@ -10,19 +9,25 @@ internal class PortalAsiceGenerator : AsiceGenerator
109
{
1110
public static DocumentBundle CreateAsice(Job job, X509Certificate2 certificate, IAsiceConfiguration asiceConfiguration)
1211
{
13-
var manifest = new Manifest(job.Title, job.Sender, job.Documents, job.Signers)
14-
{
15-
Availability = job.Availability,
16-
AuthenticationLevel = job.AuthenticationLevel,
17-
IdentifierInSignedDocuments = job.IdentifierInSignedDocuments,
18-
NonSensitiveTitle = job.NonSensitiveTitle,
19-
Description = job.Description
20-
};
12+
var manifest = ToManifest(job);
2113

2214
var signature = new SignatureGenerator(certificate, job.Documents, manifest);
2315
var asiceArchive = GetAsiceArchive(job, asiceConfiguration, job.Documents, manifest, signature);
2416

2517
return new DocumentBundle(asiceArchive.GetBytes());
2618
}
19+
20+
internal static Manifest ToManifest(Job job)
21+
{
22+
return new Manifest(job.Title, job.Sender, job.Documents, job.Signers)
23+
{
24+
Availability = job.Availability,
25+
AuthenticationLevel = job.AuthenticationLevel,
26+
IdentifierInSignedDocuments = job.IdentifierInSignedDocuments,
27+
Description = job.Description,
28+
NonSensitiveTitle = job.NonSensitiveTitle
29+
};
30+
}
2731
}
32+
2833
}

0 commit comments

Comments
 (0)