This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
19 additions
and
42 deletions.
There are no files selected for viewing
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
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
2 changes: 1 addition & 1 deletion
2
WalletSdk/src/test/java/com/spruceid/wallet/sdk/ExampleInstrumentedTest.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
53 changes: 15 additions & 38 deletions
53
WalletSdk/src/test/java/com/spruceid/wallet/sdk/KeyManagerTest.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 |
---|---|---|
@@ -1,61 +1,38 @@ | ||
package com.spruceid.wallet.sdk | ||
|
||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
import org.junit.runner.RunWith | ||
|
||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.annotation.Config | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
//@RunWith(RobolectricTestRunner::class) | ||
//@Config(sdk = [30]) | ||
class KeyManagerTest { | ||
|
||
@Test | ||
fun getKeyStore() { | ||
fun clampOrFill() { | ||
val keyManager = KeyManager() | ||
val keyStore = keyManager.getKeyStore() | ||
|
||
assertNotNull(keyStore) | ||
} | ||
|
||
@Test | ||
fun reset() { | ||
Assert.assertEquals(4, 2 + 2) | ||
} | ||
|
||
@Test | ||
fun generateSigningKey() { | ||
} | ||
|
||
@Test | ||
fun getJwk() { | ||
} | ||
// Greater than 32 | ||
val inputMoreThan = ByteArray(33) { it.toByte() } | ||
val expectedMoreThan = inputMoreThan.drop(1).toByteArray() | ||
val resultMoreThan = keyManager.clampOrFill(inputMoreThan) | ||
|
||
@Test | ||
fun keyExists() { | ||
} | ||
assertArrayEquals(expectedMoreThan, resultMoreThan) | ||
|
||
@Test | ||
fun signPayload() { | ||
} | ||
// Less than 32. | ||
val inputLessThan = ByteArray(30) { it.toByte() } | ||
val expectedLessThan = ByteArray(2) { 0.toByte() } + inputLessThan | ||
val result = keyManager.clampOrFill(inputLessThan) | ||
|
||
@Test | ||
fun generateEncryptionKey() { | ||
} | ||
assertArrayEquals(expectedLessThan, result) | ||
|
||
@Test | ||
fun encryptPayload() { | ||
} | ||
// Equal to 32. | ||
val inputEqualTo = ByteArray(32) { it.toByte() } | ||
val resultEqualTo = keyManager.clampOrFill(inputEqualTo) | ||
|
||
@Test | ||
fun decryptPayload() { | ||
assertArrayEquals(inputEqualTo, resultEqualTo) | ||
} | ||
} |