Jian Li | f8c2d4a | 2016-09-15 02:33:12 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.lisp.msg.authentication; |
| 17 | |
| 18 | import org.junit.Before; |
| 19 | import org.junit.Test; |
| 20 | |
| 21 | import static org.hamcrest.MatcherAssert.assertThat; |
| 22 | import static org.hamcrest.Matchers.is; |
| 23 | import static org.onosproject.lisp.msg.authentication.LispAuthenticationKeyEnum.*; |
| 24 | |
| 25 | /** |
| 26 | * Test case for LISP authentication. |
| 27 | */ |
| 28 | public 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 Li | afe2d3f | 2016-11-01 02:49:07 +0900 | [diff] [blame] | 41 | 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 Li | f8c2d4a | 2016-09-15 02:33:12 +0900 | [diff] [blame] | 45 | |
| 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 | } |