diff options
Diffstat (limited to 'ebics/src/test/kotlin/XmlUtilTest.kt')
-rw-r--r-- | ebics/src/test/kotlin/XmlUtilTest.kt | 118 |
1 files changed, 0 insertions, 118 deletions
diff --git a/ebics/src/test/kotlin/XmlUtilTest.kt b/ebics/src/test/kotlin/XmlUtilTest.kt index 8b8f340f..1ec63538 100644 --- a/ebics/src/test/kotlin/XmlUtilTest.kt +++ b/ebics/src/test/kotlin/XmlUtilTest.kt @@ -17,100 +17,17 @@ * <http://www.gnu.org/licenses/> */ -import org.apache.xml.security.binding.xmldsig.SignatureType import org.junit.Assert.assertTrue import org.junit.Test import tech.libeufin.common.crypto.CryptoUtil import tech.libeufin.common.decodeBase64 import tech.libeufin.ebics.XMLUtil -import tech.libeufin.ebics.XMLUtil.Companion.signEbicsResponse -import tech.libeufin.ebics.ebics_h004.EbicsKeyManagementResponse -import tech.libeufin.ebics.ebics_h004.EbicsResponse -import tech.libeufin.ebics.ebics_h004.EbicsTypes -import tech.libeufin.ebics.ebics_h004.HTDResponseOrderData import java.security.KeyPairGenerator import javax.xml.transform.stream.StreamSource class XmlUtilTest { @Test - fun deserializeConsecutiveLists() { - val tmp = XMLUtil.convertToJaxb<HTDResponseOrderData>(""" - <?xml version="1.0" encoding="UTF-8" standalone="yes"?> - <HTDResponseOrderData xmlns="urn:org:ebics:H004"> - <PartnerInfo> - <AddressInfo> - <Name>Foo</Name> - </AddressInfo> - <BankInfo> - <HostID>host01</HostID> - </BankInfo> - <AccountInfo Currency="EUR" Description="ACCT" ID="acctid1"> - <AccountNumber international="true">DE21500105174751659277</AccountNumber> - <BankCode international="true">INGDDEFFXXX</BankCode> - <AccountHolder>Mina Musterfrau</AccountHolder> - </AccountInfo> - <AccountInfo Currency="EUR" Description="glsdemoacct" ID="glsdemo"> - <AccountNumber international="true">DE91430609670123123123</AccountNumber> - <BankCode international="true">GENODEM1GLS</BankCode> - <AccountHolder>Mina Musterfrau</AccountHolder> - </AccountInfo> - <OrderInfo> - <OrderType>C53</OrderType> - <TransferType>Download</TransferType> - <Description>foo</Description> - </OrderInfo> - <OrderInfo> - <OrderType>C52</OrderType> - <TransferType>Download</TransferType> - <Description>foo</Description> - </OrderInfo> - <OrderInfo> - <OrderType>CCC</OrderType> - <TransferType>Upload</TransferType> - <Description>foo</Description> - </OrderInfo> - </PartnerInfo> - <UserInfo> - <UserID Status="5">USER1</UserID> - <Name>Some User</Name> - <Permission> - <OrderTypes>C54 C53 C52 CCC</OrderTypes> - </Permission> - </UserInfo> - </HTDResponseOrderData>""".trimIndent().toByteArray().inputStream() - ) - - println(tmp.value.partnerInfo.orderInfoList[0].description) - } - - @Test - fun exceptionOnConversion() { - try { - XMLUtil.convertToJaxb<EbicsKeyManagementResponse>("<malformed xml>".toByteArray().inputStream()) - } catch (e: javax.xml.bind.UnmarshalException) { - // just ensuring this is the exception - println("caught") - return - } - assertTrue(false) - } - - @Test - fun hevValidation(){ - val classLoader = ClassLoader.getSystemClassLoader() - val hev = classLoader.getResourceAsStream("ebics_hev.xml") - assertTrue(XMLUtil.validate(StreamSource(hev))) - } - - @Test - fun iniValidation(){ - val classLoader = ClassLoader.getSystemClassLoader() - val ini = classLoader.getResourceAsStream("ebics_ini_request_sample.xml") - assertTrue(XMLUtil.validate(StreamSource(ini))) - } - - @Test fun basicSigningTest() { val doc = XMLUtil.parseIntoDom(""" <myMessage xmlns:ebics="urn:org:ebics:H004"> @@ -128,41 +45,6 @@ class XmlUtilTest { } @Test - fun verifySigningWithConversion() { - - val pair = CryptoUtil.generateRsaKeyPair(2048) - - val response = EbicsResponse().apply { - version = "H004" - header = EbicsResponse.Header().apply { - _static = EbicsResponse.StaticHeaderType() - mutable = EbicsResponse.MutableHeaderType().apply { - this.reportText = "foo" - this.returnCode = "bar" - this.transactionPhase = EbicsTypes.TransactionPhaseType.INITIALISATION - } - } - authSignature = SignatureType() - body = EbicsResponse.Body().apply { - returnCode = EbicsResponse.ReturnCode().apply { - authenticate = true - value = "asdf" - } - } - } - - val signature = signEbicsResponse(response, pair.private) - val signatureJaxb = XMLUtil.convertToJaxb<EbicsResponse>(signature.inputStream()) - - assertTrue( - XMLUtil.verifyEbicsDocument( - XMLUtil.convertJaxbToDocument(signatureJaxb.value), - pair.public - ) - ) - } - - @Test fun multiAuthSigningTest() { val doc = XMLUtil.parseIntoDom(""" <myMessage xmlns:ebics="urn:org:ebics:H004"> |