-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1616 changes the password format to UNIX crypt using Apache Commons …
…Codec
- Loading branch information
Showing
6 changed files
with
216 additions
and
66 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
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
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
70 changes: 70 additions & 0 deletions
70
...ices/deegree-webservices/src/test/java/org/deegree/console/security/PasswordFileTest.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.deegree.console.security; | ||
|
||
import static org.deegree.console.security.LogBean.PASSWORD_FILE; | ||
import static org.hamcrest.CoreMatchers.*; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.isEmptyOrNullString; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
import java.security.NoSuchAlgorithmException; | ||
|
||
import org.deegree.commons.config.DeegreeWorkspace; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author <a href="mailto:friebe@lat-lon.de">Torsten Friebe</a> | ||
* @since 3.6 | ||
*/ | ||
public class PasswordFileTest { | ||
|
||
@Test | ||
@Ignore | ||
public void getCurrentContentFromWorkspaceRoot() throws IOException { | ||
File workspaceDir = new File(DeegreeWorkspace.getWorkspaceRoot()); | ||
File passwordFileFQN = new File(workspaceDir, PASSWORD_FILE); | ||
assertTrue(passwordFileFQN.exists()); | ||
assertTrue(passwordFileFQN.isFile()); | ||
PasswordFile passwordFile = new PasswordFile(passwordFileFQN); | ||
assertTrue(passwordFile.exists()); | ||
assertThat(passwordFile.getCurrentContent().toString(), not(isEmptyOrNullString())); | ||
} | ||
|
||
/** | ||
* Attention: Enabling this unit test will overwrite the content of the console.pw | ||
* file! This test is intended as an example how to create a valid console.pw file | ||
* with the new extended passwort format introduced with deegree version 3.6. | ||
* @throws IOException | ||
* @since 3.6 | ||
* @see SaltedPassword | ||
*/ | ||
@Test | ||
@Ignore | ||
public void update() throws IOException { | ||
File workspaceDir = new File(DeegreeWorkspace.getWorkspaceRoot()); | ||
File passwordFileFQN = new File(workspaceDir, PASSWORD_FILE); | ||
PasswordFile passwordFile = new PasswordFile(passwordFileFQN); | ||
passwordFile.update(new SaltedPassword("deegree3")); | ||
} | ||
|
||
@Test | ||
public void writePasswordToWriter() throws IOException, NoSuchAlgorithmException { | ||
SaltedPassword mypassword = new SaltedPassword("deegree3"); | ||
PasswordFile passwordFile = new PasswordFile(File.createTempFile("pwd", ".tmp")); | ||
StringWriter writer = new StringWriter(); | ||
passwordFile.writePasswordToWriter(new PrintWriter(writer), mypassword); | ||
assertThat(writer.toString(), not(isEmptyOrNullString())); | ||
assertThat(writer.toString(), is(equalTo(mypassword.toString()))); | ||
} | ||
|
||
@Test | ||
public void exists() throws IOException { | ||
PasswordFile passwordFile = new PasswordFile(File.createTempFile("pwd", ".tmp")); | ||
assertTrue(passwordFile.exists()); | ||
} | ||
|
||
} |
Oops, something went wrong.