1 package ch
.cyberduck
.core
.irods
;
4 * Copyright (c) 2002-2015 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
20 import ch
.cyberduck
.core
.AbstractTestCase
;
21 import ch
.cyberduck
.core
.AttributedList
;
22 import ch
.cyberduck
.core
.Credentials
;
23 import ch
.cyberduck
.core
.DisabledCancelCallback
;
24 import ch
.cyberduck
.core
.DisabledHostKeyCallback
;
25 import ch
.cyberduck
.core
.DisabledListProgressListener
;
26 import ch
.cyberduck
.core
.DisabledLoginCallback
;
27 import ch
.cyberduck
.core
.DisabledPasswordStore
;
28 import ch
.cyberduck
.core
.DisabledTranscriptListener
;
29 import ch
.cyberduck
.core
.Host
;
30 import ch
.cyberduck
.core
.Local
;
31 import ch
.cyberduck
.core
.Path
;
32 import ch
.cyberduck
.core
.Profile
;
33 import ch
.cyberduck
.core
.ProfileReaderFactory
;
34 import ch
.cyberduck
.core
.exception
.LoginFailureException
;
36 import org
.junit
.Test
;
38 import static org
.junit
.Assert
.*;
43 public class IRODSSessionTest
extends AbstractTestCase
{
46 public void testConnect() throws Exception
{
47 final Profile profile
= ProfileReaderFactory
.get().read(
48 new Local("profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
49 final Host host
= new Host(profile
, profile
.getDefaultHostname(), new Credentials(
50 properties
.getProperty("irods.key"), properties
.getProperty("irods.secret")
53 final IRODSSession session
= new IRODSSession(host
);
55 assertNotNull(session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()));
56 assertTrue(session
.isConnected());
57 assertNotNull(session
.getClient());
60 assertFalse(session
.isConnected());
64 public void testLogin() throws Exception
{
65 final Profile profile
= ProfileReaderFactory
.get().read(
66 new Local("profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
67 final Host host
= new Host(profile
, profile
.getDefaultHostname(), new Credentials(
68 properties
.getProperty("irods.key"), properties
.getProperty("irods.secret")
71 final IRODSSession session
= new IRODSSession(host
);
73 assertNotNull(session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()));
74 assertTrue(session
.isConnected());
75 assertNotNull(session
.getClient());
77 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
78 assertNotNull(session
.workdir());
80 final AttributedList
<Path
> list
= session
.list(session
.workdir(), new DisabledListProgressListener());
81 assertFalse(list
.isEmpty());
83 assertTrue(session
.isConnected());
85 assertFalse(session
.isConnected());
88 @Test(expected
= LoginFailureException
.class)
89 public void testLoginFailure() throws Exception
{
90 final Profile profile
= ProfileReaderFactory
.get().read(
91 new Local("profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
92 final Host host
= new Host(profile
, profile
.getDefaultHostname(), new Credentials("a", "a"));
94 final IRODSSession session
= new IRODSSession(host
);
95 assertNotNull(session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()));
96 assertTrue(session
.isConnected());
97 assertNotNull(session
.getClient());
98 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());