From 3e86316132fd5892bd0c6792bc34010d33b4edce Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Mon, 16 Feb 2026 04:59:40 -0800 Subject: [PATCH] chore(junit): migrate from JUnit 4 to Junit 5 --- gradle/libs.versions.toml | 4 --- sshlib/build.gradle.kts | 2 -- .../connectbot/sshlib/AgentProtocolTest.kt | 12 ++++---- .../connectbot/sshlib/AgentProviderTest.kt | 10 +++---- .../connectbot/sshlib/KeyFingerprintTest.kt | 2 +- .../sshlib/KnownHostsVerifierTest.kt | 2 +- .../org/connectbot/sshlib/SshKeysTest.kt | 9 ++++-- .../org/connectbot/sshlib/SshSigningTest.kt | 21 ++++++++----- .../connectbot/sshlib/StreamForwarderTest.kt | 2 +- .../sshlib/client/ForwardingChannelTest.kt | 10 +++---- .../sshlib/client/SessionChannelTest.kt | 8 ++--- .../sshlib/client/Socks5HandlerTest.kt | 8 ++--- .../sshlib/crypto/AesCbcCipherTest.kt | 4 +-- .../sshlib/crypto/AesGcmCipherTest.kt | 6 ++-- .../sshlib/crypto/AlgorithmsTest.kt | 30 +++++++++---------- .../crypto/ChaCha20Poly1305CipherTest.kt | 2 +- .../crypto/Curve25519KeyExchangeTest.kt | 2 +- .../org/connectbot/sshlib/crypto/DerTest.kt | 6 ++-- .../crypto/DiffieHellmanGroupExchangeTest.kt | 2 +- .../sshlib/crypto/DiffieHellmanTest.kt | 2 +- .../sshlib/crypto/EcdhKeyExchangeTest.kt | 2 +- .../crypto/EcdsaSignatureAlgorithmTest.kt | 2 +- .../crypto/Ed25519SignatureAlgorithmTest.kt | 2 +- .../crypto/Ed448SignatureAlgorithmTest.kt | 2 +- .../crypto/MlKemHybridKeyExchangeTest.kt | 2 +- .../sshlib/crypto/OpenSshKeyWriterTest.kt | 2 +- .../sshlib/crypto/PemKeyWriterTest.kt | 2 +- .../sshlib/crypto/PrivateKeyReaderTest.kt | 2 +- .../crypto/RsaSignatureAlgorithmTest.kt | 2 +- .../sshlib/crypto/SignatureGenerationTest.kt | 2 +- .../sshlib/crypto/TinkX25519ProviderTest.kt | 2 +- .../sshlib/crypto/TripleDesCbcCipherTest.kt | 6 ++-- .../sshlib/crypto/ZlibCompressorTest.kt | 4 +-- .../crypto/ed25519/Ed25519KeyFactoryTest.kt | 2 +- .../ed25519/Ed25519KeyPairGeneratorTest.kt | 2 +- .../crypto/ed25519/Ed25519PrivateKeyTest.kt | 2 +- .../connectbot/sshlib/protocol/CaptureTest.kt | 2 +- .../ForwardingChannelTransportTest.kt | 10 +++---- .../sshlib/transport/KtorTcpTransportTest.kt | 2 +- .../sshlib/transport/PacketIOEtmTest.kt | 8 ++--- 40 files changed, 104 insertions(+), 100 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e65b747..e498389 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,8 +9,6 @@ slf4j = "2.0.17" tink = "1.20.0" kyber = "2.0.1" jbcrypt = "1.0.2" -junit4 = "4.13.2" -junitVintage = "6.0.2" junit = "6.0.2" mockk = "1.14.9" logback = "1.5.29" @@ -31,8 +29,6 @@ slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" } tink = { module = "com.google.crypto.tink:tink", version.ref = "tink" } kyber = { module = "asia.hombre:kyber", version.ref = "kyber" } jbcrypt = { module = "org.connectbot:jbcrypt", version.ref = "jbcrypt" } -junit = { module = "junit:junit", version.ref = "junit4" } -junit-vintage-engine = { module = "org.junit.vintage:junit-vintage-engine", version.ref = "junitVintage" } logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" } junit-jupiter-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } junit-jupiter-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" } diff --git a/sshlib/build.gradle.kts b/sshlib/build.gradle.kts index c1cb13e..464f318 100644 --- a/sshlib/build.gradle.kts +++ b/sshlib/build.gradle.kts @@ -42,11 +42,9 @@ dependencies { implementation(libs.jbcrypt) // Unit tests - testImplementation(libs.junit) testImplementation(kotlin("test")) testImplementation(libs.kotlinx.coroutines.test) testImplementation(libs.mockk) - testRuntimeOnly(libs.junit.vintage.engine) // Integration test dependencies testImplementation(libs.junit.jupiter.api) diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProtocolTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProtocolTest.kt index 57b2e06..69a0de9 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProtocolTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProtocolTest.kt @@ -27,12 +27,12 @@ import org.connectbot.sshlib.protocol.SshAgentcRequestIdentities import org.connectbot.sshlib.protocol.SshAgentcSignRequest import org.connectbot.sshlib.protocol.createByteString import org.connectbot.sshlib.protocol.toByteArray -import org.junit.Assert.assertArrayEquals -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test import java.nio.ByteBuffer class AgentProtocolTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProviderTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProviderTest.kt index 3f771d9..aeefc1e 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProviderTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/AgentProviderTest.kt @@ -17,11 +17,11 @@ package org.connectbot.sshlib import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotEquals -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertNull -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotEquals +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.Test class AgentProviderTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/KeyFingerprintTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/KeyFingerprintTest.kt index 77574d9..01860da 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/KeyFingerprintTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/KeyFingerprintTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib -import org.junit.Test +import org.junit.jupiter.api.Test import java.util.Base64 import kotlin.test.assertEquals import kotlin.test.assertTrue diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/KnownHostsVerifierTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/KnownHostsVerifierTest.kt index d0f67ef..5c91ba2 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/KnownHostsVerifierTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/KnownHostsVerifierTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib import kotlinx.coroutines.test.runTest -import org.junit.Test +import org.junit.jupiter.api.Test import java.io.File import java.util.Base64 import kotlin.test.assertFalse diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/SshKeysTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/SshKeysTest.kt index 2b7be68..7a19e4e 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/SshKeysTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/SshKeysTest.kt @@ -16,8 +16,9 @@ package org.connectbot.sshlib -import org.junit.Test +import org.junit.jupiter.api.Test import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertNotNull import kotlin.test.assertTrue @@ -113,9 +114,11 @@ class SshKeysTest { assertEquals("EC", keyPair.public.algorithm) } - @Test(expected = SshException::class) + @Test fun `decodePemPrivateKey invalid data throws`() { - SshKeys.decodePemPrivateKey("not a valid key") + assertFailsWith { + SshKeys.decodePemPrivateKey("not a valid key") + } } @Test diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/SshSigningTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/SshSigningTest.kt index 959d7fe..c537895 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/SshSigningTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/SshSigningTest.kt @@ -22,10 +22,11 @@ import org.connectbot.sshlib.crypto.SignatureEntry import org.connectbot.sshlib.crypto.SignatureVerifier import org.connectbot.sshlib.protocol.SshPublicKey import org.connectbot.sshlib.protocol.SshSignature -import org.junit.Test +import org.junit.jupiter.api.Test import java.security.KeyPairGenerator import java.security.spec.ECGenParameterSpec import kotlin.test.assertEquals +import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.test.assertNotEquals import kotlin.test.assertTrue @@ -98,10 +99,12 @@ class SshSigningTest { assertTrue(pubKey.publicKeyBlob.isNotEmpty()) } - @Test(expected = SshException::class) + @Test fun `sign with unknown algorithm throws`() { val keyData = readKey("ed25519_unencrypted") - SshSigning.sign("unknown-algorithm", keyData, null, "data".toByteArray()) + assertFailsWith { + SshSigning.sign("unknown-algorithm", keyData, null, "data".toByteArray()) + } } private fun loadKeyPair(keyResource: String, passphrase: String? = null): java.security.KeyPair { @@ -153,11 +156,13 @@ class SshSigningTest { assertEquals(fromPrivate, authPubKey) } - @Test(expected = SshException::class) + @Test fun `encodePublicKey unsupported key type throws`() { val kpg = KeyPairGenerator.getInstance("DSA") kpg.initialize(2048) - SshSigning.encodePublicKey(kpg.generateKeyPair()) + assertFailsWith { + SshSigning.encodePublicKey(kpg.generateKeyPair()) + } } @Test @@ -232,10 +237,12 @@ class SshSigningTest { assertTrue(sigEntry.algorithm.verify(parsedPubKey, parsedSig, data)) } - @Test(expected = SshException::class) + @Test fun `signWithKeyPair unknown algorithm throws`() { val keyPair = loadKeyPair("ed25519_unencrypted") - SshSigning.signWithKeyPair("unknown-algorithm", keyPair, "data".toByteArray()) + assertFailsWith { + SshSigning.signWithKeyPair("unknown-algorithm", keyPair, "data".toByteArray()) + } } @Test diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/StreamForwarderTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/StreamForwarderTest.kt index 7bf3777..8c4a47c 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/StreamForwarderTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/StreamForwarderTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib -import org.junit.Test +import org.junit.jupiter.api.Test import kotlin.test.assertFalse import kotlin.test.assertTrue diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/client/ForwardingChannelTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/client/ForwardingChannelTest.kt index 8b008c5..1de6c5e 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/client/ForwardingChannelTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/client/ForwardingChannelTest.kt @@ -20,11 +20,11 @@ import io.mockk.coEvery import io.mockk.coVerify import io.mockk.mockk import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertArrayEquals -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test class ForwardingChannelTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/client/SessionChannelTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/client/SessionChannelTest.kt index 4da6f33..f319842 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/client/SessionChannelTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/client/SessionChannelTest.kt @@ -20,10 +20,10 @@ import io.mockk.coEvery import io.mockk.mockk import io.mockk.slot import kotlinx.coroutines.test.runTest -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test class SessionChannelTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/client/Socks5HandlerTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/client/Socks5HandlerTest.kt index a266ff0..b4b0b17 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/client/Socks5HandlerTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/client/Socks5HandlerTest.kt @@ -21,10 +21,10 @@ import io.ktor.utils.io.ByteReadChannel import io.ktor.utils.io.readFully import kotlinx.coroutines.test.runTest import org.connectbot.sshlib.Socks5Authenticator -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertNull -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.Test import java.nio.ByteBuffer class Socks5HandlerTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesCbcCipherTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesCbcCipherTest.kt index 0455751..76165b4 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesCbcCipherTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesCbcCipherTest.kt @@ -16,8 +16,8 @@ package org.connectbot.sshlib.crypto -import org.junit.Assert.assertArrayEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Test import kotlin.test.assertFailsWith import kotlin.test.assertFalse diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesGcmCipherTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesGcmCipherTest.kt index 24ac6c9..51eb05b 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesGcmCipherTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AesGcmCipherTest.kt @@ -17,8 +17,8 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.transport.TransportException -import org.junit.Assert.assertArrayEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Test import java.nio.ByteBuffer import kotlin.test.assertFailsWith @@ -166,7 +166,7 @@ class AesGcmCipherTest { val result = encryptor.encrypt(packetLength, plaintext) val decrypted = decryptor.decrypt(packetLength, result.ciphertext, result.tag) - assertArrayEquals("Packet $i failed", plaintext, decrypted) + assertArrayEquals(plaintext, decrypted, "Packet $i failed") } } diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AlgorithmsTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AlgorithmsTest.kt index d26698e..c3482ef 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AlgorithmsTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/AlgorithmsTest.kt @@ -16,13 +16,13 @@ package org.connectbot.sshlib.crypto -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertNull -import org.junit.Assert.assertSame -import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.Assertions.assertSame +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Test class AlgorithmsTest { @@ -124,8 +124,8 @@ class AlgorithmsTest { fun `CipherEntry defaults contain all entries`() { for (entry in CipherEntry.entries) { assertTrue( - "${entry.sshName} not found in defaultString", - CipherEntry.defaultString.contains(entry.sshName) + CipherEntry.defaultString.contains(entry.sshName), + "${entry.sshName} not found in defaultString" ) } } @@ -189,8 +189,8 @@ class AlgorithmsTest { fun `MacEntry defaults contain all entries`() { for (entry in MacEntry.entries) { assertTrue( - "${entry.sshName} not found in defaultString", - MacEntry.defaultString.contains(entry.sshName) + MacEntry.defaultString.contains(entry.sshName), + "${entry.sshName} not found in defaultString" ) } } @@ -266,8 +266,8 @@ class AlgorithmsTest { fun `KexEntry defaultString contains all default entries`() { for (entry in KexEntry.defaults) { assertTrue( - "${entry.sshName} not found in defaultString", - KexEntry.defaultString.contains(entry.sshName) + KexEntry.defaultString.contains(entry.sshName), + "${entry.sshName} not found in defaultString" ) } } @@ -306,8 +306,8 @@ class AlgorithmsTest { fun `SignatureEntry defaults contain all entries`() { for (entry in SignatureEntry.entries) { assertTrue( - "${entry.sshName} not found in defaultString", - SignatureEntry.defaultString.contains(entry.sshName) + SignatureEntry.defaultString.contains(entry.sshName), + "${entry.sshName} not found in defaultString" ) } } diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ChaCha20Poly1305CipherTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ChaCha20Poly1305CipherTest.kt index 2315a7e..f8533ad 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ChaCha20Poly1305CipherTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ChaCha20Poly1305CipherTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.transport.TransportException -import org.junit.Test +import org.junit.jupiter.api.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Curve25519KeyExchangeTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Curve25519KeyExchangeTest.kt index f05dbe6..37605cc 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Curve25519KeyExchangeTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Curve25519KeyExchangeTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigInteger import kotlin.test.assertContentEquals import kotlin.test.assertEquals diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DerTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DerTest.kt index 3c01b00..3c2766b 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DerTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DerTest.kt @@ -17,9 +17,9 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Assert.assertArrayEquals -import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test import java.math.BigInteger import kotlin.test.assertFailsWith diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanGroupExchangeTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanGroupExchangeTest.kt index e16a213..9b3c508 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanGroupExchangeTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanGroupExchangeTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigInteger import java.security.KeyFactory import java.security.KeyPairGenerator diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanTest.kt index b86357d..77b1a52 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/DiffieHellmanTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigInteger import java.security.KeyFactory import java.security.KeyPairGenerator diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdhKeyExchangeTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdhKeyExchangeTest.kt index bfaf962..3208049 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdhKeyExchangeTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdhKeyExchangeTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigInteger import java.security.KeyPairGenerator import java.security.interfaces.ECPublicKey diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdsaSignatureAlgorithmTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdsaSignatureAlgorithmTest.kt index 65a0d03..c387445 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdsaSignatureAlgorithmTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/EcdsaSignatureAlgorithmTest.kt @@ -19,7 +19,7 @@ package org.connectbot.sshlib.crypto import io.kaitai.struct.ByteBufferKaitaiStream import org.connectbot.sshlib.protocol.SshPublicKey import org.connectbot.sshlib.protocol.SshSignature -import org.junit.Test +import org.junit.jupiter.api.Test import java.io.ByteArrayOutputStream import java.io.DataOutputStream import java.math.BigInteger diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed25519SignatureAlgorithmTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed25519SignatureAlgorithmTest.kt index 735e832..3ffdbc6 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed25519SignatureAlgorithmTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed25519SignatureAlgorithmTest.kt @@ -19,7 +19,7 @@ package org.connectbot.sshlib.crypto import io.kaitai.struct.ByteBufferKaitaiStream import org.connectbot.sshlib.protocol.SshPublicKey import org.connectbot.sshlib.protocol.SshSignature -import org.junit.Test +import org.junit.jupiter.api.Test import java.io.ByteArrayOutputStream import java.io.DataOutputStream import java.security.KeyPairGenerator diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed448SignatureAlgorithmTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed448SignatureAlgorithmTest.kt index 0823ed2..00854bb 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed448SignatureAlgorithmTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/Ed448SignatureAlgorithmTest.kt @@ -19,7 +19,7 @@ package org.connectbot.sshlib.crypto import io.kaitai.struct.ByteBufferKaitaiStream import org.connectbot.sshlib.protocol.SshPublicKey import org.connectbot.sshlib.protocol.SshSignature -import org.junit.Test +import org.junit.jupiter.api.Test import java.io.ByteArrayOutputStream import java.io.DataOutputStream import java.security.KeyPairGenerator diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/MlKemHybridKeyExchangeTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/MlKemHybridKeyExchangeTest.kt index 3bd3acb..5c8c1cc 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/MlKemHybridKeyExchangeTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/MlKemHybridKeyExchangeTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Test +import org.junit.jupiter.api.Test import java.security.MessageDigest import kotlin.test.assertContentEquals import kotlin.test.assertEquals diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/OpenSshKeyWriterTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/OpenSshKeyWriterTest.kt index 44a396e..870dba9 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/OpenSshKeyWriterTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/OpenSshKeyWriterTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib.crypto -import org.junit.Test +import org.junit.jupiter.api.Test import java.security.interfaces.ECPublicKey import java.security.interfaces.RSAPublicKey import kotlin.test.assertEquals diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PemKeyWriterTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PemKeyWriterTest.kt index 955bc53..1eeafa2 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PemKeyWriterTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PemKeyWriterTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib.crypto -import org.junit.Test +import org.junit.jupiter.api.Test import java.security.interfaces.ECPublicKey import java.security.interfaces.RSAPublicKey import kotlin.test.assertEquals diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PrivateKeyReaderTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PrivateKeyReaderTest.kt index be8db41..6a742a3 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PrivateKeyReaderTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/PrivateKeyReaderTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto import org.connectbot.sshlib.SshException -import org.junit.Test +import org.junit.jupiter.api.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertFalse diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/RsaSignatureAlgorithmTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/RsaSignatureAlgorithmTest.kt index 20ea98c..449fdb3 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/RsaSignatureAlgorithmTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/RsaSignatureAlgorithmTest.kt @@ -19,7 +19,7 @@ package org.connectbot.sshlib.crypto import io.kaitai.struct.ByteBufferKaitaiStream import org.connectbot.sshlib.protocol.SshPublicKey import org.connectbot.sshlib.protocol.SshSignature -import org.junit.Test +import org.junit.jupiter.api.Test import java.io.ByteArrayOutputStream import java.io.DataOutputStream import java.math.BigInteger diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/SignatureGenerationTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/SignatureGenerationTest.kt index ed4b7a8..3801e65 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/SignatureGenerationTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/SignatureGenerationTest.kt @@ -19,7 +19,7 @@ package org.connectbot.sshlib.crypto import io.kaitai.struct.ByteBufferKaitaiStream import org.connectbot.sshlib.protocol.SshPublicKey import org.connectbot.sshlib.protocol.SshSignature -import org.junit.Test +import org.junit.jupiter.api.Test import kotlin.test.assertTrue class SignatureGenerationTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TinkX25519ProviderTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TinkX25519ProviderTest.kt index 3c6f1de..5310861 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TinkX25519ProviderTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TinkX25519ProviderTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib.crypto -import org.junit.Test +import org.junit.jupiter.api.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TripleDesCbcCipherTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TripleDesCbcCipherTest.kt index 174a039..de3baa4 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TripleDesCbcCipherTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/TripleDesCbcCipherTest.kt @@ -16,8 +16,8 @@ package org.connectbot.sshlib.crypto -import org.junit.Assert.assertArrayEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Test import kotlin.test.assertFailsWith import kotlin.test.assertFalse @@ -69,7 +69,7 @@ class TripleDesCbcCipherTest { val ciphertext = encryptor.encrypt(plaintext) val decrypted = decryptor.decrypt(ciphertext) - assertArrayEquals("Packet $i failed", plaintext, decrypted) + assertArrayEquals(plaintext, decrypted, "Packet $i failed") } } diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ZlibCompressorTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ZlibCompressorTest.kt index bb15347..5f53b41 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ZlibCompressorTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ZlibCompressorTest.kt @@ -16,8 +16,8 @@ package org.connectbot.sshlib.crypto -import org.junit.Assert.assertArrayEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertArrayEquals +import org.junit.jupiter.api.Test import kotlin.random.Random class ZlibCompressorTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyFactoryTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyFactoryTest.kt index 5fb9c95..82f603c 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyFactoryTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyFactoryTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib.crypto.ed25519 -import org.junit.Test +import org.junit.jupiter.api.Test import java.security.InvalidKeyException import java.security.Key import java.security.KeyFactory diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyPairGeneratorTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyPairGeneratorTest.kt index a29610b..d0aba35 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyPairGeneratorTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519KeyPairGeneratorTest.kt @@ -16,7 +16,7 @@ package org.connectbot.sshlib.crypto.ed25519 -import org.junit.Test +import org.junit.jupiter.api.Test import java.security.SecureRandom import kotlin.test.assertEquals import kotlin.test.assertIs diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519PrivateKeyTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519PrivateKeyTest.kt index db7b216..c62dda3 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519PrivateKeyTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/crypto/ed25519/Ed25519PrivateKeyTest.kt @@ -17,7 +17,7 @@ package org.connectbot.sshlib.crypto.ed25519 import org.connectbot.sshlib.crypto.DerReader -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigInteger import java.security.spec.InvalidKeySpecException import java.security.spec.PKCS8EncodedKeySpec diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/protocol/CaptureTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/protocol/CaptureTest.kt index c7274e2..876e715 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/protocol/CaptureTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/protocol/CaptureTest.kt @@ -20,7 +20,7 @@ import io.kaitai.struct.ByteBufferKaitaiStream import kotlinx.coroutines.runBlocking import org.connectbot.sshlib.transport.ByteArrayTransport import org.connectbot.sshlib.transport.PacketIO -import org.junit.Test +import org.junit.jupiter.api.Test import java.math.BigInteger import javax.crypto.Cipher import javax.crypto.Mac diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/ForwardingChannelTransportTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/ForwardingChannelTransportTest.kt index 38dfdbd..e145164 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/ForwardingChannelTransportTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/ForwardingChannelTransportTest.kt @@ -23,11 +23,11 @@ import io.mockk.mockk import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.test.runTest import org.connectbot.sshlib.client.ForwardingChannel -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Assert.fail -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Assertions.fail +import org.junit.jupiter.api.Test class ForwardingChannelTransportTest { diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/KtorTcpTransportTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/KtorTcpTransportTest.kt index 982a1d1..e34916f 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/KtorTcpTransportTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/KtorTcpTransportTest.kt @@ -22,7 +22,7 @@ import io.ktor.utils.io.ByteWriteChannel import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest -import org.junit.Test +import org.junit.jupiter.api.Test import java.net.InetAddress import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/PacketIOEtmTest.kt b/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/PacketIOEtmTest.kt index d521718..85f3ce9 100644 --- a/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/PacketIOEtmTest.kt +++ b/sshlib/src/test/kotlin/org/connectbot/sshlib/transport/PacketIOEtmTest.kt @@ -22,8 +22,8 @@ import org.connectbot.sshlib.crypto.AesCtrCipher import org.connectbot.sshlib.crypto.HmacSha256 import org.connectbot.sshlib.crypto.TripleDesCbcCipher import org.connectbot.sshlib.protocol.SshEnums -import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test class PacketIOEtmTest { @@ -125,9 +125,9 @@ class PacketIOEtmTest { val wireData = writeTransport.getWrittenData() val encryptedPayloadSize = wireData.size - 4 - 32 assertEquals( - "Encrypted payload not block-aligned for payloadSize=$payloadSize", 0, - encryptedPayloadSize % blockSize + encryptedPayloadSize % blockSize, + "Encrypted payload not block-aligned for payloadSize=$payloadSize" ) } }