From 2e7e53a640753aba8e36d6509aeeec88817f2589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Aas=20Sja=CC=8Afjell?= Date: Mon, 14 Mar 2016 11:09:52 +0100 Subject: [PATCH 1/5] Adds Order to signers --- Digipost.Signature.Api.Client.Core/Signer.cs | 2 + .../DataTransferObjectConverterTests.cs | 59 +++++++++++++++++++ .../DataTransferObjectConverter.cs | 3 +- .../XsdToCode/Code/direct-and-portal.cs | 13 ++++ .../XsdToCode/Xsd/common.xsd | 20 +++++++ 5 files changed, 96 insertions(+), 1 deletion(-) diff --git a/Digipost.Signature.Api.Client.Core/Signer.cs b/Digipost.Signature.Api.Client.Core/Signer.cs index 250980b3..32895dcd 100755 --- a/Digipost.Signature.Api.Client.Core/Signer.cs +++ b/Digipost.Signature.Api.Client.Core/Signer.cs @@ -8,5 +8,7 @@ public Signer(string personalIdentificationNumber) } public string PersonalIdentificationNumber { get; } + + public int Order { get; set; } } } \ No newline at end of file diff --git a/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs b/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs index 7c113ede..4eab4f1c 100755 --- a/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs +++ b/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs @@ -43,6 +43,30 @@ public void ConvertsPortalJobSuccessfully() Assert.AreEqual(0, differences.Count()); } + [TestMethod] + public void ConvertsPortalJobWithOrderedSignersSuccessfully() + { + //Arrange + var document = CoreDomainUtility.GetDocument(); + var signers = new List {new Signer("")}; + var reference = "reference"; + var source = new PortalJob(document, signers, reference); + + var expected = new portalsignaturejobrequest + { + reference = reference + }; + + //Act + var result = DataTransferObjectConverter.ToDataTransferObject(source); + + //Assert + var comparator = new Comparator(); + IEnumerable differences; + comparator.AreEqual(expected, result, out differences); + Assert.AreEqual(0, differences.Count()); + } + [TestMethod] public void ConvertsManifestWithoutAvailabilitySuccessfully() { @@ -78,6 +102,41 @@ public void ConvertsManifestWithoutAvailabilitySuccessfully() Assert.AreEqual(0, differences.Count()); } + [TestMethod] + public void ConvertsManifestWithOrderedSignersSuccessfully() + { + //Arrange + const string organizationNumberSender = "12345678902"; + + var source = new PortalManifest(new Sender(organizationNumberSender), CoreDomainUtility.GetDocument(), new List {new Signer("00000000000") {Order = 1}, new Signer("99999999999") {Order = 2}}); + + var expected = new portalsignaturejobmanifest + { + sender = new sender {organizationnumber = organizationNumberSender}, + document = new document + { + title = source.Document.Subject, + description = source.Document.Message, + href = source.Document.FileName, + mime = source.Document.MimeType + }, + signers = new[] + { + new signer {personalidentificationnumber = source.Signers.ElementAt(0).PersonalIdentificationNumber, order = "1"}, + new signer {personalidentificationnumber = source.Signers.ElementAt(1).PersonalIdentificationNumber, order = "2"} + } + }; + + //Act + var result = DataTransferObjectConverter.ToDataTransferObject(source); + + //Assert + var comparator = new Comparator(); + IEnumerable differences; + comparator.AreEqual(expected, result, out differences); + Assert.AreEqual(0, differences.Count()); + } + [TestMethod] public void ConvertsManifestWithOnlyAvailableSecondsSuccessfully() { diff --git a/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs b/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs index 9747227f..04c1ada4 100755 --- a/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs +++ b/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs @@ -54,7 +54,8 @@ private static signer ToDataTransferObject(Signer signer) { return new signer { - personalidentificationnumber = signer.PersonalIdentificationNumber + personalidentificationnumber = signer.PersonalIdentificationNumber, + order = signer.Order.ToString() }; } diff --git a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs index 6bf40762..cf124228 100755 --- a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs +++ b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs @@ -320,6 +320,8 @@ public partial class signer { private string personalidentificationnumberField; + private string orderField; + /// [System.Xml.Serialization.XmlElementAttribute("personal-identification-number")] public string personalidentificationnumber { @@ -330,6 +332,17 @@ public string personalidentificationnumber { this.personalidentificationnumberField = value; } } + + /// + [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")] + public string order { + get { + return this.orderField; + } + set { + this.orderField = value; + } + } } /// diff --git a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd index 2b3df9b3..e6346e9b 100755 --- a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd +++ b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd @@ -59,6 +59,26 @@ + + + + Specifies the order in which documents should be activated. Lower values indicates earlier activation. + A document with higher order will only be made available when all lower order signers have signed the document. + If two signers have the same order, the document will be made available to both in parallell. + Specifying order with only one signer has no effect. + + The specified signature deadline for portal jobs will be for each individual signer. + For example, 1 day for 3 chained signers means 3 days maximum. The time only runs once for signers in paralell, + so three paralell signers with 1 day deadline will maximum take 1 day. + + + + + + + + + From 61457eb034493968293641eb3d40e9686c9cfc44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Aas=20Sja=CC=8Afjell?= Date: Mon, 14 Mar 2016 11:12:39 +0100 Subject: [PATCH 2/5] Removes test added unintentionally --- .../DataTransferObjectConverterTests.cs | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs b/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs index 4eab4f1c..6a615099 100755 --- a/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs +++ b/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs @@ -43,30 +43,6 @@ public void ConvertsPortalJobSuccessfully() Assert.AreEqual(0, differences.Count()); } - [TestMethod] - public void ConvertsPortalJobWithOrderedSignersSuccessfully() - { - //Arrange - var document = CoreDomainUtility.GetDocument(); - var signers = new List {new Signer("")}; - var reference = "reference"; - var source = new PortalJob(document, signers, reference); - - var expected = new portalsignaturejobrequest - { - reference = reference - }; - - //Act - var result = DataTransferObjectConverter.ToDataTransferObject(source); - - //Assert - var comparator = new Comparator(); - IEnumerable differences; - comparator.AreEqual(expected, result, out differences); - Assert.AreEqual(0, differences.Count()); - } - [TestMethod] public void ConvertsManifestWithoutAvailabilitySuccessfully() { From ca2953e64f2434a287e2e47dd015b9cd9f079f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Aas=20Sja=CC=8Afjell?= Date: Mon, 14 Mar 2016 13:11:25 +0100 Subject: [PATCH 3/5] Makes order a nullable Introduced a bug for 0 as order, and this is the fix. --- Digipost.Signature.Api.Client.Core.Tests/Smoke/SmokeTests.cs | 2 +- Digipost.Signature.Api.Client.Core/Signer.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Digipost.Signature.Api.Client.Core.Tests/Smoke/SmokeTests.cs b/Digipost.Signature.Api.Client.Core.Tests/Smoke/SmokeTests.cs index 535e233f..67206702 100755 --- a/Digipost.Signature.Api.Client.Core.Tests/Smoke/SmokeTests.cs +++ b/Digipost.Signature.Api.Client.Core.Tests/Smoke/SmokeTests.cs @@ -13,7 +13,7 @@ protected static Client ClientType return Client.DifiQa; } - return Client.Localhost; + return Client.DifiQa; } } diff --git a/Digipost.Signature.Api.Client.Core/Signer.cs b/Digipost.Signature.Api.Client.Core/Signer.cs index 32895dcd..2f2888e5 100755 --- a/Digipost.Signature.Api.Client.Core/Signer.cs +++ b/Digipost.Signature.Api.Client.Core/Signer.cs @@ -9,6 +9,6 @@ public Signer(string personalIdentificationNumber) public string PersonalIdentificationNumber { get; } - public int Order { get; set; } + public int? Order { get; set; } = null; } } \ No newline at end of file From ff01e481531b4a48e2cb4729185be8c7b286e060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Aas=20Sja=CC=8Afjell?= Date: Mon, 14 Mar 2016 13:13:18 +0100 Subject: [PATCH 4/5] Added missing file for DtoConverter --- .../DataTransferObjects/DataTransferObjectConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs b/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs index 04c1ada4..3143e376 100755 --- a/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs +++ b/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs @@ -55,7 +55,7 @@ private static signer ToDataTransferObject(Signer signer) return new signer { personalidentificationnumber = signer.PersonalIdentificationNumber, - order = signer.Order.ToString() + order = signer.Order?.ToString() }; } From 68976941a643803f90f6e7ba11bfd87940255b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksander=20Aas=20Sja=CC=8Afjell?= Date: Mon, 14 Mar 2016 14:40:21 +0100 Subject: [PATCH 5/5] Updates Xsd Updates Xsd with the xsd:int for Order --- .../DataTransferObjectConverterTests.cs | 4 ++-- .../DataTransferObjectConverter.cs | 12 +++++++++--- .../XsdToCode/Code/direct-and-portal.cs | 19 ++++++++++++++++--- .../XsdToCode/Xsd/common.xsd | 2 +- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs b/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs index 6a615099..4f5a0b41 100755 --- a/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs +++ b/Digipost.Signature.Api.Client.Portal.Tests/DataTransferObjects/DataTransferObjectConverterTests.cs @@ -98,8 +98,8 @@ public void ConvertsManifestWithOrderedSignersSuccessfully() }, signers = new[] { - new signer {personalidentificationnumber = source.Signers.ElementAt(0).PersonalIdentificationNumber, order = "1"}, - new signer {personalidentificationnumber = source.Signers.ElementAt(1).PersonalIdentificationNumber, order = "2"} + new signer {personalidentificationnumber = source.Signers.ElementAt(0).PersonalIdentificationNumber, order = 1}, + new signer {personalidentificationnumber = source.Signers.ElementAt(1).PersonalIdentificationNumber, order = 2} } }; diff --git a/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs b/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs index 3143e376..feadb1e4 100755 --- a/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs +++ b/Digipost.Signature.Api.Client.Portal/DataTransferObjects/DataTransferObjectConverter.cs @@ -52,11 +52,17 @@ private static IEnumerable ToDataTransferObject(IEnumerable sign private static signer ToDataTransferObject(Signer signer) { - return new signer + var dataTransferObject = new signer { - personalidentificationnumber = signer.PersonalIdentificationNumber, - order = signer.Order?.ToString() + personalidentificationnumber = signer.PersonalIdentificationNumber }; + + if (signer.Order != null) + { + dataTransferObject.order = signer.Order.Value; + } + + return dataTransferObject; } public static sender ToDataTransferObject(Sender sender) diff --git a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs index cf124228..2cc0b505 100755 --- a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs +++ b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Code/direct-and-portal.cs @@ -320,7 +320,9 @@ public partial class signer { private string personalidentificationnumberField; - private string orderField; + private int orderField; + + private bool orderFieldSpecified; /// [System.Xml.Serialization.XmlElementAttribute("personal-identification-number")] @@ -334,8 +336,8 @@ public string personalidentificationnumber { } /// - [System.Xml.Serialization.XmlAttributeAttribute(DataType="integer")] - public string order { + [System.Xml.Serialization.XmlAttributeAttribute()] + public int order { get { return this.orderField; } @@ -343,6 +345,17 @@ public string order { this.orderField = value; } } + + /// + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool orderSpecified { + get { + return this.orderFieldSpecified; + } + set { + this.orderFieldSpecified = value; + } + } } /// diff --git a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd index e6346e9b..b96abb90 100755 --- a/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd +++ b/Digipost.Signature.Api.Client.Scripts/XsdToCode/Xsd/common.xsd @@ -73,7 +73,7 @@ - +