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
8 package org.opendaylight.netconf.nettyutil.handler.ssh.authentication;
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.Mockito.doNothing;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
14 import static org.mockito.Mockito.verify;
16 import org.junit.Test;
17 import org.opendaylight.netconf.shaded.sshd.client.future.AuthFuture;
18 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
20 public class LoginPasswordHandlerTest {
22 public void testLoginPassword() throws Exception {
23 final LoginPasswordHandler loginPasswordHandler = new LoginPasswordHandler("user", "pwd");
24 assertEquals("user", loginPasswordHandler.getUsername());
26 final ClientSession session = mock(ClientSession.class);
27 doNothing().when(session).addPasswordIdentity("pwd");
28 doReturn(mock(AuthFuture.class)).when(session).auth();
29 loginPasswordHandler.authenticate(session);
31 verify(session).addPasswordIdentity("pwd");
32 verify(session).auth();