Skip to content

Commit

Permalink
Merge pull request #231 from android-password-store/revert-incorrect-…
Browse files Browse the repository at this point in the history
…skip

Revert "fix: disable still-failing tests"
  • Loading branch information
msfjarvis authored Oct 12, 2023
2 parents 8c8ae01 + 4f4b4ea commit 50f2f21
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/kotlin/kage/Age.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,16 @@ public object Age {
val markSupportedStream =
if (srcStream.markSupported()) srcStream else BufferedInputStream(srcStream)

markSupportedStream.mark(ArmorInputStream.HEADER.length)
// Check if the InputStream contains whitespace + header
val readLimit = ArmorInputStream.MAX_WHITESPACE + ArmorInputStream.HEADER.length
markSupportedStream.mark(readLimit)

val headerStr = markSupportedStream.readNBytes(ArmorInputStream.HEADER.length).decodeToString()
val initialString = markSupportedStream.readNBytes(readLimit).decodeToString()

markSupportedStream.reset()

val decodedStream =
if (headerStr.startsWith(ArmorInputStream.HEADER_START)) {
if (initialString.contains(ArmorInputStream.HEADER_START)) {
ArmorInputStream(markSupportedStream)
} else markSupportedStream

Expand Down
3 changes: 1 addition & 2 deletions src/kotlin/kage/crypto/stream/ArmorInputStream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ internal class ArmorInputStream(src: InputStream) : InputStream() {

const val COLUMNS_PER_LINE = 64
const val BYTES_PER_LINE = COLUMNS_PER_LINE / 4 * 3

private const val MAX_WHITESPACE = 1024
const val MAX_WHITESPACE = 1024
}
}
5 changes: 1 addition & 4 deletions src/test/kotlin/kage/UpstreamTestSuite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class UpstreamTestSuite {

@TestFactory
fun generateTests(): List<DynamicTest> {
return Files.newDirectoryStream(testFixtureRoot).mapNotNull { path ->
// TODO: Fix the following tests
if (path.name in arrayOf("armor_garbage_leading", "armor_whitespace_outside"))
return@mapNotNull null
return Files.newDirectoryStream(testFixtureRoot).map { path ->
val contents = path.toFile().readBytes()
DynamicTest.dynamicTest(path.name) {
val suite = TestSuite.parse(contents)
Expand Down

0 comments on commit 50f2f21

Please sign in to comment.