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/runConfigurations.xml
|
||||
.idea/discord.xml
|
||||
.idea/migrations.xml
|
||||
.idea/androidTestResultsUserPreferences.xml
|
||||
|
||||
# Keystore files
|
||||
*.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 {
|
||||
resources {
|
||||
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)
|
||||
class ScramblerTest {
|
||||
|
||||
private val scrambler = Scrambler(ApplicationProvider.getApplicationContext())
|
||||
|
||||
@Test
|
||||
fun encryptDecryptTest() {
|
||||
assertEquals("TEST", decrypt(encrypt("TEST",
|
||||
ApplicationProvider.getApplicationContext())))
|
||||
assertEquals(
|
||||
"TEST", scrambler.decrypt(scrambler.encrypt("TEST"))
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun emptyTextEncryptTest() {
|
||||
assertFailsWith<ScramblerException> {
|
||||
decrypt("")
|
||||
scrambler.decrypt("")
|
||||
}
|
||||
|
||||
assertFailsWith<ScramblerException> {
|
||||
encrypt("", ApplicationProvider.getApplicationContext())
|
||||
scrambler.encrypt("")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@SdkSuppress(minSdkVersion = 18)
|
||||
fun emptyKeyStoreTest() {
|
||||
val text = encrypt("test", ApplicationProvider.getApplicationContext())
|
||||
val text = scrambler.encrypt("test")
|
||||
|
||||
val keyStore = KeyStore.getInstance("AndroidKeyStore")
|
||||
keyStore.load(null)
|
||||
keyStore.deleteEntry("wulkanowy_password")
|
||||
|
||||
assertFailsWith<ScramblerException> {
|
||||
decrypt(text)
|
||||
scrambler.decrypt(text)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user