Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/main/kotlin/GoogleRevocationList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,5 @@ internal data class StatusFile(val entries: Map<String, StatusEntry>)
* @return A set of revoked serial numbers.
*/
fun parseAttestationStatus(input: InputStream): Set<String> {
return Gson()
.fromJson(InputStreamReader(input), StatusFile::class.java)
.entries
.filterValues { it.status == "REVOKED" }
.keys
return Gson().fromJson(InputStreamReader(input), StatusFile::class.java).entries.keys
}
30 changes: 5 additions & 25 deletions src/test/kotlin/GoogleRevocationListTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GoogleRevocationListTest {
{
"entries": {
"abc": { "status": "REVOKED" },
"def": { "status": "OK" }
"def": { "status": "SUSPENDED" }
}
}
"""
Expand All @@ -47,7 +47,7 @@ class GoogleRevocationListTest {
FakeHttpURLConnection(uri.toURL(), HttpURLConnection.HTTP_OK, json)
}

assertThat(result).containsExactly("abc")
assertThat(result).containsExactly("abc", "def")
}

@Test
Expand All @@ -68,7 +68,7 @@ class GoogleRevocationListTest {
}

@Test
fun parseAttestationStatus_revokedAndOkEntries() {
fun parseAttestationStatus_revokedAndSuspendedEntries() {
val json =
"""
{
Expand All @@ -78,7 +78,7 @@ class GoogleRevocationListTest {
"reason": "KEY_COMPROMISE"
},
"def": {
"status": "OK"
"status": "SUSPENDED"
},
"123": {
"status": "REVOKED",
Expand All @@ -89,27 +89,7 @@ class GoogleRevocationListTest {
"""
.trimIndent()
val result = parseAttestationStatus(json.byteInputStream())
assertThat(result).containsExactly("abc", "123")
}

@Test
fun parseAttestationStatus_onlyOkEntries() {
val json =
"""
{
"entries": {
"def": {
"status": "OK"
},
"456": {
"status": "OK"
}
}
}
"""
.trimIndent()
val result = parseAttestationStatus(json.byteInputStream())
assertThat(result).isEmpty()
assertThat(result).containsExactly("abc", "def", "123")
}

@Test
Expand Down
Loading