Simon Hunt | 6ee94c8 | 2017-10-30 16:19:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2017-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 | */ |
| 16 | package org.opencord.aaa.api; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | import org.opencord.aaa.PrintableTest; |
| 20 | |
| 21 | import java.net.InetAddress; |
| 22 | |
| 23 | import static org.junit.Assert.assertEquals; |
| 24 | |
| 25 | /** |
| 26 | * Unit tests for {@link AaaConfig}. |
| 27 | */ |
| 28 | public class AaaConfigTest extends PrintableTest { |
| 29 | |
| 30 | private AaaConfig cfg; |
| 31 | |
| 32 | @Test |
| 33 | public void basic() { |
| 34 | cfg = new AaaConfig(); |
| 35 | print(cfg); |
| 36 | |
| 37 | InetAddress radAddr = cfg.radiusIp(); |
| 38 | print(radAddr); |
| 39 | assertEquals("wrong default radius addr", |
| 40 | AaaConfig.DEFAULT_RADIUS_IP, radAddr.getHostAddress()); |
| 41 | |
| 42 | InetAddress nasAddr = cfg.nasIp(); |
| 43 | print(nasAddr); |
| 44 | assertEquals("wrong default nas addr", |
| 45 | AaaConfig.DEFAULT_NAS_IP, nasAddr.getHostAddress()); |
| 46 | |
| 47 | String radMac = cfg.radiusMac(); |
| 48 | print(radMac); |
| 49 | assertEquals("wrong default radius mac", |
| 50 | AaaConfig.DEFAULT_RADIUS_MAC, radMac); |
| 51 | |
| 52 | String nasMac = cfg.nasMac(); |
| 53 | print(nasMac); |
| 54 | assertEquals("wrong default nas mac", |
| 55 | AaaConfig.DEFAULT_NAS_MAC, nasMac); |
| 56 | |
| 57 | String radSecret = cfg.radiusSecret(); |
| 58 | print(radSecret); |
| 59 | assertEquals("wrong default secret", |
| 60 | AaaConfig.DEFAULT_RADIUS_SECRET, radSecret); |
| 61 | |
| 62 | short radUdpPort = cfg.radiusServerUdpPort(); |
| 63 | print(radUdpPort); |
| 64 | short defaultPort = Short.valueOf(AaaConfig.DEFAULT_RADIUS_SERVER_PORT); |
| 65 | assertEquals("wrong default UDP port", defaultPort, radUdpPort); |
| 66 | |
| 67 | short vlanId = cfg.radiusServerVlanId(); |
| 68 | print(vlanId); |
| 69 | short defaultVlanId = Short.valueOf(AaaConfig.DEFAULT_RADIUS_VLAN_ID); |
| 70 | assertEquals("wrong default vlan id", defaultVlanId, vlanId); |
| 71 | |
| 72 | byte pBit = cfg.radiusServerPBit(); |
| 73 | print(pBit); |
| 74 | byte defaultPBit = Byte.valueOf(AaaConfig.DEFAULT_RADIUS_VLAN_PRIORITY_BIT); |
| 75 | assertEquals("wrong default priority bit", defaultPBit, pBit); |
| 76 | |
| 77 | String radConnType = cfg.radiusConnectionType(); |
| 78 | print(radConnType); |
| 79 | assertEquals("wrong default connection type", |
| 80 | AaaConfig.DEFAULT_RADIUS_CONNECTION_TYPE, radConnType); |
| 81 | } |
| 82 | } |