Skip to content

Commit

Permalink
fix: Move PoWebContentType to Relaynet library (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea authored Jan 8, 2021
1 parent 3120eed commit 70a7948
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ dependencies {

implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")

api('tech.relaycorp:relaynet:[1.40.0,2.0.0)')
testImplementation('tech.relaycorp:relaynet-testing:1.2.0')
api('tech.relaycorp:relaynet:[1.41.0,2.0.0)')
testImplementation('tech.relaycorp:relaynet-testing:1.2.1')

// We're depending on BouncyCastle just so we can use a base64 encoder on Android 21+. See:
// https://github.com/relaycorp/relaynet-poweb-jvm/issues/66
Expand Down
9 changes: 5 additions & 4 deletions src/main/kotlin/tech/relaycorp/poweb/PoWebClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.flow
import okhttp3.OkHttpClient
import org.bouncycastle.util.encoders.Base64
import tech.relaycorp.relaynet.bindings.ContentTypes
import tech.relaycorp.relaynet.bindings.pdc.ClientBindingException
import tech.relaycorp.relaynet.bindings.pdc.DetachedSignatureType
import tech.relaycorp.relaynet.bindings.pdc.NonceSignerException
Expand Down Expand Up @@ -297,13 +298,13 @@ public class PoWebClient internal constructor(
private const val DEFAULT_LOCAL_PORT = 276
private const val DEFAULT_REMOTE_PORT = 443

private val PARCEL_CONTENT_TYPE = ContentType.parse(PoWebContentType.PARCEL.value)
private val PARCEL_CONTENT_TYPE = ContentType.parse(ContentTypes.PARCEL.value)
private val PRE_REGISTRATION_CONTENT_TYPE =
ContentType.parse(PoWebContentType.PRE_REGISTRATION.value)
ContentType.parse(ContentTypes.NODE_PRE_REGISTRATION.value)
private val PNRA_CONTENT_TYPE =
ContentType.parse(PoWebContentType.REGISTRATION_AUTHORIZATION.value)
ContentType.parse(ContentTypes.NODE_REGISTRATION_AUTHORIZATION.value)
private val PNRR_CONTENT_TYPE =
ContentType("application", "vnd.relaynet.node-registration.request")
ContentType.parse(ContentTypes.NODE_REGISTRATION_REQUEST.value)
private val PNR_CONTENT_TYPE =
ContentType("application", "vnd.relaynet.node-registration.registration")

Expand Down
14 changes: 0 additions & 14 deletions src/main/kotlin/tech/relaycorp/poweb/PoWebContentType.kt

This file was deleted.

3 changes: 2 additions & 1 deletion src/test/kotlin/tech/relaycorp/poweb/ParcelDeliveryTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kotlinx.coroutines.test.runBlockingTest
import org.bouncycastle.util.encoders.Base64
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import tech.relaycorp.relaynet.bindings.ContentTypes
import tech.relaycorp.relaynet.bindings.pdc.ClientBindingException
import tech.relaycorp.relaynet.bindings.pdc.DetachedSignatureType
import tech.relaycorp.relaynet.bindings.pdc.RejectedParcelException
Expand Down Expand Up @@ -66,7 +67,7 @@ class ParcelDeliveryTest {

client.use { client.deliverParcel(parcelSerialized, signer) }

assertEquals(PoWebContentType.PARCEL.value, contentType)
assertEquals(ContentTypes.PARCEL.value, contentType)
}

@Test
Expand Down
9 changes: 5 additions & 4 deletions src/test/kotlin/tech/relaycorp/poweb/RegistrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import kotlinx.coroutines.test.runBlockingTest
import org.junit.jupiter.api.Nested
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import tech.relaycorp.relaynet.bindings.ContentTypes
import tech.relaycorp.relaynet.bindings.pdc.ServerBindingException
import tech.relaycorp.relaynet.messages.InvalidMessageException
import tech.relaycorp.relaynet.messages.control.PrivateNodeRegistration
Expand All @@ -29,7 +30,7 @@ class RegistrationTest {
inner class PreRegistration {
private val publicKey = KeyPairSet.PRIVATE_GW.public
private val responseHeaders =
headersOf("Content-Type", PoWebContentType.REGISTRATION_AUTHORIZATION.value)
headersOf("Content-Type", ContentTypes.NODE_REGISTRATION_AUTHORIZATION.value)

@Test
fun `Request method should be POST`() = runBlockingTest {
Expand Down Expand Up @@ -67,7 +68,7 @@ class RegistrationTest {

client.use { client.preRegisterNode(publicKey) }

assertEquals(PoWebContentType.PRE_REGISTRATION.value, contentType.toString())
assertEquals(ContentTypes.NODE_PRE_REGISTRATION.value, contentType.toString())
}

@Test
Expand Down Expand Up @@ -132,7 +133,7 @@ class RegistrationTest {
inner class Registration {
private val pnrrSerialized = "The PNRR".toByteArray()
private val responseHeaders =
headersOf("Content-Type", PoWebContentType.REGISTRATION.value)
headersOf("Content-Type", ContentTypes.NODE_REGISTRATION.value)

private val registration =
PrivateNodeRegistration(PDACertPath.PRIVATE_GW, PDACertPath.PUBLIC_GW)
Expand Down Expand Up @@ -174,7 +175,7 @@ class RegistrationTest {

client.use { client.registerNode(pnrrSerialized) }

assertEquals(PoWebContentType.REGISTRATION_REQUEST.value, contentType.toString())
assertEquals(ContentTypes.NODE_REGISTRATION_REQUEST.value, contentType.toString())
}

@Test
Expand Down

0 comments on commit 70a7948

Please sign in to comment.