Chanhee Lee | 9401048 | 2017-01-23 23:06:18 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-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 | |
| 17 | package org.onosproject.security; |
| 18 | |
| 19 | import static org.junit.Assert.assertFalse; |
| 20 | import static org.junit.Assert.assertNotNull; |
| 21 | import static org.junit.Assert.assertNull; |
| 22 | |
| 23 | import org.junit.Before; |
| 24 | import org.junit.Test; |
| 25 | import org.onosproject.core.DefaultApplicationId; |
| 26 | |
| 27 | /** |
| 28 | * Test of SecurityUtil. |
| 29 | */ |
| 30 | public class SecurityUtilTest { |
| 31 | |
| 32 | private static SecurityAdminServiceAdapter service = new SecurityAdminServiceAdapter(); |
| 33 | private DefaultApplicationId appId; |
| 34 | |
| 35 | @Before |
| 36 | public void setUp() throws Exception { |
| 37 | appId = new DefaultApplicationId(1, "test"); |
| 38 | } |
| 39 | |
| 40 | @Test |
| 41 | public void testIsSecurityModeEnabled() { |
| 42 | assertNull(System.getSecurityManager()); |
| 43 | assertNotNull(service); |
| 44 | } |
| 45 | |
| 46 | @Test |
| 47 | public void testGetSecurityService() { |
| 48 | assertNull(System.getSecurityManager()); |
| 49 | assertNotNull(service); |
| 50 | } |
| 51 | |
| 52 | @Test |
| 53 | public void testIsAppSecured() { |
| 54 | assertFalse(service.isSecured(appId)); |
| 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void testRegister() { |
| 59 | service.register(appId); |
| 60 | } |
| 61 | |
| 62 | } |