blob: 2e994b62e9ef8acf256c5e84800728891b97efb0 [file] [log] [blame]
Jian Lif8c2d4a2016-09-15 02:33:12 +09001/*
2 * Copyright 2016-present Open Networking Laboratory
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.lisp.msg.authentication;
17
18import org.junit.Before;
19import org.junit.Test;
20
21import static org.hamcrest.MatcherAssert.assertThat;
22import static org.hamcrest.Matchers.is;
23import static org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum.*;
24
25/**
26 * Test case for LISP authentication.
27 */
28public class LispAuthenticationTest {
29
30 private LispAuthenticationFactory factory;
31
32 @Before
33 public void setup() {
34 factory = LispAuthenticationFactory.getInstance();
35 }
36
37 @Test
38 public void testAuthData() {
39
40 String authKey = "testKey";
Jian Liafe2d3f2016-11-01 02:49:07 +090041 byte[] noneAuthData = factory.createAuthenticationData(NONE, authKey, new byte[0]);
42 byte[] unknownAuthData = factory.createAuthenticationData(UNKNOWN, authKey, new byte[0]);
43 byte[] sha1AuthData = factory.createAuthenticationData(SHA1, authKey, new byte[0]);
44 byte[] sha256AuthData = factory.createAuthenticationData(SHA256, authKey, new byte[0]);
Jian Lif8c2d4a2016-09-15 02:33:12 +090045
46 assertThat(noneAuthData, is(new byte[0]));
47 assertThat(unknownAuthData, is(new byte[0]));
48 assertThat(sha1AuthData.length, is(20));
49 assertThat(sha256AuthData.length, is(32));
50 }
51}