forked from github/wulkanowy-mirror
Fix android tests (#2410)
This commit is contained in:
parent
fc91936884
commit
e58a60410c
2
.gitignore
vendored
2
.gitignore
vendored
@ -65,6 +65,8 @@ captures/
|
|||||||
.idea/uiDesigner.xml
|
.idea/uiDesigner.xml
|
||||||
.idea/runConfigurations.xml
|
.idea/runConfigurations.xml
|
||||||
.idea/discord.xml
|
.idea/discord.xml
|
||||||
|
.idea/migrations.xml
|
||||||
|
.idea/androidTestResultsUserPreferences.xml
|
||||||
|
|
||||||
# Keystore files
|
# Keystore files
|
||||||
*.jks
|
*.jks
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectMigrations">
|
|
||||||
<option name="MigrateToGradleLocalJavaHome">
|
|
||||||
<set>
|
|
||||||
<option value="$PROJECT_DIR$" />
|
|
||||||
</set>
|
|
||||||
</option>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -142,7 +142,9 @@ android {
|
|||||||
packagingOptions {
|
packagingOptions {
|
||||||
resources {
|
resources {
|
||||||
excludes += ['META-INF/library_release.kotlin_module',
|
excludes += ['META-INF/library_release.kotlin_module',
|
||||||
'META-INF/library-core_release.kotlin_module']
|
'META-INF/library-core_release.kotlin_module',
|
||||||
|
'META-INF/LICENSE.md',
|
||||||
|
'META-INF/LICENSE-notice.md']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,34 +14,37 @@ import kotlin.test.assertFailsWith
|
|||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class ScramblerTest {
|
class ScramblerTest {
|
||||||
|
|
||||||
|
private val scrambler = Scrambler(ApplicationProvider.getApplicationContext())
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun encryptDecryptTest() {
|
fun encryptDecryptTest() {
|
||||||
assertEquals("TEST", decrypt(encrypt("TEST",
|
assertEquals(
|
||||||
ApplicationProvider.getApplicationContext())))
|
"TEST", scrambler.decrypt(scrambler.encrypt("TEST"))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun emptyTextEncryptTest() {
|
fun emptyTextEncryptTest() {
|
||||||
assertFailsWith<ScramblerException> {
|
assertFailsWith<ScramblerException> {
|
||||||
decrypt("")
|
scrambler.decrypt("")
|
||||||
}
|
}
|
||||||
|
|
||||||
assertFailsWith<ScramblerException> {
|
assertFailsWith<ScramblerException> {
|
||||||
encrypt("", ApplicationProvider.getApplicationContext())
|
scrambler.encrypt("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SdkSuppress(minSdkVersion = 18)
|
@SdkSuppress(minSdkVersion = 18)
|
||||||
fun emptyKeyStoreTest() {
|
fun emptyKeyStoreTest() {
|
||||||
val text = encrypt("test", ApplicationProvider.getApplicationContext())
|
val text = scrambler.encrypt("test")
|
||||||
|
|
||||||
val keyStore = KeyStore.getInstance("AndroidKeyStore")
|
val keyStore = KeyStore.getInstance("AndroidKeyStore")
|
||||||
keyStore.load(null)
|
keyStore.load(null)
|
||||||
keyStore.deleteEntry("wulkanowy_password")
|
keyStore.deleteEntry("wulkanowy_password")
|
||||||
|
|
||||||
assertFailsWith<ScramblerException> {
|
assertFailsWith<ScramblerException> {
|
||||||
decrypt(text)
|
scrambler.decrypt(text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user