mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
feat: increase testing for new group config types
This commit is contained in:
parent
faeee662af
commit
f69e3846e3
3 changed files with 31 additions and 3 deletions
|
@ -4,6 +4,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import androidx.test.platform.app.InstrumentationRegistry
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
import network.loki.messenger.libsession_util.util.*
|
import network.loki.messenger.libsession_util.util.*
|
||||||
import org.hamcrest.CoreMatchers.equalTo
|
import org.hamcrest.CoreMatchers.equalTo
|
||||||
|
import org.hamcrest.CoreMatchers.hasItem
|
||||||
import org.hamcrest.CoreMatchers.not
|
import org.hamcrest.CoreMatchers.not
|
||||||
import org.hamcrest.CoreMatchers.notNullValue
|
import org.hamcrest.CoreMatchers.notNullValue
|
||||||
import org.hamcrest.MatcherAssert.assertThat
|
import org.hamcrest.MatcherAssert.assertThat
|
||||||
|
@ -272,7 +273,8 @@ class InstrumentedTests {
|
||||||
val newConf = UserProfile.newInstance(edSk)
|
val newConf = UserProfile.newInstance(edSk)
|
||||||
|
|
||||||
val accepted = newConf.merge("fakehash1" to newToPush)
|
val accepted = newConf.merge("fakehash1" to newToPush)
|
||||||
assertEquals(1, accepted)
|
assertThat(accepted, hasItem("fakehash1"))
|
||||||
|
assertThat(accepted.size, equalTo(1))
|
||||||
|
|
||||||
assertTrue(newConf.needsDump())
|
assertTrue(newConf.needsDump())
|
||||||
assertFalse(newConf.needsPush())
|
assertFalse(newConf.needsPush())
|
||||||
|
@ -664,7 +666,16 @@ class InstrumentedTests {
|
||||||
val groupConfig = UserGroupsConfig.newInstance(userSecret)
|
val groupConfig = UserGroupsConfig.newInstance(userSecret)
|
||||||
val group = groupConfig.createGroup()
|
val group = groupConfig.createGroup()
|
||||||
groupConfig.set(group)
|
groupConfig.set(group)
|
||||||
val groupMembersConfig = GroupMembersConfig.newInstance()
|
val groupMembersConfig = GroupMembersConfig.newInstance(
|
||||||
|
group.groupSessionId.pubKeyBytes,
|
||||||
|
group.signingKey()
|
||||||
|
)
|
||||||
|
val toAdd = GroupMember(userSessionId.hexString(), "user", admin = true)
|
||||||
|
groupMembersConfig.set(
|
||||||
|
toAdd
|
||||||
|
)
|
||||||
|
assertThat(groupMembersConfig.all().size, equalTo(1))
|
||||||
|
assertThat(groupMembersConfig.all(), hasItem(toAdd))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -674,8 +685,21 @@ class InstrumentedTests {
|
||||||
val group = groupConfig.createGroup()
|
val group = groupConfig.createGroup()
|
||||||
groupConfig.set(group)
|
groupConfig.set(group)
|
||||||
val allClosedGroups = groupConfig.all()
|
val allClosedGroups = groupConfig.all()
|
||||||
assertThat(allClosedGroups, equalTo(1))
|
assertThat(allClosedGroups.size, equalTo(1))
|
||||||
assertTrue(groupConfig.needsPush())
|
assertTrue(groupConfig.needsPush())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testNewGroupInfo() {
|
||||||
|
val (_, userSecret) = keyPair
|
||||||
|
val groupConfig = UserGroupsConfig.newInstance(userSecret)
|
||||||
|
val group = groupConfig.createGroup()
|
||||||
|
groupConfig.set(group)
|
||||||
|
val groupInfo = GroupInfoConfig.newInstance(group.groupSessionId.pubKeyBytes, group.signingKey())
|
||||||
|
groupInfo.setName("Test Group")
|
||||||
|
groupInfo.setDescription("This is a test group")
|
||||||
|
assertThat(groupInfo.getName(), equalTo("Test Group"))
|
||||||
|
assertThat(groupInfo.getDescription(), equalTo("This is a test group"))
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -192,6 +192,7 @@ Java_network_loki_messenger_libsession_1util_GroupInfoConfig_getDescription(JNIE
|
||||||
jobject thiz) {
|
jobject thiz) {
|
||||||
std::lock_guard guard{util::util_mutex_};
|
std::lock_guard guard{util::util_mutex_};
|
||||||
auto group_info = ptrToInfo(env, thiz);
|
auto group_info = ptrToInfo(env, thiz);
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
|
|
|
@ -10,15 +10,18 @@ class SessionId {
|
||||||
|
|
||||||
var prefix: IdPrefix?
|
var prefix: IdPrefix?
|
||||||
var publicKey: String
|
var publicKey: String
|
||||||
|
var pubKeyBytes: ByteArray
|
||||||
|
|
||||||
constructor(id: String) {
|
constructor(id: String) {
|
||||||
prefix = IdPrefix.fromValue(id)
|
prefix = IdPrefix.fromValue(id)
|
||||||
publicKey = id.drop(2)
|
publicKey = id.drop(2)
|
||||||
|
pubKeyBytes = Hex.fromStringCondensed(publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(prefix: IdPrefix, publicKey: ByteArray) {
|
constructor(prefix: IdPrefix, publicKey: ByteArray) {
|
||||||
this.prefix = prefix
|
this.prefix = prefix
|
||||||
this.publicKey = publicKey.toHexString()
|
this.publicKey = publicKey.toHexString()
|
||||||
|
this.pubKeyBytes = publicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
fun hexString() = prefix?.value + publicKey
|
fun hexString() = prefix?.value + publicKey
|
||||||
|
|
Loading…
Reference in a new issue