-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add encryption tests for existing user and customerUser, fix hibernat…
…e4 maven plugin to not export table droppings, remove hibernate4 maven plugin from general pom file, add connection properties to hibernate4 maven plugin for all databases
- Loading branch information
Showing
5 changed files
with
107 additions
and
173 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
1 change: 0 additions & 1 deletion
1
modules/core/src/main/java/io/smsc/model/dashboard/DashboardBox.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
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
39 changes: 36 additions & 3 deletions
39
modules/core/src/test/java/io/smsc/encryption/EncrypterUtilTest.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 |
---|---|---|
@@ -1,44 +1,77 @@ | ||
package io.smsc.encryption; | ||
|
||
import io.smsc.AbstractTest; | ||
import io.smsc.model.CustomerUser; | ||
import io.smsc.model.User; | ||
import io.smsc.util.EncrypterUtil; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.security.crypto.keygen.KeyGenerators; | ||
|
||
import static io.smsc.util.EncrypterUtil.removeCryptographyRestrictions; | ||
|
||
public class EncrypterUtilTest { | ||
public class EncrypterUtilTest extends AbstractTest { | ||
|
||
@Before | ||
public void removeCryptographyRestriction() { | ||
removeCryptographyRestrictions(); | ||
} | ||
|
||
@Test | ||
public void testEncryptDecryptUserPassword() { | ||
public void testNewUserEncryptDecryptPassword() { | ||
User user = new User(); | ||
user.setPassword("john123456"); | ||
EncrypterUtil.encrypt(user); | ||
System.out.println("Encrypted password: " + user.getPassword()); | ||
System.out.println("Salt: " + user.getSalt()); | ||
EncrypterUtil.decrypt(user); | ||
System.out.println("Decrypted password: " + user.getPassword()); | ||
Assert.assertEquals("john123456", user.getPassword()); | ||
} | ||
|
||
@Test | ||
public void testNewCustomerUserEncryptDecryptPassword() { | ||
CustomerUser customerUser = new CustomerUser(); | ||
customerUser.setPassword("john123456"); | ||
System.out.println("Raw password: " + customerUser.getPassword()); | ||
EncrypterUtil.encrypt(customerUser); | ||
System.out.println("Encrypted password: " + customerUser.getPassword()); | ||
System.out.println("Salt: " + customerUser.getSalt()); | ||
EncrypterUtil.decrypt(customerUser); | ||
System.out.println("Decrypted password: " + customerUser.getPassword()); | ||
Assert.assertEquals("john123456", customerUser.getPassword()); | ||
} | ||
|
||
@Test | ||
public void testExistingUserEncryptDecryptPassword() { | ||
User user = new User(); | ||
user.setPassword("john123456"); | ||
String salt = KeyGenerators.string().generateKey(); | ||
user.setSalt(salt); | ||
System.out.println("Raw password: " + user.getPassword()); | ||
EncrypterUtil.encrypt(user); | ||
System.out.println("Encrypted password: " + user.getPassword()); | ||
System.out.println("Salt: " + user.getSalt()); | ||
EncrypterUtil.decrypt(user); | ||
System.out.println("Decrypted password: " + user.getPassword()); | ||
Assert.assertEquals("john123456", user.getPassword()); | ||
Assert.assertEquals(salt, user.getSalt()); | ||
} | ||
|
||
@Test | ||
public void testEncryptDecryptCustomerUserPassword() { | ||
public void testExistingCustomerUserEncryptDecryptPassword() { | ||
CustomerUser customerUser = new CustomerUser(); | ||
customerUser.setPassword("john123456"); | ||
String salt = KeyGenerators.string().generateKey(); | ||
customerUser.setSalt(salt); | ||
System.out.println("Raw password: " + customerUser.getPassword()); | ||
EncrypterUtil.encrypt(customerUser); | ||
System.out.println("Encrypted password: " + customerUser.getPassword()); | ||
System.out.println("Salt: " + customerUser.getSalt()); | ||
EncrypterUtil.decrypt(customerUser); | ||
System.out.println("Decrypted password: " + customerUser.getPassword()); | ||
Assert.assertEquals("john123456", customerUser.getPassword()); | ||
Assert.assertEquals(salt, customerUser.getSalt()); | ||
} | ||
} |
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