Fixed that countSupportedActiveTanMedia is in rare cases blank

This commit is contained in:
dankito 2020-04-29 02:18:10 +02:00
parent f3abeeaa5f
commit e021011729
2 changed files with 28 additions and 1 deletions

View File

@ -339,7 +339,10 @@ open class ResponseParser @JvmOverloads constructor(
val procedureParameters = mapToSingleTanProcedureParameters(dataElementForNextProcedure) val procedureParameters = mapToSingleTanProcedureParameters(dataElementForNextProcedure)
parsedProceduresParameters.add(procedureParameters) 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) else remainingDataElements = remainingDataElements.subList(20, remainingDataElements.size)
} }

View File

@ -658,6 +658,30 @@ class ResponseParserTest : FinTsTestBase() {
?: run { Assert.fail("No segment of type TanInfo found in ${result.receivedSegments}") } ?: 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<TanInfo>(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 @Test
fun parseTanResponse_NoStrongAuthenticationRequired() { fun parseTanResponse_NoStrongAuthenticationRequired() {