-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from apptentive/branch_5.3.0
Release 5.3.0
- Loading branch information
Showing
47 changed files
with
1,873 additions
and
750 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
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
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
54 changes: 54 additions & 0 deletions
54
...ntive/src/androidTest/java/com/apptentive/android/sdk/encryption/SecurityManagerTest.java
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,54 @@ | ||
package com.apptentive.android.sdk.encryption; | ||
|
||
import com.apptentive.android.sdk.InstrumentationTestCaseBase; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.Random; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class SecurityManagerTest extends InstrumentationTestCaseBase { | ||
private static final int TEST_DATA_SIZE = 8096; | ||
|
||
@Before | ||
public void setup() { | ||
SecurityManager.clear(getContext()); | ||
SecurityManager.init(getContext()); | ||
} | ||
|
||
@Test | ||
public void testDataEncryptionDecryption() throws Exception { | ||
EncryptionKey key = SecurityManager.getMasterKey(); | ||
|
||
// Set up the test data | ||
byte[] testData = new byte[TEST_DATA_SIZE]; | ||
new Random().nextBytes(testData); | ||
|
||
byte[] cipherText = Encryptor.encrypt(key, testData); | ||
assertNotNull(cipherText); | ||
|
||
byte[] plainText = Encryptor.decrypt(key, cipherText); | ||
assertNotNull(plainText); | ||
|
||
assertTrue(Arrays.equals(plainText, testData)); | ||
} | ||
|
||
@Test | ||
public void testStringEncryptionDecryption() throws Exception { | ||
EncryptionKey key = SecurityManager.getMasterKey(); | ||
|
||
// Set up the test data | ||
String testData = "Test data"; | ||
|
||
byte[] cipherText = Encryptor.encrypt(key, testData); | ||
assertNotNull(cipherText); | ||
|
||
String plainText = Encryptor.decryptString(key, cipherText); | ||
assertNotNull(plainText); | ||
|
||
assertEquals(plainText, testData); | ||
} | ||
} |
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
Oops, something went wrong.