Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Sep 17, 2024
2 parents e118477 + 7709b67 commit 664673f
Show file tree
Hide file tree
Showing 10 changed files with 319 additions and 21 deletions.
239 changes: 239 additions & 0 deletions itext.tests/itext.io.tests/itext/io/font/LoadAllAsianFontsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using iText.IO.Font.Cmap;
using iText.Test;
using iText.Test.Attributes;

namespace iText.IO.Font {
[NUnit.Framework.Category("IntegrationTest")]
public class LoadAllAsianFontsTest : ExtendedITextTest {
[NUnit.Framework.TestCaseSource("Data")]
// TODO DEVSIX-8619 All cmap parsing errors should be fixed and this logging should then be removed
[LogMessage(iText.IO.Logs.IoLogMessageConstant.UNKNOWN_ERROR_WHILE_PROCESSING_CMAP, Ignore = true)]
public virtual void TestAsianFonts(String cmapName, String ordering) {
CheckFontAsianCmap(cmapName, ordering);
}

public static ICollection<Object[]> Data() {
IList<Object[]> result = new List<Object[]>();
result.Add(new Object[] { "78-EUC-H", "Japan1" });
result.Add(new Object[] { "78-EUC-V", "Japan1" });
result.Add(new Object[] { "78-H", "Japan1" });
result.Add(new Object[] { "78-RKSJ-H", "Japan1" });
result.Add(new Object[] { "78-RKSJ-V", "Japan1" });
result.Add(new Object[] { "78-V", "Japan1" });
result.Add(new Object[] { "78ms-RKSJ-H", "Japan1" });
result.Add(new Object[] { "78ms-RKSJ-V", "Japan1" });
result.Add(new Object[] { "83pv-RKSJ-H", "Japan1" });
result.Add(new Object[] { "90ms-RKSJ-H", "Japan1" });
result.Add(new Object[] { "90ms-RKSJ-V", "Japan1" });
result.Add(new Object[] { "90msp-RKSJ-H", "Japan1" });
result.Add(new Object[] { "90msp-RKSJ-V", "Japan1" });
result.Add(new Object[] { "90pv-RKSJ-H", "Japan1" });
result.Add(new Object[] { "90pv-RKSJ-V", "Japan1" });
result.Add(new Object[] { "Add-H", "Japan1" });
result.Add(new Object[] { "Add-RKSJ-H", "Japan1" });
result.Add(new Object[] { "Add-RKSJ-V", "Japan1" });
result.Add(new Object[] { "Add-V", "Japan1" });
result.Add(new Object[] { "Adobe-CNS1-0", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-1", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-2", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-3", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-4", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-5", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-6", "CNS1" });
result.Add(new Object[] { "Adobe-CNS1-7", "CNS1" });
result.Add(new Object[] { "Adobe-GB1-0", "GB1" });
result.Add(new Object[] { "Adobe-GB1-1", "GB1" });
result.Add(new Object[] { "Adobe-GB1-2", "GB1" });
result.Add(new Object[] { "Adobe-GB1-3", "GB1" });
result.Add(new Object[] { "Adobe-GB1-4", "GB1" });
result.Add(new Object[] { "Adobe-GB1-5", "GB1" });
result.Add(new Object[] { "Adobe-Japan1-0", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-1", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-2", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-3", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-4", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-5", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-6", "Japan1" });
result.Add(new Object[] { "Adobe-Japan1-7", "Japan1" });
result.Add(new Object[] { "Adobe-Korea1-0", "Korea1" });
result.Add(new Object[] { "Adobe-Korea1-1", "Korea1" });
result.Add(new Object[] { "Adobe-Korea1-2", "Korea1" });
result.Add(new Object[] { "Adobe-KR-0", "KR" });
result.Add(new Object[] { "Adobe-KR-1", "KR" });
result.Add(new Object[] { "Adobe-KR-2", "KR" });
result.Add(new Object[] { "Adobe-KR-3", "KR" });
result.Add(new Object[] { "Adobe-KR-4", "KR" });
result.Add(new Object[] { "Adobe-KR-5", "KR" });
result.Add(new Object[] { "Adobe-KR-6", "KR" });
result.Add(new Object[] { "Adobe-KR-7", "KR" });
result.Add(new Object[] { "Adobe-KR-8", "KR" });
result.Add(new Object[] { "Adobe-KR-9", "KR" });
result.Add(new Object[] { "B5-H", "CNS1" });
result.Add(new Object[] { "B5-V", "CNS1" });
result.Add(new Object[] { "B5pc-H", "CNS1" });
result.Add(new Object[] { "B5pc-V", "CNS1" });
result.Add(new Object[] { "CNS1-H", "CNS1" });
result.Add(new Object[] { "CNS1-V", "CNS1" });
result.Add(new Object[] { "CNS2-H", "CNS1" });
result.Add(new Object[] { "CNS2-V", "CNS1" });
result.Add(new Object[] { "CNS-EUC-H", "CNS1" });
result.Add(new Object[] { "CNS-EUC-V", "CNS1" });
result.Add(new Object[] { "ETen-B5-H", "CNS1" });
result.Add(new Object[] { "ETen-B5-V", "CNS1" });
result.Add(new Object[] { "ETenms-B5-H", "CNS1" });
result.Add(new Object[] { "ETenms-B5-V", "CNS1" });
result.Add(new Object[] { "ETHK-B5-H", "CNS1" });
result.Add(new Object[] { "ETHK-B5-V", "CNS1" });
result.Add(new Object[] { "EUC-H", "Japan1" });
result.Add(new Object[] { "EUC-V", "Japan1" });
result.Add(new Object[] { "Ext-H", "Japan1" });
result.Add(new Object[] { "Ext-RKSJ-H", "Japan1" });
result.Add(new Object[] { "Ext-RKSJ-V", "Japan1" });
result.Add(new Object[] { "Ext-V", "Japan1" });
result.Add(new Object[] { "GB-EUC-H", "GB1" });
result.Add(new Object[] { "GB-EUC-V", "GB1" });
result.Add(new Object[] { "GBK2K-H", "GB1" });
result.Add(new Object[] { "GBK2K-V", "GB1" });
result.Add(new Object[] { "GBK-EUC-H", "GB1" });
result.Add(new Object[] { "GBK-EUC-V", "GB1" });
result.Add(new Object[] { "GBKp-EUC-H", "GB1" });
result.Add(new Object[] { "GBKp-EUC-V", "GB1" });
result.Add(new Object[] { "GBpc-EUC-H", "GB1" });
result.Add(new Object[] { "GBpc-EUC-V", "GB1" });
result.Add(new Object[] { "GBT-EUC-H", "GB1" });
result.Add(new Object[] { "GBT-EUC-V", "GB1" });
result.Add(new Object[] { "GBT-H", "GB1" });
result.Add(new Object[] { "GBT-V", "GB1" });
result.Add(new Object[] { "GBTpc-EUC-H", "GB1" });
result.Add(new Object[] { "GBTpc-EUC-V", "GB1" });
result.Add(new Object[] { "H", "Japan1" });
result.Add(new Object[] { "Hankaku", "Japan1" });
result.Add(new Object[] { "Hiragana", "Japan1" });
result.Add(new Object[] { "HKdla-B5-H", "CNS1" });
result.Add(new Object[] { "HKdla-B5-V", "CNS1" });
result.Add(new Object[] { "HKdlb-B5-H", "CNS1" });
result.Add(new Object[] { "HKdlb-B5-V", "CNS1" });
result.Add(new Object[] { "HKgccs-B5-H", "CNS1" });
result.Add(new Object[] { "HKgccs-B5-V", "CNS1" });
result.Add(new Object[] { "HKm314-B5-H", "CNS1" });
result.Add(new Object[] { "HKm314-B5-V", "CNS1" });
result.Add(new Object[] { "HKm471-B5-H", "CNS1" });
result.Add(new Object[] { "HKm471-B5-V", "CNS1" });
result.Add(new Object[] { "HKscs-B5-H", "CNS1" });
result.Add(new Object[] { "HKscs-B5-V", "CNS1" });
result.Add(new Object[] { "Identity-H", "Identity" });
result.Add(new Object[] { "Identity-V", "Identity" });
result.Add(new Object[] { "Katakana", "Japan1" });
result.Add(new Object[] { "KSC-EUC-H", "Korea1" });
result.Add(new Object[] { "KSC-EUC-V", "Korea1" });
result.Add(new Object[] { "KSC-H", "Korea1" });
result.Add(new Object[] { "KSC-Johab-H", "Korea1" });
result.Add(new Object[] { "KSC-Johab-V", "Korea1" });
result.Add(new Object[] { "KSC-V", "Korea1" });
result.Add(new Object[] { "KSCms-UHC-H", "Korea1" });
result.Add(new Object[] { "KSCms-UHC-HW-H", "Korea1" });
result.Add(new Object[] { "KSCms-UHC-HW-V", "Korea1" });
result.Add(new Object[] { "KSCms-UHC-V", "Korea1" });
result.Add(new Object[] { "KSCpc-EUC-H", "Korea1" });
result.Add(new Object[] { "KSCpc-EUC-V", "Korea1" });
result.Add(new Object[] { "NWP-H", "Japan1" });
result.Add(new Object[] { "NWP-V", "Japan1" });
result.Add(new Object[] { "RKSJ-H", "Japan1" });
result.Add(new Object[] { "RKSJ-V", "Japan1" });
result.Add(new Object[] { "Roman", "Japan1" });
result.Add(new Object[] { "UniAKR-UTF8-H", "KR" });
result.Add(new Object[] { "UniAKR-UTF16-H", "KR" });
result.Add(new Object[] { "UniAKR-UTF32-H", "KR" });
result.Add(new Object[] { "UniCNS-UCS2-H", "CNS1" });
result.Add(new Object[] { "UniCNS-UCS2-V", "CNS1" });
result.Add(new Object[] { "UniCNS-UTF8-H", "CNS1" });
result.Add(new Object[] { "UniCNS-UTF8-V", "CNS1" });
result.Add(new Object[] { "UniCNS-UTF16-H", "CNS1" });
result.Add(new Object[] { "UniCNS-UTF16-V", "CNS1" });
result.Add(new Object[] { "UniCNS-UTF32-H", "CNS1" });
result.Add(new Object[] { "UniCNS-UTF32-V", "CNS1" });
result.Add(new Object[] { "UniGB-UCS2-H", "GB1" });
result.Add(new Object[] { "UniGB-UCS2-V", "GB1" });
result.Add(new Object[] { "UniGB-UTF8-H", "GB1" });
result.Add(new Object[] { "UniGB-UTF8-V", "GB1" });
result.Add(new Object[] { "UniGB-UTF16-H", "GB1" });
result.Add(new Object[] { "UniGB-UTF16-V", "GB1" });
result.Add(new Object[] { "UniGB-UTF32-H", "GB1" });
result.Add(new Object[] { "UniGB-UTF32-V", "GB1" });
result.Add(new Object[] { "UniJIS2004-UTF8-H", "Japan1" });
result.Add(new Object[] { "UniJIS2004-UTF8-V", "Japan1" });
result.Add(new Object[] { "UniJIS2004-UTF16-H", "Japan1" });
result.Add(new Object[] { "UniJIS2004-UTF16-V", "Japan1" });
result.Add(new Object[] { "UniJIS2004-UTF32-H", "Japan1" });
result.Add(new Object[] { "UniJIS2004-UTF32-V", "Japan1" });
result.Add(new Object[] { "UniJIS-UCS2-H", "Japan1" });
result.Add(new Object[] { "UniJIS-UCS2-HW-H", "Japan1" });
result.Add(new Object[] { "UniJIS-UCS2-HW-V", "Japan1" });
result.Add(new Object[] { "UniJIS-UCS2-V", "Japan1" });
result.Add(new Object[] { "UniJIS-UTF8-H", "Japan1" });
result.Add(new Object[] { "UniJIS-UTF8-V", "Japan1" });
result.Add(new Object[] { "UniJIS-UTF16-H", "Japan1" });
result.Add(new Object[] { "UniJIS-UTF16-V", "Japan1" });
result.Add(new Object[] { "UniJIS-UTF32-H", "Japan1" });
result.Add(new Object[] { "UniJIS-UTF32-V", "Japan1" });
result.Add(new Object[] { "UniJISPro-UCS2-HW-V", "Japan1" });
result.Add(new Object[] { "UniJISPro-UCS2-V", "Japan1" });
result.Add(new Object[] { "UniJISPro-UTF8-V", "Japan1" });
result.Add(new Object[] { "UniJISX0213-UTF32-H", "Japan1" });
result.Add(new Object[] { "UniJISX0213-UTF32-V", "Japan1" });
result.Add(new Object[] { "UniJISX02132004-UTF32-H", "Japan1" });
result.Add(new Object[] { "UniJISX02132004-UTF32-V", "Japan1" });
result.Add(new Object[] { "UniKS-UCS2-H", "Korea1" });
result.Add(new Object[] { "UniKS-UCS2-V", "Korea1" });
result.Add(new Object[] { "UniKS-UTF8-H", "Korea1" });
result.Add(new Object[] { "UniKS-UTF8-V", "Korea1" });
result.Add(new Object[] { "UniKS-UTF16-H", "Korea1" });
result.Add(new Object[] { "UniKS-UTF16-V", "Korea1" });
result.Add(new Object[] { "UniKS-UTF32-H", "Korea1" });
result.Add(new Object[] { "UniKS-UTF32-V", "Korea1" });
result.Add(new Object[] { "V", "Japan1" });
result.Add(new Object[] { "WP-Symbol", "Japan1" });
result.Add(new Object[] { ResourceTestUtil.NormalizeResourceName("toUnicode/Adobe-CNS1-UCS2"), "Adobe_CNS1_UCS2"
});
result.Add(new Object[] { ResourceTestUtil.NormalizeResourceName("toUnicode/Adobe-GB1-UCS2"), "Adobe_GB1_UCS2"
});
result.Add(new Object[] { ResourceTestUtil.NormalizeResourceName("toUnicode/Adobe-Japan1-UCS2"), "Adobe_Japan1_UCS2"
});
result.Add(new Object[] { ResourceTestUtil.NormalizeResourceName("toUnicode/Adobe-Korea1-UCS2"), "Adobe_Korea1_UCS2"
});
result.Add(new Object[] { ResourceTestUtil.NormalizeResourceName("toUnicode/Adobe-KR-UCS2"), "Adobe_KR_UCS2"
});
return result;
}

private void CheckFontAsianCmap(String cmapName, String ordering) {
AbstractCMap cmap = CjkResourceLoader.GetUni2CidCmap(cmapName);
NUnit.Framework.Assert.IsTrue(cmapName.EndsWith(cmap.GetName()));
NUnit.Framework.Assert.AreEqual(ordering, cmap.GetOrdering());
}
}
}
34 changes: 34 additions & 0 deletions itext.tests/itext.io.tests/itext/io/font/ResourceTestUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;

namespace iText.IO.Font {
//\cond DO_NOT_DOCUMENT
internal class ResourceTestUtil {
public static String NormalizeResourceName(String resourceName) {
string result = resourceName.Replace("toUnicode/", "ToUnicode.");
return result;
}
}
//\endcond
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@ You should have received a copy of the GNU Affero General Public License
*/
using System;
using System.IO;
using iText.Bouncycastleconnector;
using iText.Commons.Bouncycastle;
using iText.Signatures.Logs;
using iText.Test;
using iText.Test.Attributes;

namespace iText.Signatures
{
[NUnit.Framework.Category("BouncyCastleUnitTest")]
public class DigestAlgorithmsManualTest : ExtendedITextTest
{
private static readonly IBouncyCastleFactory BOUNCY_CASTLE_FACTORY = BouncyCastleFactoryCreator.GetFactory();
private static readonly bool FIPS_MODE = "BCFIPS".Equals(BOUNCY_CASTLE_FACTORY.GetProviderName());

[NUnit.Framework.Test]
public virtual void DigestSHA1SunPKCS11Test()
{
Expand All @@ -54,5 +62,13 @@ public virtual void DigestSHA256SUNTest()
};
NUnit.Framework.Assert.AreEqual(expected, hash);
}

[LogMessage(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, Ignore = true)]
[NUnit.Framework.Test]
public virtual void NotAllowedNameGetAllowedDigestTest() {
String name = "SM3";
String oid = "1.2.156.10197.1.401";
NUnit.Framework.Assert.AreEqual(FIPS_MODE ? null : oid, DigestAlgorithms.GetAllowedDigest(name));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,5 @@ public virtual void NotAllowedOidGetDigestTest() {
String oid = "1.2.156.10197.1.401";
NUnit.Framework.Assert.AreEqual(FIPS_MODE ? oid : name, DigestAlgorithms.GetDigest(oid));
}

[LogMessage(SignLogMessageConstant.ALGORITHM_NOT_FROM_SPEC, Ignore = true)]
[NUnit.Framework.Test]
public virtual void NotAllowedNameGetAllowedDigestTest() {
String name = "SM3";
String oid = "1.2.156.10197.1.401";
NUnit.Framework.Assert.AreEqual(FIPS_MODE ? null : oid, DigestAlgorithms.GetAllowedDigest(name));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,17 @@ public virtual void VerifyRsaSha3SignatureTest() {
public virtual void VerifyRsaPssSha3SignatureTest() {
VerifyIsoExtensionExample("RSASSA-PSS", "sample-pss-sha3_256.pdf");
}

[NUnit.Framework.Test]
public virtual void VerifyEd448SignatureTest() {
// SHAKE256 is not available in BCFIPS
if ("BCFIPS".Equals(BOUNCY_CASTLE_FACTORY.GetProviderName())) {
NUnit.Framework.Assert.Catch(typeof(PdfException), () => VerifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf"
));
}
else {
VerifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf");
}
}
}
}
12 changes: 0 additions & 12 deletions itext.tests/itext.sign.tests/itext/signatures/PdfPKCS7Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,6 @@ public virtual void GetEncodedPkcs7WithRevocationInfoTest() {
NUnit.Framework.Assert.AreEqual(SerializedAsString(bytes), SerializedAsString(cmpBytes));
}

[NUnit.Framework.Test]
public virtual void VerifyEd448SignatureTest() {
// SHAKE256 is not available in BCFIPS
if ("BCFIPS".Equals(BOUNCY_CASTLE_FACTORY.GetProviderName())) {
NUnit.Framework.Assert.Catch(typeof(PdfException), () => VerifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf"
));
}
else {
VerifyIsoExtensionExample("Ed448", "sample-ed448-shake256.pdf");
}
}

[NUnit.Framework.Test]
public virtual void VerifyNistECDSASha2SignatureTest() {
VerifyIsoExtensionExample("SHA256withECDSA", "sample-nistp256-sha256.pdf");
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 664673f

Please sign in to comment.