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); } }