Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/library/assistant/ui/settings/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public String getPassword() {
}

public void setPassword(String password) {
if (password.length() < 16) {
this.password = DigestUtils.shaHex(password);
}else
this.password = password;
this.password = DigestUtils.shaHex(password);
}

public static void initConfig() {
Expand Down
24 changes: 24 additions & 0 deletions test/library/assistant/ui/settings/PreferencesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package library.assistant.ui.settings;

import org.junit.Test;
import static org.junit.Assert.*;
import org.apache.commons.codec.digest.DigestUtils;

public class PreferencesTest {

@Test
public void testSetPasswordShort() {
Preferences pref = new Preferences();
String password = "short";
pref.setPassword(password);
assertEquals("Short password should be hashed", DigestUtils.shaHex(password), pref.getPassword());
}

@Test
public void testSetPasswordLong() {
Preferences pref = new Preferences();
String password = "verylongpasswordmorethan16chars";
pref.setPassword(password);
assertEquals("Long password should be hashed", DigestUtils.shaHex(password), pref.getPassword());
}
}
10 changes: 10 additions & 0 deletions test/stubs/library/assistant/alert/AlertMaker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package library.assistant.alert;

public class AlertMaker {

public static void showSimpleAlert(String title, String content) {
}

public static void showErrorMessage(Exception ex, String title, String content) {
}
}