aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/java/de/thedevstack/conversationsplus
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2016-10-20 19:45:26 +0200
committersteckbrief <steckbrief@chefmail.de>2016-10-20 19:45:26 +0200
commit59e861ee6904296cbe8dd43c4a29513c2e928981 (patch)
treea3bf768814ece1c377caefca35bc535c758a47c5 /src/test/java/de/thedevstack/conversationsplus
parent2860088f0ea1cd5753756861c71cc7c118094f32 (diff)
parent9ec29bb1dcf664fea606105b7e700641a4b44ae4 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Diffstat (limited to 'src/test/java/de/thedevstack/conversationsplus')
-rw-r--r--src/test/java/de/thedevstack/conversationsplus/utils/SimpleCryptoUtilTest.java136
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);
+ }
+}