forked from frankframework/frankframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prefix support for CredentialFactory, improve error logging (frankfra…
- Loading branch information
1 parent
7bf550e
commit 4c26329
Showing
7 changed files
with
149 additions
and
29 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
26 changes: 26 additions & 0 deletions
26
credentialProvider/src/test/java/nl/nn/credentialprovider/CredentialFactoryTest.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,26 @@ | ||
package nl.nn.credentialprovider; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
@Ignore("Can only run before other tests that use CredentialFactory") | ||
public class CredentialFactoryTest { | ||
|
||
@Test | ||
public void testFindAliasNoPrefix() { | ||
// test depends on setting credentialFactory.class=nl.nn.credentialprovider.MockMapCredentialFactory in test/resources/credentialprovider.properties | ||
ICredentials c = CredentialFactory.getCredentials("account", null, null); | ||
assertEquals("fakeUsername", c.getUsername()); | ||
assertEquals("fakePassword", c.getPassword()); | ||
} | ||
|
||
@Test | ||
public void testFindAliasWithPrefix() { | ||
ICredentials c = CredentialFactory.getCredentials("fakePrefix:account", null, null); | ||
assertEquals("fakeUsername", c.getUsername()); | ||
assertEquals("fakePassword", c.getPassword()); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
credentialProvider/src/test/java/nl/nn/credentialprovider/MockMapCredentialFactory.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,29 @@ | ||
package nl.nn.credentialprovider; | ||
|
||
import java.io.IOException; | ||
import java.net.MalformedURLException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import nl.nn.credentialprovider.util.AppConstants; | ||
|
||
public class MockMapCredentialFactory extends MapCredentialFactory { | ||
|
||
public MockMapCredentialFactory() throws IOException { | ||
super(); | ||
} | ||
|
||
@Override | ||
public String getPropertyBase() { | ||
return "mockCredentiaFactory"; | ||
} | ||
|
||
@Override | ||
protected Map<String, String> getCredentialMap(AppConstants appConstants) throws MalformedURLException, IOException { | ||
Map<String,String> map = new HashMap<>(); | ||
map.put("account/username", "fakeUsername"); | ||
map.put("account/password", "fakePassword"); | ||
return map; | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
credentialProvider/src/test/resources/credentialprovider.properties
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,2 @@ | ||
credentialFactory.class=nl.nn.credentialprovider.MockMapCredentialFactory | ||
credentialFactory.optionalPrefix=fakePrefix: |