Skip to content

Commit

Permalink
Remove the old way in kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
Diane Huxley committed Sep 9, 2024
1 parent 0e70cf2 commit 962157c
Show file tree
Hide file tree
Showing 10 changed files with 342 additions and 1,609 deletions.
19 changes: 0 additions & 19 deletions bound/kt/src/test/kotlin/web5/sdk/crypto/keys/JwkTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,8 @@ import web5.sdk.Web5Exception
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class JwkTest {

private val testSuite = UnitTestSuite("jwk_compute_thumbprint")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_ec_valid() {
testSuite.include()
val jwk = Jwk(
kty = "EC",
crv = "secp256k1",
Expand All @@ -36,7 +24,6 @@ class JwkTest {

@Test
fun test_okp_valid() {
testSuite.include()
val jwk = Jwk(
kty = "OKP",
crv = "Ed25519",
Expand All @@ -49,7 +36,6 @@ class JwkTest {

@Test
fun test_unsupported_kty() {
testSuite.include()
val jwk = Jwk(
kty = "RSA",
crv = "RS256",
Expand All @@ -66,7 +52,6 @@ class JwkTest {

@Test
fun test_empty_kty() {
testSuite.include()
val jwk = Jwk(
kty = "",
crv = "Ed25519",
Expand All @@ -82,7 +67,6 @@ class JwkTest {

@Test
fun test_empty_x() {
testSuite.include()
val jwk = Jwk(
kty = "OKP",
crv = "Ed25519",
Expand All @@ -98,7 +82,6 @@ class JwkTest {

@Test
fun test_empty_crv() {
testSuite.include()
val jwk = Jwk(
kty = "EC",
crv = "",
Expand All @@ -115,7 +98,6 @@ class JwkTest {

@Test
fun test_ec_missing_y() {
testSuite.include()
val jwk = Jwk(
kty = "EC",
crv = "P-256",
Expand All @@ -131,7 +113,6 @@ class JwkTest {

@Test
fun test_ec_empty_y() {
testSuite.include()
val jwk = Jwk(
kty = "EC",
crv = "P-256",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,8 @@ import web5.sdk.Web5Exception
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class Ed25519SignerTest {

private val testSuite = UnitTestSuite("ed25519_sign")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_with_valid_key() {
testSuite.include()

val jwk = Ed25519Generator.generate()
val signer = Ed25519Signer(jwk)
Expand Down
42 changes: 1 addition & 41 deletions bound/kt/src/test/kotlin/web5/sdk/dids/BearerDidTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package web5.sdk.dids

import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.fail
import web5.sdk.UnitTestSuite
import web5.sdk.crypto.keys.InMemoryKeyManager
import web5.sdk.dids.methods.jwk.DidJwk
import web5.sdk.dids.methods.jwk.DidJwkCreateOptions
Expand All @@ -13,20 +11,8 @@ class BearerDidTest {
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
inner class FromPortableDid {
private val testSuite = UnitTestSuite("bearer_did_from_portable_did")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_can_instantiate_successfully() {
testSuite.include()

val portableDid = PortableDid.fromJsonString("""
{"uri":"did:web:tbd.website%3A9002:alice","document":{"id":"did:web:tbd.website%3A9002:alice","@context":["https://www.w3.org/ns/did/v1"],"verificationMethod":[{"id":"did:web:tbd.website%3A9002:alice#key-0","type":"JsonWebKey","controller":"did:web:tbd.website%3A9002:alice","publicKeyJwk":{"alg":"Ed25519","kty":"OKP","crv":"Ed25519","x":"NNoVSv_v34ombmylF572t9HYYDiJtMgfckRT1W0vW0g"}}]},"privateKeys":[{"alg":"Ed25519","kty":"OKP","crv":"Ed25519","d":"SwuWbL-Fm64OUFy6x3FBt3RiB79RcnZZrllGT24m4BA","x":"NNoVSv_v34ombmylF572t9HYYDiJtMgfckRT1W0vW0g"}]}
Expand All @@ -41,20 +27,8 @@ class BearerDidTest {
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
inner class GetSigner {
private val testSuite = UnitTestSuite("bearer_did_get_signer")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_verification_method_id_empty() {
testSuite.include()

val bearerDid = DidJwk.create()

Expand All @@ -68,7 +42,6 @@ class BearerDidTest {

@Test
fun test_not_found_by_verification_method_id() {
testSuite.include()

val bearerDid = DidJwk.create()

Expand All @@ -82,7 +55,6 @@ class BearerDidTest {

@Test
fun test_found_by_verification_method_id() {
testSuite.include()

val bearerDid = DidJwk.create()

Expand All @@ -95,20 +67,8 @@ class BearerDidTest {
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
inner class ToPortableDid {
private val testSuite = UnitTestSuite("bearer_did_to_portable_did")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_can_export() {
testSuite.include()

val inMemoryKeyManager = InMemoryKeyManager(listOf())
val bearerDid = DidJwk.create(DidJwkCreateOptions(keyManager = inMemoryKeyManager))
Expand All @@ -119,4 +79,4 @@ class BearerDidTest {
}
}
}
}
}
12 changes: 0 additions & 12 deletions bound/kt/src/test/kotlin/web5/sdk/dids/DidTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,8 @@ import web5.sdk.Web5Exception
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class DidTest {

private val testSuite = UnitTestSuite("did_parse")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_did_empty_string_should_error() {
testSuite.include()
val uri = ""

val exception = assertThrows<Web5Exception> {
Expand Down
19 changes: 1 addition & 18 deletions bound/kt/src/test/kotlin/web5/sdk/dids/ResolutionResultTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,37 +4,22 @@ import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.fail
import web5.sdk.UnitTestSuite
import web5.sdk.dids.methods.jwk.DidJwk
import web5.sdk.dids.methods.web.DidWeb

class ResolutionResultTests {
@Nested
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
inner class Resolve {
private val testSuite = UnitTestSuite("resolution_result_resolve")

@AfterAll
fun verifyAllTestsIncluded() {
if (testSuite.tests.isNotEmpty()) {
println("The following tests were not included or executed:")
testSuite.tests.forEach { println(it) }
fail("Not all tests were executed! ${testSuite.tests}")
}
}

@Test
fun test_invalid_did() {
testSuite.include()

val resolutionResult = ResolutionResult.resolve("something invalid")
assertEquals(ResolutionMetadataError.INVALID_DID, resolutionResult.resolutionMetadata.error)
}

@Test
fun test_did_jwk() {
testSuite.include()

val bearerDid = DidJwk.create()

Expand All @@ -45,7 +30,6 @@ class ResolutionResultTests {

@Test
fun test_did_web() {
testSuite.include()

val mockWebServer = MockWebServer()
mockWebServer.start()
Expand All @@ -72,10 +56,9 @@ class ResolutionResultTests {

@Test
fun test_method_not_supported() {
testSuite.include()

val resolutionResult = ResolutionResult.resolve("did:example:123")
assertEquals(ResolutionMetadataError.METHOD_NOT_SUPPORTED, resolutionResult.resolutionMetadata.error)
}
}
}
}
Loading

0 comments on commit 962157c

Please sign in to comment.