refactoring android tests to match refactoring of package names
moving some nip96 stuff to quartz
This commit is contained in:
+1
-2
@@ -18,12 +18,11 @@
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.vitorpamplona.quartz.experimental
|
||||
package com.vitorpamplona.quartz.nip01Core.experimental
|
||||
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.EventHasher
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.experimental.Nip01Serializer
|
||||
import com.vitorpamplona.quartz.nip01Core.generateId
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import org.junit.Test
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Vitor Pamplona
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
* Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.vitorpamplona.quartz.nip05DnsIdentifiers
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.fail
|
||||
import org.junit.Test
|
||||
|
||||
class Nip05Test {
|
||||
companion object {
|
||||
private val ALL_UPPER_CASE_USER_NAME = "ONETWO"
|
||||
private val ALL_LOWER_CASE_USER_NAME = "onetwo"
|
||||
}
|
||||
|
||||
var nip05Verifier = Nip05()
|
||||
|
||||
@Test
|
||||
fun `test with matching case on user name`() =
|
||||
runBlocking {
|
||||
// Set-up
|
||||
val userNameToTest = ALL_UPPER_CASE_USER_NAME
|
||||
val expectedPubKey = "ca29c211f1c72d5b6622268ff43d2288ea2b2cb5b9aa196ff9f1704fc914b71b"
|
||||
val nostrJson = "{\n \"names\": {\n \"$userNameToTest\": \"$expectedPubKey\" \n }\n}"
|
||||
val nip05 = "$userNameToTest@domain.com"
|
||||
|
||||
nip05Verifier.parseHexKeyFor(nip05, nostrJson).fold(
|
||||
onSuccess = { assertEquals(expectedPubKey, it) },
|
||||
onFailure = { fail("Test failure") },
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test with NOT matching case on user name`() =
|
||||
runBlocking {
|
||||
// Set-up
|
||||
val expectedPubKey = "ca29c211f1c72d5b6622268ff43d2288ea2b2cb5b9aa196ff9f1704fc914b71b"
|
||||
val nostrJson = "{ \"names\": { \"$ALL_UPPER_CASE_USER_NAME\": \"$expectedPubKey\" }}"
|
||||
|
||||
val nip05 = "$ALL_LOWER_CASE_USER_NAME@domain.com"
|
||||
|
||||
nip05Verifier.parseHexKeyFor(nip05, nostrJson).fold(
|
||||
onSuccess = { assertEquals(expectedPubKey, it) },
|
||||
onFailure = { fail("Test failure") },
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `execute assemble url with invalid value returns null`() {
|
||||
// given
|
||||
val nip05address = "this@that@that.com"
|
||||
|
||||
// when
|
||||
val actualValue = nip05Verifier.assembleUrl(nip05address)
|
||||
|
||||
// then
|
||||
assertNull(actualValue)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `execute assemble url with valid value returns nip05 url`() {
|
||||
// given
|
||||
val userName = "TheUser"
|
||||
val domain = "domain.com"
|
||||
val nip05address = "$userName@$domain"
|
||||
val expectedValue = "https://$domain/.well-known/nostr.json?name=$userName"
|
||||
|
||||
// when
|
||||
val actualValue = nip05Verifier.assembleUrl(nip05address)
|
||||
|
||||
// then
|
||||
assertEquals(expectedValue, actualValue)
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,14 @@
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.vitorpamplona.quartz.nip19Bech32Entities
|
||||
package com.vitorpamplona.quartz.nip19Bech32
|
||||
|
||||
import com.vitorpamplona.quartz.nip01Core.addressables.ATag
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.entities.NAddress
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.entities.NEvent
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.entities.NProfile
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.entities.NPub
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.entities.Note
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.addressables.ATag
|
||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NAddress
|
||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NEvent
|
||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NProfile
|
||||
import com.vitorpamplona.quartz.nip19Bech32.entities.NPub
|
||||
import com.vitorpamplona.quartz.nip19Bech32.entities.Note
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package com.vitorpamplona.quartz.nip19Bech32Entities
|
||||
package com.vitorpamplona.quartz.nip19Bech32
|
||||
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.tlv.to32BitByteArray
|
||||
import com.vitorpamplona.quartz.nip19Bech32Entities.tlv.toInt32
|
||||
import com.vitorpamplona.quartz.nip19Bech32.tlv.to32BitByteArray
|
||||
import com.vitorpamplona.quartz.nip19Bech32.tlv.toInt32
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
Reference in New Issue
Block a user