blob: be923c0c40b51bf7aea87b2983369c30b9ee9166 [file] [log] [blame]
Daniel Parkdeefa702018-07-17 17:55:51 +09001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Jian Li2a2d26c2018-10-08 11:29:31 +090016package org.onosproject.openstacknode.api;
Daniel Parkdeefa702018-07-17 17:55:51 +090017
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
Daniel Parkdeefa702018-07-17 17:55:51 +090020
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.is;
23
24/**
25 * Unit tests for DefaultOpenstackSshAuth.
26 */
27public class DefaultOpenstackSshAuthTest {
28
29 private static final String ID_1 = "sdn1";
30 private static final String ID_2 = "sdn2";
31 private static final String PASSWORD_1 = "password1";
32 private static final String PASSWORD_2 = "password2";
33
34 private static final OpenstackSshAuth OS_SSH_AUTH_1 =
35 createOpenstackSshAuth(ID_1, PASSWORD_1);
36 private static final OpenstackSshAuth OS_SSH_AUTH_2 =
37 createOpenstackSshAuth(ID_2, PASSWORD_2);
38 private static final OpenstackSshAuth OS_SSH_AUTH_3 =
39 createOpenstackSshAuth(ID_1, PASSWORD_1);
40
41
42 private static OpenstackSshAuth createOpenstackSshAuth(String id, String password) {
43 return DefaultOpenstackSshAuth.builder()
44 .id(id)
45 .password(password)
46 .build();
47 }
48
49 @Test
50 public void testEquality() {
51 new EqualsTester().addEqualityGroup(OS_SSH_AUTH_1, OS_SSH_AUTH_3)
52 .addEqualityGroup(OS_SSH_AUTH_2)
53 .testEquals();
54 }
55
56 @Test
57 public void testConstruction() {
58 OpenstackSshAuth auth = OS_SSH_AUTH_1;
59
60 assertThat(auth.id(), is("sdn1"));
61 assertThat(auth.password(), is("password1"));
62 }
63}