From e0210117296fb508417c24961880bd3cf2664f03 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 29 Apr 2020 02:18:10 +0200 Subject: [PATCH] Fixed that countSupportedActiveTanMedia is in rare cases blank --- .../dankito/fints/response/ResponseParser.kt | 5 +++- .../fints/response/ResponseParserTest.kt | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt index 0c335852..1b78a47b 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/ResponseParser.kt @@ -339,7 +339,10 @@ open class ResponseParser @JvmOverloads constructor( val procedureParameters = mapToSingleTanProcedureParameters(dataElementForNextProcedure) parsedProceduresParameters.add(procedureParameters) - if (procedureParameters.countSupportedActiveTanMedia != null) remainingDataElements = remainingDataElements.subList(21, remainingDataElements.size) + val has21ElementsParsed = procedureParameters.countSupportedActiveTanMedia != null || + (dataElementForNextProcedure.size >= 21 && dataElementForNextProcedure[20].isBlank()) + + if (has21ElementsParsed) remainingDataElements = remainingDataElements.subList(21, remainingDataElements.size) else remainingDataElements = remainingDataElements.subList(20, remainingDataElements.size) } diff --git a/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt b/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt index 095ae119..3099d498 100644 --- a/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt +++ b/fints4javaLib/src/test/kotlin/net/dankito/fints/response/ResponseParserTest.kt @@ -658,6 +658,30 @@ class ResponseParserTest : FinTsTestBase() { ?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } } + @Test + fun parseTanInfo_CountSupportedActiveTanMediaIsBlank() { + + // when + val result = underTest.parse("HITANS:27:6:3+1+1+1+N:N:0:901:2:TechnicalId901:::mobileTAN-Verfahren:6:1:Freigabe durch mobileTAN:1:N:4:N:0:0:N:N:00:0:N::902:2:MS1.0.0:::photoTAN-Verfahren:6:1:Freigabe durch photoTAN:1:N:4:N:0:0:N:N:00:0:N:'") + + // then + assertSuccessfullyParsedSegment(result, InstituteSegmentId.TanInfo, 27, 6, 3) + + result.getFirstSegmentById(InstituteSegmentId.TanInfo)?.let { segment -> + assertThat(segment.maxCountJobs).isEqualTo(1) + assertThat(segment.minimumCountSignatures).isEqualTo(1) + assertThat(segment.securityClass).isEqualTo(1) + assertThat(segment.tanProcedureParameters.oneStepProcedureAllowed).isFalse() + assertThat(segment.tanProcedureParameters.moreThanOneTanDependentJobPerMessageAllowed).isFalse() + assertThat(segment.tanProcedureParameters.jobHashValue).isEqualTo("0") + + assertThat(segment.tanProcedureParameters.procedureParameters).hasSize(2) + assertThat(segment.tanProcedureParameters.procedureParameters).extracting("procedureName") + .containsExactlyInAnyOrder("mobileTAN-Verfahren", "photoTAN-Verfahren") + } + ?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } + } + @Test fun parseTanResponse_NoStrongAuthenticationRequired() {