blob: bdba45c0c3ae45acc30cd9e63ba21ea2cee8dba9 [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 */
16package org.onosproject.openstacknode.impl;
17
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
20import org.onosproject.openstacknode.api.OpenstackSshAuth;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.is;
24
25/**
26 * Unit tests for DefaultOpenstackSshAuth.
27 */
28public class DefaultOpenstackSshAuthTest {
29
30 private static final String ID_1 = "sdn1";
31 private static final String ID_2 = "sdn2";
32 private static final String PASSWORD_1 = "password1";
33 private static final String PASSWORD_2 = "password2";
34
35 private static final OpenstackSshAuth OS_SSH_AUTH_1 =
36 createOpenstackSshAuth(ID_1, PASSWORD_1);
37 private static final OpenstackSshAuth OS_SSH_AUTH_2 =
38 createOpenstackSshAuth(ID_2, PASSWORD_2);
39 private static final OpenstackSshAuth OS_SSH_AUTH_3 =
40 createOpenstackSshAuth(ID_1, PASSWORD_1);
41
42
43 private static OpenstackSshAuth createOpenstackSshAuth(String id, String password) {
44 return DefaultOpenstackSshAuth.builder()
45 .id(id)
46 .password(password)
47 .build();
48 }
49
50 @Test
51 public void testEquality() {
52 new EqualsTester().addEqualityGroup(OS_SSH_AUTH_1, OS_SSH_AUTH_3)
53 .addEqualityGroup(OS_SSH_AUTH_2)
54 .testEquals();
55 }
56
57 @Test
58 public void testConstruction() {
59 OpenstackSshAuth auth = OS_SSH_AUTH_1;
60
61 assertThat(auth.id(), is("sdn1"));
62 assertThat(auth.password(), is("password1"));
63 }
64}