Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2013-01-16 19:14:38 +0000
committerSteffen Pingel2013-10-08 01:55:47 +0000
commit3b1cb33184c84edfc8a6bba711ab9d47acd648b4 (patch)
treeb49163b64284cfafff81446cfcaac7df5cb32c76 /org.eclipse.mylyn.tasks.tests
parented32420d9f87d18a801caed2caddcfa6901492cb (diff)
downloadorg.eclipse.mylyn.tasks-3b1cb33184c84edfc8a6bba711ab9d47acd648b4.tar.gz
org.eclipse.mylyn.tasks-3b1cb33184c84edfc8a6bba711ab9d47acd648b4.tar.xz
org.eclipse.mylyn.tasks-3b1cb33184c84edfc8a6bba711ab9d47acd648b4.zip
326119: Repository credentials are overwritten during repository
settings validation Change-Id: I0f8becdc0bc2869d67de80401920bf6f7d69bd87 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=326119
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java
index dcec4ed99..554498487 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskRepositoryCredentialsTest.java
@@ -159,4 +159,46 @@ public class TaskRepositoryCredentialsTest extends TestCase {
assertEquals("Time stamp set", stamp.getTime(), taskRepository.getConfigurationDate().getTime());
}
+ public void testDoNotPersistCredentials() throws Exception {
+ TaskRepository repository = new TaskRepository("kind", "http://url");
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("user", "pwd"), true);
+ assertEquals("pwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+
+ repository.setShouldPersistCredentials(false);
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("user", "newpwd"), true);
+ assertEquals("newpwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+
+ repository.setShouldPersistCredentials(true);
+ assertEquals("pwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ }
+
+ public void testSetCredentialsDoesNotAffectExistingRepositoryWhenShouldNotPersistIsSetToTrue() throws Exception {
+ TaskRepository repository = new TaskRepository("kind", "http://url");
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("user", "pwd"), true);
+ assertEquals("pwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+
+ TaskRepository newRepository = new TaskRepository("kind", "http://url");
+ newRepository.setShouldPersistCredentials(false);
+ newRepository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("newuser", "newpwd"),
+ true);
+ assertEquals("pwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ assertEquals("newpwd", newRepository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("user", "pwd2"), true);
+ assertEquals("pwd2", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ assertEquals("newpwd", newRepository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ }
+
+ public void testSetCredentialsAffectExistingRepository() throws Exception {
+ TaskRepository repository = new TaskRepository("kind", "http://url");
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("user", "pwd"), true);
+ assertEquals("pwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+
+ TaskRepository newRepository = new TaskRepository("kind", "http://url");
+ newRepository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("newuser", "newpwd"),
+ true);
+ assertEquals("newpwd", repository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ assertEquals("newpwd", newRepository.getCredentials(AuthenticationType.REPOSITORY).getPassword());
+ }
+
}

Back to the top