BUG-1521 Increase test coverage of netconf-netty-util
[controller.git] / opendaylight / netconf / netconf-netty-util / src / test / java / org / opendaylight / controller / netconf / nettyutil / handler / ssh / authentication / LoginPasswordTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.netconf.nettyutil.handler.ssh.authentication;
10
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;
16
17 import org.apache.sshd.ClientSession;
18 import org.apache.sshd.client.future.AuthFuture;
19 import org.junit.Test;
20
21 public class LoginPasswordTest {
22
23     @Test
24     public void testLoginPassword() throws Exception {
25         final LoginPassword loginPassword = new LoginPassword("user", "pwd");
26         assertEquals("user", loginPassword.getUsername());
27
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);
32
33         verify(session).addPasswordIdentity("pwd");
34         verify(session).auth();
35     }
36 }