diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-07-16 15:11:36 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-07-16 15:11:36 +0200 |
commit | 97100834a5bcb08f2fdf2eb6c580d3ceeb8b6b2f (patch) | |
tree | 7dc5897dc229b39a123484fb3a20bb989ee3c1fb /src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java | |
parent | 10e607ac51dcc42fa1b54bacb698beed43750de7 (diff) |
Implements FS#227: Store password encrypted in internal database
Diffstat (limited to 'src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java')
-rw-r--r-- | src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java b/src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java new file mode 100644 index 00000000..7e71a3bf --- /dev/null +++ b/src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java @@ -0,0 +1,136 @@ +package de.thedevstack.conversationsplus.utils; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Created by steckbrief on 10.07.2016. + */ +public class SimpleCryptoUtilTest { + @Test + public void testEncryptWithNullSeed() { + String seed = null; + String cleartext = "Test123"; + String expectedResult = null; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testEncryptWithWhitespaceSeed() { + String seed = " "; + String cleartext = "Test123"; + String expectedResult = "3E7721EF6F8D9E47403AC03F45341E5C"; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testEncryptWithZeroLengthSeed() { + String seed = ""; + String cleartext = "Test123"; + String expectedResult = "BEFF4A6800B91AE505672CA238D7C72F"; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testEncryptWithNullCleartext() { + String seed = "asdasdadasd"; + String cleartext = null; + String expectedResult = null; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testEncryptWithWhitespaceCleartext() { + String seed = "asdasdadasd"; + String cleartext = " "; + String expectedResult = "1C476E5E4E66809AB6C91EEF9C93A32F"; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testEncryptWithZeroLengthCleartext() { + String seed = "asdasdadasd"; + String cleartext = ""; + String expectedResult = "22BD1DA9232CA6594A466B419B2AFB8C"; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testEncrypt() { + String seed = "asdasdadasd"; + String cleartext = "Test123"; + String expectedResult = "E1D9C96AAF09434D915A2F0C147CBF64"; + String result = SimpleCryptoUtil.encrypt(seed, cleartext); + assertEquals(expectedResult, result); + } + + @Test + public void testDecryptWithNullSeed() { + String seed = null; + String encryptedText = "E1D9C96AAF09434D915A2F0C147CBF64"; + String expectedResult = null; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } + + @Test + public void testDecryptWithWhitespaceSeed() { + String seed = " "; + String encryptedText = "3E7721EF6F8D9E47403AC03F45341E5C"; + String expectedResult = "Test123"; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } + + @Test + public void testDecryptWithZeroLengthSeed() { + String seed = ""; + String encryptedText = "BEFF4A6800B91AE505672CA238D7C72F"; + String expectedResult = "Test123"; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } + + @Test + public void testDecryptWithNullEncryptedText() { + String seed = "asdasdadasd"; + String encryptedText = null; + String expectedResult = null; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } + + @Test + public void testDecryptWithWhitespaceEncryptedText() { + String seed = "asdasdadasd"; + String encryptedText = " "; + String expectedResult = ""; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } + + @Test + public void testDecryptWithZeroLengthEncryptedText() { + String seed = "asdasdadasd"; + String encryptedText = ""; + String expectedResult = ""; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } + + @Test + public void testDecrypt() { + String seed = "asdasdadasd"; + String encryptedText = "E1D9C96AAF09434D915A2F0C147CBF64"; + String expectedResult = "Test123"; + String result = SimpleCryptoUtil.decrypt(seed, encryptedText); + assertEquals(expectedResult, result); + } +} |