Skip to content

Commit

Permalink
Add failing test for issue #7940.
Browse files Browse the repository at this point in the history
Former-commit-id: 9271719a981864006eb25562a09e4e24bd6ce687
  • Loading branch information
dkocher committed May 9, 2014
1 parent f5422c0 commit 1fd7379
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/ch/cyberduck/core/dav/DAVSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Collections;
import java.util.EnumSet;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;

import static org.junit.Assert.*;

Expand Down Expand Up @@ -332,4 +333,38 @@ public void testUnrecognizedName() throws Exception {
session.open(new DisabledHostKeyCallback());
session.login(new DisabledPasswordStore(), new DisabledLoginController(), new DisabledCancelCallback());
}

@Test
public void testLoginChangeUsername() throws Exception {
final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch", new Credentials(
Preferences.instance().getProperty("connection.login.anon.name"),
Preferences.instance().getProperty("connection.login.anon.pass"))
);
host.setDefaultPath("/dav/basic");
final DAVSession session = new DAVSession(host);
final AtomicBoolean prompt = new AtomicBoolean();
final LoginConnectionService c = new LoginConnectionService(new DisabledLoginController() {
@Override
public void prompt(Protocol protocol, Credentials credentials, String title, String reason, LoginOptions options) throws LoginCanceledException {
if(prompt.get()) {
fail();
}
credentials.setUsername(properties.getProperty("webdav.user"));
credentials.setPassword(properties.getProperty("webdav.password"));
prompt.set(true);
}

@Override
public void warn(Protocol protocol, String title, String message, String continueButton, String disconnectButton, String preference) throws LoginCanceledException {
//
}
}, new DisabledHostKeyCallback(),
new DisabledPasswordStore(), new DisabledProgressListener());
c.connect(session, Cache.empty());
assertTrue(prompt.get());
assertTrue(session.isConnected());
assertTrue(session.isSecured());
assertNotNull(session.workdir());
session.close();
}
}

0 comments on commit 1fd7379

Please sign in to comment.