mirror of
https://github.com/etesync/android
synced 2025-01-23 14:10:54 +00:00
Fix tests following kotlin migration.
This commit is contained in:
parent
5c894e001f
commit
4795bd40ef
@ -377,8 +377,7 @@ class App : Application() {
|
|||||||
val DEFAULT_LANGUAGE = "default"
|
val DEFAULT_LANGUAGE = "default"
|
||||||
var sDefaultLocacle = Locale.getDefault()
|
var sDefaultLocacle = Locale.getDefault()
|
||||||
|
|
||||||
lateinit var appName: String
|
var appName: String = "EteSync"
|
||||||
private set
|
|
||||||
|
|
||||||
var sslSocketFactoryCompat: SSLSocketFactoryCompat? = null
|
var sslSocketFactoryCompat: SSLSocketFactoryCompat? = null
|
||||||
private set
|
private set
|
||||||
|
@ -34,7 +34,7 @@ object HttpClient {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val date = SimpleDateFormat("yyyy/MM/dd", Locale.US).format(Date(BuildConfig.buildTime))
|
val date = SimpleDateFormat("yyyy/MM/dd", Locale.US).format(Date(BuildConfig.buildTime))
|
||||||
userAgent = App.appName + "/" + BuildConfig.VERSION_NAME + " (" + date + "; okhttp3) Android/" + Build.VERSION.RELEASE
|
userAgent = "${App.appName}/${BuildConfig.VERSION_NAME} (${date}; okhttp3) Android/${Build.VERSION.RELEASE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun create(context: Context?, logger: Logger, host: String?, token: String): OkHttpClient {
|
fun create(context: Context?, logger: Logger, host: String?, token: String): OkHttpClient {
|
||||||
@ -52,7 +52,7 @@ object HttpClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun create(context: Context, logger: Logger = App.log): OkHttpClient {
|
fun create(context: Context?, logger: Logger = App.log): OkHttpClient {
|
||||||
return defaultBuilder(context, logger).build()
|
return defaultBuilder(context, logger).build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +68,8 @@ class ServiceTest {
|
|||||||
val info = CollectionInfo.defaultForServiceType(CollectionInfo.Type.ADDRESS_BOOK)
|
val info = CollectionInfo.defaultForServiceType(CollectionInfo.Type.ADDRESS_BOOK)
|
||||||
info.uid = JournalManager.Journal.genUid()
|
info.uid = JournalManager.Journal.genUid()
|
||||||
info.displayName = "Test"
|
info.displayName = "Test"
|
||||||
val crypto = Crypto.CryptoManager(info.version, Helpers.keyBase64, info.uid)
|
val crypto = Crypto.CryptoManager(info.version, Helpers.keyBase64, info.uid!!)
|
||||||
var journal = JournalManager.Journal(crypto, info.toJson(), info.uid)
|
var journal = JournalManager.Journal(crypto, info.toJson(), info.uid!!)
|
||||||
journalManager.create(journal)
|
journalManager.create(journal)
|
||||||
|
|
||||||
// Try pushing the same journal (uid clash)
|
// Try pushing the same journal (uid clash)
|
||||||
@ -89,7 +89,7 @@ class ServiceTest {
|
|||||||
|
|
||||||
// Update journal
|
// Update journal
|
||||||
info.displayName = "Test 2"
|
info.displayName = "Test 2"
|
||||||
journal = JournalManager.Journal(crypto, info.toJson(), info.uid)
|
journal = JournalManager.Journal(crypto, info.toJson(), info.uid!!)
|
||||||
journalManager.update(journal)
|
journalManager.update(journal)
|
||||||
|
|
||||||
journals = journalManager.list()
|
journals = journalManager.list()
|
||||||
@ -105,7 +105,7 @@ class ServiceTest {
|
|||||||
|
|
||||||
// Bad HMAC
|
// Bad HMAC
|
||||||
info.uid = JournalManager.Journal.genUid()
|
info.uid = JournalManager.Journal.genUid()
|
||||||
journal = JournalManager.Journal(crypto, info.toJson(), info.uid)
|
journal = JournalManager.Journal(crypto, info.toJson(), info.uid!!)
|
||||||
info.displayName = "Test 3"
|
info.displayName = "Test 3"
|
||||||
//// We assume this doesn't update the hmac.
|
//// We assume this doesn't update the hmac.
|
||||||
journal.setContent(crypto, info.toJson())
|
journal.setContent(crypto, info.toJson())
|
||||||
@ -133,11 +133,11 @@ class ServiceTest {
|
|||||||
val info = CollectionInfo.defaultForServiceType(CollectionInfo.Type.ADDRESS_BOOK)
|
val info = CollectionInfo.defaultForServiceType(CollectionInfo.Type.ADDRESS_BOOK)
|
||||||
info.uid = JournalManager.Journal.genUid()
|
info.uid = JournalManager.Journal.genUid()
|
||||||
info.displayName = "Test"
|
info.displayName = "Test"
|
||||||
val crypto = Crypto.CryptoManager(info.version, Helpers.keyBase64, info.uid)
|
val crypto = Crypto.CryptoManager(info.version, Helpers.keyBase64, info.uid!!)
|
||||||
val journal = JournalManager.Journal(crypto, info.toJson(), info.uid)
|
val journal = JournalManager.Journal(crypto, info.toJson(), info.uid!!)
|
||||||
journalManager.create(journal)
|
journalManager.create(journal)
|
||||||
|
|
||||||
val journalEntryManager = JournalEntryManager(httpClient!!, remote!!, info.uid)
|
val journalEntryManager = JournalEntryManager(httpClient!!, remote!!, info.uid!!)
|
||||||
var previousEntry: JournalEntryManager.Entry? = null
|
var previousEntry: JournalEntryManager.Entry? = null
|
||||||
val entry = JournalEntryManager.Entry()
|
val entry = JournalEntryManager.Entry()
|
||||||
entry.update(crypto, "Content", previousEntry)
|
entry.update(crypto, "Content", previousEntry)
|
||||||
@ -240,8 +240,8 @@ class ServiceTest {
|
|||||||
val info = CollectionInfo.defaultForServiceType(CollectionInfo.Type.ADDRESS_BOOK)
|
val info = CollectionInfo.defaultForServiceType(CollectionInfo.Type.ADDRESS_BOOK)
|
||||||
info.uid = JournalManager.Journal.genUid()
|
info.uid = JournalManager.Journal.genUid()
|
||||||
info.displayName = "Test"
|
info.displayName = "Test"
|
||||||
val crypto = Crypto.CryptoManager(info.version, Helpers.keyBase64, info.uid)
|
val crypto = Crypto.CryptoManager(info.version, Helpers.keyBase64, info.uid!!)
|
||||||
val journal = JournalManager.Journal(crypto, info.toJson(), info.uid)
|
val journal = JournalManager.Journal(crypto, info.toJson(), info.uid!!)
|
||||||
journalManager.create(journal)
|
journalManager.create(journal)
|
||||||
|
|
||||||
assertEquals(journalManager.listMembers(journal).size.toLong(), 0)
|
assertEquals(journalManager.listMembers(journal).size.toLong(), 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user