Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 4e33be2 | 2017-08-03 22:45:46 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 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 | */ |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 16 | package org.opencord.aaa.impl; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 17 | |
| 18 | import org.junit.After; |
| 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 21 | import org.onlab.junit.TestUtils; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 22 | import org.onlab.packet.BasePacket; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 23 | import org.onlab.packet.DeserializationException; |
| 24 | import org.onlab.packet.EAP; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 25 | import org.onlab.packet.Ethernet; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 26 | import org.onlab.packet.IpAddress; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 27 | import org.onlab.packet.RADIUS; |
| 28 | import org.onlab.packet.RADIUSAttribute; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 29 | import org.onosproject.core.CoreServiceAdapter; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 30 | import org.onosproject.event.DefaultEventSinkRegistry; |
| 31 | import org.onosproject.event.Event; |
| 32 | import org.onosproject.event.EventDeliveryService; |
| 33 | import org.onosproject.event.EventSink; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 34 | import org.onosproject.net.config.Config; |
| 35 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 36 | import org.onosproject.net.packet.InboundPacket; |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 37 | import org.onosproject.store.service.TestStorageService; |
Matteo Scandolo | cf847b8 | 2019-04-26 15:00:00 -0700 | [diff] [blame] | 38 | import org.opencord.aaa.AaaConfig; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 39 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 40 | import java.net.InetAddress; |
| 41 | import java.net.UnknownHostException; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 42 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 43 | import static com.google.common.base.Preconditions.checkState; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 44 | import static org.hamcrest.Matchers.is; |
| 45 | import static org.hamcrest.Matchers.notNullValue; |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 46 | import static org.hamcrest.Matchers.nullValue; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 47 | import static org.junit.Assert.assertThat; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Set of tests of the ONOS application component. |
| 51 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 52 | public class AaaManagerTest extends AaaTestBase { |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 53 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 54 | static final String BAD_IP_ADDRESS = "198.51.100.0"; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 55 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 56 | private AaaManager aaaManager; |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 57 | private AaaStatisticsManager aaaStatisticsManager; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 58 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 59 | class AaaManagerWithoutRadiusServer extends AaaManager { |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 60 | protected void sendRadiusPacket(RADIUS radiusPacket, InboundPacket inPkt) { |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 61 | savePacket(radiusPacket); |
| 62 | } |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 63 | } |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 64 | /** |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 65 | * Mocks the AAAConfig class to force usage of an unroutable address for the |
| 66 | * RADIUS server. |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 67 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 68 | static class MockAaaConfig extends AaaConfig { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 69 | @Override |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 70 | public InetAddress radiusIp() { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 71 | try { |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 72 | return InetAddress.getByName(BAD_IP_ADDRESS); |
| 73 | } catch (UnknownHostException ex) { |
| 74 | // can't happen |
| 75 | throw new IllegalStateException(ex); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /** |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 81 | * Mocks the network config registry. |
| 82 | */ |
| 83 | @SuppressWarnings("unchecked") |
| 84 | private static final class TestNetworkConfigRegistry |
| 85 | extends NetworkConfigRegistryAdapter { |
| 86 | @Override |
| 87 | public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 88 | AaaConfig aaaConfig = new MockAaaConfig(); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 89 | return (C) aaaConfig; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 93 | public static class TestEventDispatcher extends DefaultEventSinkRegistry |
| 94 | implements EventDeliveryService { |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 95 | @Override |
| 96 | @SuppressWarnings("unchecked") |
| 97 | public synchronized void post(Event event) { |
| 98 | EventSink sink = getSink(event.getClass()); |
| 99 | checkState(sink != null, "No sink for event %s", event); |
| 100 | sink.process(event); |
| 101 | } |
| 102 | |
| 103 | @Override |
| 104 | public void setDispatchTimeLimit(long millis) { |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public long getDispatchTimeLimit() { |
| 109 | return 0; |
| 110 | } |
| 111 | } |
| 112 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 113 | /** |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 114 | * Sets up the services required by the AAA application. |
| 115 | */ |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 116 | @Before |
| 117 | public void setUp() { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 118 | aaaManager = new AaaManagerWithoutRadiusServer(); |
| 119 | aaaManager.netCfgService = new TestNetworkConfigRegistry(); |
| 120 | aaaManager.coreService = new CoreServiceAdapter(); |
| 121 | aaaManager.packetService = new MockPacketService(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 122 | aaaManager.deviceService = new TestDeviceService(); |
Gamze Abaka | 1cfdb19 | 2018-10-25 11:39:19 +0000 | [diff] [blame] | 123 | aaaManager.sadisService = new MockSadisService(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 124 | aaaManager.cfgService = new MockCfgService(); |
Jonathan Hart | 9d1ce80 | 2020-01-28 10:45:08 -0800 | [diff] [blame] | 125 | aaaManager.storageService = new TestStorageService(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 126 | aaaStatisticsManager = new AaaStatisticsManager(); |
Shubham Sharma | 4900ce6 | 2019-06-19 14:18:50 +0000 | [diff] [blame] | 127 | aaaManager.radiusOperationalStatusService = new RadiusOperationalStatusManager(); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 128 | TestUtils.setField(aaaStatisticsManager, "eventDispatcher", new TestEventDispatcher()); |
| 129 | aaaStatisticsManager.activate(); |
| 130 | aaaManager.aaaStatisticsManager = this.aaaStatisticsManager; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame] | 131 | TestUtils.setField(aaaManager, "eventDispatcher", new TestEventDispatcher()); |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 132 | aaaManager.activate(new AaaTestBase.MockComponentContext()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 135 | /** |
| 136 | * Tears down the AAA application. |
| 137 | */ |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 138 | @After |
| 139 | public void tearDown() { |
kartikey dubey | e154542 | 2019-05-22 12:53:45 +0000 | [diff] [blame] | 140 | aaaManager.deactivate(new AaaTestBase.MockComponentContext()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 143 | /** |
| 144 | * Extracts the RADIUS packet from a packet sent by the supplicant. |
| 145 | * |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 146 | * @param radius RADIUS packet sent by the supplicant |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 147 | * @throws DeserializationException if deserialization of the packet contents |
| 148 | * fails. |
| 149 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 150 | private void checkRadiusPacketFromSupplicant(RADIUS radius) |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 151 | throws DeserializationException { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 152 | assertThat(radius, notNullValue()); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 153 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 154 | EAP eap = radius.decapsulateMessage(); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 155 | assertThat(eap, notNullValue()); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Fetches the sent packet at the given index. The requested packet |
| 160 | * must be the last packet on the list. |
| 161 | * |
| 162 | * @param index index into sent packets array |
| 163 | * @return packet |
| 164 | */ |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 165 | private BasePacket fetchPacket(int index) { |
| 166 | BasePacket packet = savedPackets.get(index); |
| 167 | assertThat(packet, notNullValue()); |
| 168 | return packet; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Tests the authentication path through the AAA application. |
| 173 | * |
| 174 | * @throws DeserializationException if packed deserialization fails. |
| 175 | */ |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 176 | @Test |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 177 | public void testAuthentication() throws Exception { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 178 | |
| 179 | // (1) Supplicant start up |
| 180 | |
| 181 | Ethernet startPacket = constructSupplicantStartPacket(); |
| 182 | sendPacket(startPacket); |
| 183 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 184 | Ethernet responsePacket = (Ethernet) fetchPacket(0); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 185 | checkRadiusPacket(aaaManager, responsePacket, EAP.ATTR_IDENTITY); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 186 | |
| 187 | // (2) Supplicant identify |
| 188 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 189 | Ethernet identifyPacket = constructSupplicantIdentifyPacket(null, |
| 190 | EAP.ATTR_IDENTITY, (byte) 3, null); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 191 | sendPacket(identifyPacket); |
| 192 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 193 | RADIUS radiusIdentifyPacket = (RADIUS) fetchPacket(1); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 194 | byte reqId = radiusIdentifyPacket.getIdentifier(); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 195 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 196 | checkRadiusPacketFromSupplicant(radiusIdentifyPacket); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 197 | |
| 198 | assertThat(radiusIdentifyPacket.getCode(), is(RADIUS.RADIUS_CODE_ACCESS_REQUEST)); |
| 199 | assertThat(new String(radiusIdentifyPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_USERNAME).getValue()), |
| 200 | is("testuser")); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 201 | |
| 202 | IpAddress nasIp = |
| 203 | IpAddress.valueOf(IpAddress.Version.INET, |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 204 | radiusIdentifyPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_NAS_IP) |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 205 | .getValue()); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 206 | assertThat(nasIp.toString(), is(aaaManager.nasIpAddress.getHostAddress())); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 207 | |
| 208 | // State machine should have been created by now |
| 209 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 210 | StateMachine stateMachine = aaaManager.getStateMachine(SESSION_ID); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 211 | assertThat(stateMachine, notNullValue()); |
| 212 | assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING)); |
| 213 | |
| 214 | // (3) RADIUS MD5 challenge |
| 215 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 216 | RADIUS radiusCodeAccessChallengePacket = |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 217 | constructRadiusCodeAccessChallengePacket(RADIUS.RADIUS_CODE_ACCESS_CHALLENGE, EAP.ATTR_MD5, |
| 218 | reqId, aaaManager.radiusSecret.getBytes()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 219 | aaaManager.handleRadiusPacket(radiusCodeAccessChallengePacket); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 220 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 221 | Ethernet radiusChallengeMD5Packet = (Ethernet) fetchPacket(2); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 222 | checkRadiusPacket(aaaManager, radiusChallengeMD5Packet, EAP.ATTR_MD5); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 223 | |
| 224 | // (4) Supplicant MD5 response |
| 225 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 226 | Ethernet md5RadiusPacket = |
| 227 | constructSupplicantIdentifyPacket(stateMachine, |
| 228 | EAP.ATTR_MD5, |
| 229 | stateMachine.challengeIdentifier(), |
| 230 | radiusChallengeMD5Packet); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 231 | sendPacket(md5RadiusPacket); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 232 | |
| 233 | RADIUS responseMd5RadiusPacket = (RADIUS) fetchPacket(3); |
| 234 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 235 | checkRadiusPacketFromSupplicant(responseMd5RadiusPacket); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 236 | //assertThat(responseMd5RadiusPacket.getIdentifier(), is((byte) 9)); |
| 237 | reqId = responseMd5RadiusPacket.getIdentifier(); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 238 | assertThat(responseMd5RadiusPacket.getCode(), is(RADIUS.RADIUS_CODE_ACCESS_REQUEST)); |
| 239 | |
| 240 | // State machine should be in pending state |
| 241 | |
| 242 | assertThat(stateMachine, notNullValue()); |
| 243 | assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING)); |
| 244 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 245 | // (5) RADIUS Success |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 246 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 247 | RADIUS successPacket = |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 248 | constructRadiusCodeAccessChallengePacket(RADIUS.RADIUS_CODE_ACCESS_ACCEPT, |
| 249 | EAP.SUCCESS, reqId, aaaManager.radiusSecret.getBytes()); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 250 | aaaManager.handleRadiusPacket((successPacket)); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 251 | Ethernet supplicantSuccessPacket = (Ethernet) fetchPacket(4); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 252 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 253 | checkRadiusPacket(aaaManager, supplicantSuccessPacket, EAP.SUCCESS); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 254 | |
| 255 | // State machine should be in authorized state |
| 256 | |
| 257 | assertThat(stateMachine, notNullValue()); |
| 258 | assertThat(stateMachine.state(), is(StateMachine.STATE_AUTHORIZED)); |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 259 | } |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 260 | |
Jonathan Hart | 612651f | 2019-11-25 09:21:43 -0800 | [diff] [blame] | 261 | @Test |
| 262 | public void testRemoveAuthentication() { |
| 263 | Ethernet startPacket = constructSupplicantStartPacket(); |
| 264 | sendPacket(startPacket); |
| 265 | |
| 266 | StateMachine stateMachine = aaaManager.getStateMachine(SESSION_ID); |
| 267 | |
| 268 | assertThat(stateMachine, notNullValue()); |
| 269 | assertThat(stateMachine.state(), is(StateMachine.STATE_STARTED)); |
| 270 | |
| 271 | aaaManager.removeAuthenticationStateByMac(stateMachine.supplicantAddress()); |
| 272 | |
| 273 | assertThat(aaaManager.getStateMachine(SESSION_ID), nullValue()); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 274 | } |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 275 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 276 | /** |
| 277 | * Tests the default configuration. |
| 278 | */ |
| 279 | @Test |
| 280 | public void testConfig() { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 281 | assertThat(aaaManager.nasIpAddress.getHostAddress(), is(AaaConfig.DEFAULT_NAS_IP)); |
| 282 | assertThat(aaaManager.nasMacAddress, is(AaaConfig.DEFAULT_NAS_MAC)); |
| 283 | assertThat(aaaManager.radiusIpAddress.getHostAddress(), is(BAD_IP_ADDRESS)); |
| 284 | assertThat(aaaManager.radiusMacAddress, is(AaaConfig.DEFAULT_RADIUS_MAC)); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 285 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 286 | } |