-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test for AKMAlias.matches
Added an unit test for the `AKMAlias.matches` method before refactoring it. Signed-off-by: Elv1zz <[email protected]>
- Loading branch information
1 parent
d1139f8
commit acd23e6
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
library/src/test/java/com/owncloud/android/lib/common/network/AdvancedX509KeyManagerTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.owncloud.android.lib.common.network | ||
|
||
import com.owncloud.android.lib.common.network.AdvancedX509KeyManager.AKMAlias | ||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
class AdvancedX509KeyManagerTests { | ||
|
||
@Test | ||
fun testAKMAlias_matches() { | ||
val akmAlias1 = AKMAlias(AKMAlias.Type.KEYCHAIN, "alias", "hostname", 123) | ||
val akmAlias2 = AKMAlias(AKMAlias.Type.KEYCHAIN, "alias", "hostname", 123) | ||
|
||
Assert.assertTrue(akmAlias1.matches(akmAlias1)) | ||
Assert.assertTrue(akmAlias1.matches(akmAlias2)) | ||
|
||
val akmAlias3 = AKMAlias(AKMAlias.Type.KEYSTORE, "alias", "hostname", 123) | ||
Assert.assertFalse(akmAlias1.matches(akmAlias3)) | ||
|
||
val akmAlias4 = AKMAlias(AKMAlias.Type.KEYCHAIN, "alias1", "hostname", 123) | ||
Assert.assertFalse(akmAlias1.matches(akmAlias4)) | ||
|
||
val akmAlias5 = AKMAlias(AKMAlias.Type.KEYCHAIN, "alias", "hostname1", 123) | ||
Assert.assertFalse(akmAlias1.matches(akmAlias5)) | ||
|
||
val akmAlias6 = AKMAlias(AKMAlias.Type.KEYCHAIN, "alias", "hostname", 1234) | ||
Assert.assertFalse(akmAlias1.matches(akmAlias6)) | ||
|
||
// parameters being null are considered "do-not-care" | ||
val akmAlias7 = AKMAlias(null, "alias", "hostname", 123) | ||
Assert.assertTrue(akmAlias1.matches(akmAlias7)) | ||
|
||
val akmAlias8 = AKMAlias(AKMAlias.Type.KEYCHAIN, null, "hostname", 123) | ||
Assert.assertTrue(akmAlias1.matches(akmAlias8)) | ||
|
||
val akmAlias9 = AKMAlias(AKMAlias.Type.KEYCHAIN, "alias", null, 123) | ||
Assert.assertTrue(akmAlias1.matches(akmAlias9)) | ||
|
||
val akmAlias10 = AKMAlias(null, null, null, 123) | ||
Assert.assertTrue(akmAlias1.matches(akmAlias10)) | ||
|
||
} | ||
|
||
} |