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 | */ |
alshabib | 6d52745 | 2016-06-01 18:00:47 -0700 | [diff] [blame] | 16 | package org.opencord.aaa; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 18 | import com.google.common.base.Charsets; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 19 | import org.junit.After; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame^] | 22 | import org.onlab.junit.TestUtils; |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 23 | import org.onlab.packet.BasePacket; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 24 | import org.onlab.packet.DeserializationException; |
| 25 | import org.onlab.packet.EAP; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 26 | import org.onlab.packet.Ethernet; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 27 | import org.onlab.packet.IpAddress; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 28 | import org.onlab.packet.RADIUS; |
| 29 | import org.onlab.packet.RADIUSAttribute; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 30 | import org.onosproject.core.CoreServiceAdapter; |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame^] | 31 | import org.onosproject.event.DefaultEventSinkRegistry; |
| 32 | import org.onosproject.event.Event; |
| 33 | import org.onosproject.event.EventDeliveryService; |
| 34 | import org.onosproject.event.EventSink; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 35 | import org.onosproject.net.config.Config; |
| 36 | import org.onosproject.net.config.NetworkConfigRegistryAdapter; |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 37 | import org.onosproject.net.packet.InboundPacket; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 38 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame^] | 39 | import java.lang.reflect.Field; |
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; |
| 46 | import static org.junit.Assert.assertThat; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Set of tests of the ONOS application component. |
| 50 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 51 | public class AaaManagerTest extends AaaTestBase { |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 52 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 53 | static final String BAD_IP_ADDRESS = "198.51.100.0"; |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 54 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 55 | private AaaManager aaaManager; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 56 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 57 | class AaaManagerWithoutRadiusServer extends AaaManager { |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 58 | protected void sendRadiusPacket(RADIUS radiusPacket, InboundPacket inPkt) { |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 59 | savePacket(radiusPacket); |
| 60 | } |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | /** |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 64 | * Mocks the AAAConfig class to force usage of an unroutable address for the |
| 65 | * RADIUS server. |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 66 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 67 | static class MockAaaConfig extends AaaConfig { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 68 | @Override |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 69 | public InetAddress radiusIp() { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 70 | try { |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 71 | return InetAddress.getByName(BAD_IP_ADDRESS); |
| 72 | } catch (UnknownHostException ex) { |
| 73 | // can't happen |
| 74 | throw new IllegalStateException(ex); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | /** |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 80 | * Mocks the network config registry. |
| 81 | */ |
| 82 | @SuppressWarnings("unchecked") |
| 83 | private static final class TestNetworkConfigRegistry |
| 84 | extends NetworkConfigRegistryAdapter { |
| 85 | @Override |
| 86 | 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] | 87 | AaaConfig aaaConfig = new MockAaaConfig(); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 88 | return (C) aaaConfig; |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame^] | 92 | public static class TestEventDispatcher extends DefaultEventSinkRegistry |
| 93 | implements EventDeliveryService { |
| 94 | |
| 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 | * Constructs an Ethernet packet containing a RADIUS challenge |
| 115 | * packet. |
| 116 | * |
| 117 | * @param challengeCode code to use in challenge packet |
| 118 | * @param challengeType type to use in challenge packet |
| 119 | * @return Ethernet packet |
| 120 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 121 | private RADIUS constructRadiusCodeAccessChallengePacket(byte challengeCode, byte challengeType) { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 122 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 123 | String challenge = "12345678901234567"; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 124 | |
| 125 | EAP eap = new EAP(challengeType, (byte) 1, challengeType, |
| 126 | challenge.getBytes(Charsets.US_ASCII)); |
| 127 | eap.setIdentifier((byte) 1); |
| 128 | |
| 129 | RADIUS radius = new RADIUS(); |
| 130 | radius.setCode(challengeCode); |
| 131 | |
| 132 | radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_STATE, |
| 133 | challenge.getBytes(Charsets.US_ASCII)); |
| 134 | |
| 135 | radius.setPayload(eap); |
| 136 | radius.setAttribute(RADIUSAttribute.RADIUS_ATTR_EAP_MESSAGE, |
| 137 | eap.serialize()); |
| 138 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 139 | return radius; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame^] | 142 | public static void injectEventDispatcher(Object manager, EventDeliveryService svc) { |
| 143 | Class mc = manager.getClass(); |
| 144 | for (Field f : mc.getSuperclass().getDeclaredFields()) { |
| 145 | if (f.getType().equals(EventDeliveryService.class)) { |
| 146 | try { |
| 147 | TestUtils.setField(manager, f.getName(), svc); |
| 148 | } catch (TestUtils.TestUtilsException e) { |
| 149 | throw new IllegalArgumentException("Unable to inject reference", e); |
| 150 | } |
| 151 | break; |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 156 | /** |
| 157 | * Sets up the services required by the AAA application. |
| 158 | */ |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 159 | @Before |
| 160 | public void setUp() { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 161 | aaaManager = new AaaManagerWithoutRadiusServer(); |
| 162 | aaaManager.netCfgService = new TestNetworkConfigRegistry(); |
| 163 | aaaManager.coreService = new CoreServiceAdapter(); |
| 164 | aaaManager.packetService = new MockPacketService(); |
Amit Ghosh | f739be5 | 2017-09-21 15:49:37 +0100 | [diff] [blame] | 165 | aaaManager.deviceService = new TestDeviceService(); |
| 166 | aaaManager.subsService = new MockSubService(); |
Jonathan Hart | 5db4453 | 2018-07-12 18:13:54 -0700 | [diff] [blame^] | 167 | TestUtils.setField(aaaManager, "eventDispatcher", new TestEventDispatcher()); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 168 | aaaManager.activate(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 171 | /** |
| 172 | * Tears down the AAA application. |
| 173 | */ |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 174 | @After |
| 175 | public void tearDown() { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 176 | aaaManager.deactivate(); |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 179 | /** |
| 180 | * Extracts the RADIUS packet from a packet sent by the supplicant. |
| 181 | * |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 182 | * @param radius RADIUS packet sent by the supplicant |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 183 | * @throws DeserializationException if deserialization of the packet contents |
| 184 | * fails. |
| 185 | */ |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 186 | private void checkRadiusPacketFromSupplicant(RADIUS radius) |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 187 | throws DeserializationException { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 188 | assertThat(radius, notNullValue()); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 189 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 190 | EAP eap = radius.decapsulateMessage(); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 191 | assertThat(eap, notNullValue()); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | /** |
| 195 | * Fetches the sent packet at the given index. The requested packet |
| 196 | * must be the last packet on the list. |
| 197 | * |
| 198 | * @param index index into sent packets array |
| 199 | * @return packet |
| 200 | */ |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 201 | private BasePacket fetchPacket(int index) { |
| 202 | BasePacket packet = savedPackets.get(index); |
| 203 | assertThat(packet, notNullValue()); |
| 204 | return packet; |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Tests the authentication path through the AAA application. |
| 209 | * |
| 210 | * @throws DeserializationException if packed deserialization fails. |
| 211 | */ |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 212 | @Test |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 213 | public void testAuthentication() throws Exception { |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 214 | |
| 215 | // (1) Supplicant start up |
| 216 | |
| 217 | Ethernet startPacket = constructSupplicantStartPacket(); |
| 218 | sendPacket(startPacket); |
| 219 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 220 | Ethernet responsePacket = (Ethernet) fetchPacket(0); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 221 | checkRadiusPacket(aaaManager, responsePacket, EAP.ATTR_IDENTITY); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 222 | |
| 223 | // (2) Supplicant identify |
| 224 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 225 | Ethernet identifyPacket = constructSupplicantIdentifyPacket(null, EAP.ATTR_IDENTITY, (byte) 1, null); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 226 | sendPacket(identifyPacket); |
| 227 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 228 | RADIUS radiusIdentifyPacket = (RADIUS) fetchPacket(1); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 229 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 230 | checkRadiusPacketFromSupplicant(radiusIdentifyPacket); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 231 | |
| 232 | assertThat(radiusIdentifyPacket.getCode(), is(RADIUS.RADIUS_CODE_ACCESS_REQUEST)); |
| 233 | assertThat(new String(radiusIdentifyPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_USERNAME).getValue()), |
| 234 | is("testuser")); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 235 | |
| 236 | IpAddress nasIp = |
| 237 | IpAddress.valueOf(IpAddress.Version.INET, |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 238 | radiusIdentifyPacket.getAttribute(RADIUSAttribute.RADIUS_ATTR_NAS_IP) |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 239 | .getValue()); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 240 | assertThat(nasIp.toString(), is(aaaManager.nasIpAddress.getHostAddress())); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 241 | |
| 242 | // State machine should have been created by now |
| 243 | |
| 244 | StateMachine stateMachine = |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 245 | StateMachine.lookupStateMachineBySessionId(SESSION_ID); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 246 | assertThat(stateMachine, notNullValue()); |
| 247 | assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING)); |
| 248 | |
| 249 | // (3) RADIUS MD5 challenge |
| 250 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 251 | RADIUS radiusCodeAccessChallengePacket = |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 252 | constructRadiusCodeAccessChallengePacket(RADIUS.RADIUS_CODE_ACCESS_CHALLENGE, EAP.ATTR_MD5); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 253 | aaaManager.handleRadiusPacket(radiusCodeAccessChallengePacket); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 254 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 255 | Ethernet radiusChallengeMD5Packet = (Ethernet) fetchPacket(2); |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 256 | checkRadiusPacket(aaaManager, radiusChallengeMD5Packet, EAP.ATTR_MD5); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 257 | |
| 258 | // (4) Supplicant MD5 response |
| 259 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 260 | Ethernet md5RadiusPacket = |
| 261 | constructSupplicantIdentifyPacket(stateMachine, |
| 262 | EAP.ATTR_MD5, |
| 263 | stateMachine.challengeIdentifier(), |
| 264 | radiusChallengeMD5Packet); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 265 | sendPacket(md5RadiusPacket); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 266 | |
| 267 | RADIUS responseMd5RadiusPacket = (RADIUS) fetchPacket(3); |
| 268 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 269 | checkRadiusPacketFromSupplicant(responseMd5RadiusPacket); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 270 | assertThat(responseMd5RadiusPacket.getIdentifier(), is((byte) 3)); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 271 | assertThat(responseMd5RadiusPacket.getCode(), is(RADIUS.RADIUS_CODE_ACCESS_REQUEST)); |
| 272 | |
| 273 | // State machine should be in pending state |
| 274 | |
| 275 | assertThat(stateMachine, notNullValue()); |
| 276 | assertThat(stateMachine.state(), is(StateMachine.STATE_PENDING)); |
| 277 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 278 | // (5) RADIUS Success |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 279 | |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 280 | RADIUS successPacket = |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 281 | constructRadiusCodeAccessChallengePacket(RADIUS.RADIUS_CODE_ACCESS_ACCEPT, EAP.SUCCESS); |
Amit Ghosh | c9ac1e5 | 2017-07-28 12:31:18 +0100 | [diff] [blame] | 282 | aaaManager.handleRadiusPacket((successPacket)); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 283 | Ethernet supplicantSuccessPacket = (Ethernet) fetchPacket(4); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 284 | |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 285 | checkRadiusPacket(aaaManager, supplicantSuccessPacket, EAP.SUCCESS); |
Ray Milkey | ea36645 | 2015-09-30 10:56:43 -0700 | [diff] [blame] | 286 | |
| 287 | // State machine should be in authorized state |
| 288 | |
| 289 | assertThat(stateMachine, notNullValue()); |
| 290 | assertThat(stateMachine.state(), is(StateMachine.STATE_AUTHORIZED)); |
Ray Milkey | 967776a | 2015-10-07 14:37:17 -0700 | [diff] [blame] | 291 | |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 292 | } |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 293 | |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 294 | /** |
| 295 | * Tests the default configuration. |
| 296 | */ |
| 297 | @Test |
| 298 | public void testConfig() { |
Jonathan Hart | 092dfb2 | 2015-11-16 23:05:21 -0800 | [diff] [blame] | 299 | assertThat(aaaManager.nasIpAddress.getHostAddress(), is(AaaConfig.DEFAULT_NAS_IP)); |
| 300 | assertThat(aaaManager.nasMacAddress, is(AaaConfig.DEFAULT_NAS_MAC)); |
| 301 | assertThat(aaaManager.radiusIpAddress.getHostAddress(), is(BAD_IP_ADDRESS)); |
| 302 | assertThat(aaaManager.radiusMacAddress, is(AaaConfig.DEFAULT_RADIUS_MAC)); |
Ray Milkey | fcb623d | 2015-10-01 16:48:18 -0700 | [diff] [blame] | 303 | } |
Ari Saha | 8983174 | 2015-06-26 10:31:48 -0700 | [diff] [blame] | 304 | } |