2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.nettyutil.handler.ssh.authentication;
11 import static org.junit.Assert.assertEquals;
12 import static org.mockito.Mockito.doNothing;
13 import static org.mockito.Mockito.doReturn;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.verify;
17 import org.apache.sshd.ClientSession;
18 import org.apache.sshd.client.future.AuthFuture;
19 import org.junit.Test;
21 public class LoginPasswordTest {
24 public void testLoginPassword() throws Exception {
25 final LoginPassword loginPassword = new LoginPassword("user", "pwd");
26 assertEquals("user", loginPassword.getUsername());
28 final ClientSession session = mock(ClientSession.class);
29 doNothing().when(session).addPasswordIdentity("pwd");
30 doReturn(mock(AuthFuture.class)).when(session).auth();
31 loginPassword.authenticate(session);
33 verify(session).addPasswordIdentity("pwd");
34 verify(session).auth();