Add generateContactNumbers
This commit is contained in:
parent
fc07abc894
commit
1dde65920f
@ -4,6 +4,7 @@ import it.unisannio.assd.tkn.Const
|
|||||||
import it.unisannio.assd.tkn.key.ReportAuthorizationKey
|
import it.unisannio.assd.tkn.key.ReportAuthorizationKey
|
||||||
import it.unisannio.assd.tkn.key.ReportVerificationKey
|
import it.unisannio.assd.tkn.key.ReportVerificationKey
|
||||||
import it.unisannio.assd.tkn.key.TemporaryContactKey
|
import it.unisannio.assd.tkn.key.TemporaryContactKey
|
||||||
|
import it.unisannio.assd.tkn.key.TemporaryContactNumber
|
||||||
import it.unisannio.assd.tkn.read
|
import it.unisannio.assd.tkn.read
|
||||||
import it.unisannio.assd.tkn.toHexString
|
import it.unisannio.assd.tkn.toHexString
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
@ -20,6 +21,13 @@ class Report private constructor(private val report: ByteArray) {
|
|||||||
rak
|
rak
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun generateContactNumbers(): List<TemporaryContactNumber> = reportData.rvk
|
||||||
|
.contactNumbersBetween(
|
||||||
|
reportData.tck,
|
||||||
|
reportData.from,
|
||||||
|
reportData.until
|
||||||
|
)
|
||||||
|
|
||||||
fun getVerificationKey(): ReportVerificationKey = reportData.rvk
|
fun getVerificationKey(): ReportVerificationKey = reportData.rvk
|
||||||
|
|
||||||
fun toReportData(): ReportData = reportData
|
fun toReportData(): ReportData = reportData
|
||||||
|
@ -17,4 +17,7 @@ object TestConst {
|
|||||||
"bec8be3a8add45ce77897b1e7cb1906b5cff1097d3cb142fd9d002000a00000c73796d70746f6d2064617461"
|
"bec8be3a8add45ce77897b1e7cb1906b5cff1097d3cb142fd9d002000a00000c73796d70746f6d2064617461"
|
||||||
const val REPORT_SIGN = "31078ec5367b67a8c793b740626d81ba904789363137b5a313419c0f50b180d8226ecc984bf073ff" +
|
const val REPORT_SIGN = "31078ec5367b67a8c793b740626d81ba904789363137b5a313419c0f50b180d8226ecc984bf073ff" +
|
||||||
"89cbd9c88fea06bda1f0f368b0e7e88bbe68f15574482904"
|
"89cbd9c88fea06bda1f0f368b0e7e88bbe68f15574482904"
|
||||||
|
const val REPORT_MEMO = "symptom data"
|
||||||
|
const val REPORT_FROM = 2.toShort()
|
||||||
|
const val REPORT_UNTIL = 10.toShort()
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,41 @@ class ReportTest {
|
|||||||
.toHexString() `should be equal to` TestConst.REPORT_SIGN
|
.toHexString() `should be equal to` TestConst.REPORT_SIGN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun generateContactNumbers() {
|
||||||
|
val report = Report.readReportFromByteArray(
|
||||||
|
TestConst.REPORT_MESSAGE.toHexByteArray()
|
||||||
|
)
|
||||||
|
|
||||||
|
report.generateContactNumbers()
|
||||||
|
.take(2).map { it.toHexString() } `should be equal to` listOf(
|
||||||
|
TestConst.TCN_2,
|
||||||
|
TestConst.TCN_3
|
||||||
|
)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun toReportData() {
|
||||||
|
val report = Report.readReportFromByteArray(
|
||||||
|
TestConst.REPORT_MESSAGE.toHexByteArray()
|
||||||
|
)
|
||||||
|
|
||||||
|
val reportData = report.toReportData()
|
||||||
|
|
||||||
|
reportData.rvk
|
||||||
|
.toHexString() `should be equal to` TestConst.PUBLIC_KEY_STRING_HEX
|
||||||
|
|
||||||
|
reportData.tck
|
||||||
|
.toHexString() `should be equal to` TestConst.TCK_1
|
||||||
|
|
||||||
|
reportData.from `should be equal to` TestConst.REPORT_FROM
|
||||||
|
|
||||||
|
reportData.until `should be equal to` TestConst.REPORT_UNTIL
|
||||||
|
|
||||||
|
reportData.memo `should be equal to` TestConst.REPORT_MEMO
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun getVerificationKey() {
|
fun getVerificationKey() {
|
||||||
val report = Report.readReportFromByteArray(
|
val report = Report.readReportFromByteArray(
|
||||||
|
Loading…
Reference in New Issue
Block a user