Skip to content
Snippets Groups Projects
Unverified Commit 653ce1f3 authored by Lukas Lechner's avatar Lukas Lechner Committed by GitHub
Browse files

Add tracelocation byterepresentation to TraceLocation database table (DEV) (#2647)


* Add byteRepresentation property for TraceLocation and TraceLocationEntity

* Fix TraceLocationVerifierTest.kt and TraceLocationDatabaseData.kt

Co-authored-by: default avatarMatthias Urhahn <matthias.urhahn@sap.com>
parent 76c68b6d
No related branches found
No related tags found
No related merge requests found
Showing
with 30 additions and 4 deletions
......@@ -2,7 +2,7 @@
"formatVersion": 1,
"database": {
"version": 1,
"identityHash": "3130771db80d789cd0ef50b8d24e0354",
"identityHash": "58db835392620886de3bb25c22d5190a",
"entities": [
{
"tableName": "checkin",
......@@ -116,7 +116,7 @@
},
{
"tableName": "traceLocations",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`guid` TEXT NOT NULL, `version` INTEGER NOT NULL, `type` INTEGER NOT NULL, `description` TEXT NOT NULL, `address` TEXT NOT NULL, `startDate` TEXT, `endDate` TEXT, `defaultCheckInLengthInMinutes` INTEGER, `signature` TEXT NOT NULL, PRIMARY KEY(`guid`))",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`guid` TEXT NOT NULL, `version` INTEGER NOT NULL, `type` INTEGER NOT NULL, `description` TEXT NOT NULL, `address` TEXT NOT NULL, `startDate` TEXT, `endDate` TEXT, `defaultCheckInLengthInMinutes` INTEGER, `byteRepresentation` TEXT NOT NULL, `signature` TEXT NOT NULL, PRIMARY KEY(`guid`))",
"fields": [
{
"fieldPath": "guid",
......@@ -165,6 +165,11 @@
"columnName": "defaultCheckInLengthInMinutes",
"affinity": "INTEGER",
"notNull": false
},{
"fieldPath": "byteRepresentationBase64",
"columnName": "byteRepresentation",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "signatureBase64",
......@@ -186,7 +191,7 @@
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3130771db80d789cd0ef50b8d24e0354')"
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '58db835392620886de3bb25c22d5190a')"
]
}
}
\ No newline at end of file
......@@ -61,6 +61,7 @@ class TraceLocationVerifierTest : BaseTestInstrumentation() {
startDate = Instant.ofEpochSecond(2687955),
endDate = Instant.ofEpochSecond(2687991),
defaultCheckInLengthInMinutes = 0,
byteRepresentation = verifyResult.signedTraceLocation.location.toByteArray().toByteString(),
signature = verifyResult.signedTraceLocation.signature.toByteArray().toByteString()
)
......@@ -193,6 +194,7 @@ class TraceLocationVerifierTest : BaseTestInstrumentation() {
startDate = Instant.ofEpochSecond(2687955),
endDate = Instant.ofEpochSecond(2687991),
defaultCheckInLengthInMinutes = 0,
byteRepresentation = signedTraceLocation.location.toByteArray().toByteString(),
signature = signedTraceLocation.signature.toByteArray().toByteString()
)
}
......
......@@ -16,6 +16,7 @@ object TraceLocationDatabaseData {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = null,
byteRepresentationBase64 = "byteRepresentationBase64",
signatureBase64 = "signature1"
)
......@@ -28,6 +29,7 @@ object TraceLocationDatabaseData {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = 15,
byteRepresentationBase64 = "byteRepresentationBase64",
signatureBase64 = "signature2"
)
}
......@@ -59,6 +59,7 @@ class CreateEventTestViewModel @AssistedInject constructor(
startDate?.toInstant(),
endDate?.toInstant(),
defaultCheckInLengthInMinutes.toInt(),
"ByteRepresentation".toByteArray().toByteString(),
"ServerSignature".toByteArray().toByteString()
)
......
......@@ -19,6 +19,7 @@ data class TraceLocation(
val startDate: Instant?,
val endDate: Instant?,
val defaultCheckInLengthInMinutes: Int?,
val byteRepresentation: ByteString,
val signature: ByteString,
val version: Int = TRACE_LOCATION_VERSION,
) : Parcelable
......@@ -33,6 +34,7 @@ fun TraceLocationEntity.toTraceLocation() = TraceLocation(
startDate = startDate,
endDate = endDate,
defaultCheckInLengthInMinutes = defaultCheckInLengthInMinutes,
byteRepresentation = byteRepresentationBase64.decodeBase64()!!,
signature = signatureBase64.decodeBase64()!!,
version = version
)
......@@ -29,6 +29,7 @@ data class TraceLocationVerifyResult(
startDate = traceLocation.startTimestamp.toInstant(),
endDate = traceLocation.endTimestamp.toInstant(),
defaultCheckInLengthInMinutes = traceLocation.defaultCheckInLengthInMinutes,
byteRepresentation = signedTraceLocation.location.toByteArray().toByteString(),
signature = signedTraceLocation.signature.toByteArray().toByteString()
)
......
......@@ -18,8 +18,8 @@ data class TraceLocationEntity(
@ColumnInfo(name = "startDate") val startDate: Instant?,
@ColumnInfo(name = "endDate") val endDate: Instant?,
@ColumnInfo(name = "defaultCheckInLengthInMinutes") val defaultCheckInLengthInMinutes: Int?,
@ColumnInfo(name = "byteRepresentation") val byteRepresentationBase64: String,
@ColumnInfo(name = "signature") val signatureBase64: String
)
fun TraceLocation.toTraceLocationEntity(): TraceLocationEntity =
......@@ -31,6 +31,7 @@ fun TraceLocation.toTraceLocationEntity(): TraceLocationEntity =
startDate = startDate,
endDate = endDate,
defaultCheckInLengthInMinutes = defaultCheckInLengthInMinutes,
byteRepresentationBase64 = byteRepresentation.base64(),
signatureBase64 = signature.base64(),
version = version
)
......@@ -25,6 +25,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
byteRepresentationBase64 = "byteRepresentation".toByteArray().toByteString().base64(),
signatureBase64 = "signature".toByteArray().toByteString().base64()
).toTraceLocation() shouldBe TraceLocation(
guid = "TestGuid",
......@@ -35,6 +36,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
byteRepresentation = "byteRepresentation".toByteArray().toByteString(),
signature = "signature".toByteArray().toByteString()
)
}
......@@ -50,6 +52,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = null,
byteRepresentationBase64 = "byteRepresentation".toByteArray().toByteString().base64(),
signatureBase64 = "signature".toByteArray().toByteString().base64()
).toTraceLocation() shouldBe TraceLocation(
guid = "TestGuid",
......@@ -60,6 +63,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = null,
byteRepresentation = "byteRepresentation".toByteArray().toByteString(),
signature = "signature".toByteArray().toByteString()
)
}
......@@ -76,6 +80,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
byteRepresentationBase64 = "byteRepresentation".toByteArray().toByteString().base64(),
signatureBase64 = "signature".toByteArray().toByteString().base64()
),
TraceLocationEntity(
......@@ -87,6 +92,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = null,
byteRepresentationBase64 = "byteRepresentation".toByteArray().toByteString().base64(),
signatureBase64 = "signature".toByteArray().toByteString().base64()
)
).toTraceLocations() shouldBe listOf(
......@@ -99,6 +105,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
byteRepresentation = "byteRepresentation".toByteArray().toByteString(),
signature = "signature".toByteArray().toByteString()
),
TraceLocation(
......@@ -110,6 +117,7 @@ internal class DefaultTraceLocationKtTest : BaseTest() {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = null,
byteRepresentation = "byteRepresentation".toByteArray().toByteString(),
signature = "signature".toByteArray().toByteString()
)
)
......
......@@ -22,6 +22,7 @@ internal class TraceLocationEntityTest : BaseTest() {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
byteRepresentation = "byteRepresentation".toByteArray().toByteString(),
signature = "signature".toByteArray().toByteString()
).toTraceLocationEntity() shouldBe TraceLocationEntity(
guid = "TestGuid",
......@@ -32,6 +33,7 @@ internal class TraceLocationEntityTest : BaseTest() {
startDate = Instant.parse("2021-01-01T12:00:00.000Z"),
endDate = Instant.parse("2021-01-01T18:00:00.000Z"),
defaultCheckInLengthInMinutes = 15,
byteRepresentationBase64 = "byteRepresentation".toByteArray().toByteString().base64(),
signatureBase64 = "signature".toByteArray().toByteString().base64()
)
}
......@@ -47,6 +49,7 @@ internal class TraceLocationEntityTest : BaseTest() {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = null,
byteRepresentation = "byteRepresentation".toByteArray().toByteString(),
signature = "signature".toByteArray().toByteString()
).toTraceLocationEntity() shouldBe TraceLocationEntity(
guid = "TestGuid",
......@@ -57,6 +60,7 @@ internal class TraceLocationEntityTest : BaseTest() {
startDate = null,
endDate = null,
defaultCheckInLengthInMinutes = null,
byteRepresentationBase64 = "byteRepresentation".toByteArray().toByteString().base64(),
signatureBase64 = "signature".toByteArray().toByteString().base64()
)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment