public void RadiusServer_Auth_Parallel_Delay() { // Verify that we can perform multiple parallel authentications with // a brief delay. RadiusServer server = new RadiusServer(); RadiusServerSettings serverSettings = new RadiusServerSettings(); RadiusClient client = new RadiusClient(); RadiusClientSettings clientSettings = new RadiusClientSettings(Local_RADIUS, "hello"); IAsyncResult[] ar = new IAsyncResult[255]; RadiusServerDeelie deelie; serverSettings.RealmFormat = RealmFormat.Slash; serverSettings.Devices.Add(new RadiusNasInfo(IPAddress.Loopback, "hello")); serverSettings.Devices.Add(new RadiusNasInfo(NetHelper.GetActiveAdapter(), "hello")); clientSettings.RealmFormat = RealmFormat.Slash; clientSettings.PortCount = 1; clientSettings.MaxTransmissions = 1; try { server.Start(serverSettings); server.LoadAccountsFromString(@" // This is a comment line r1;jeff;password123 r2;jeff;passwordXXX r1;jane;bigfish "); client.Open(clientSettings); deelie = new RadiusServerDeelie(server, RadiusServerDeelie.Mode.AuthShortDelay); for (int i = 0; i < ar.Length; i++) { ar[i] = client.BeginAuthenticate("r1", "jeff", "password123", null, null); } for (int i = 0; i < ar.Length; i++) { Assert.IsTrue(client.EndAuthenticate(ar[i])); } } finally { server.Stop(); client.Close(); } }
public void RadiusClient_Blast() { // Send a bunch of queries to multiple servers from multiple client ports. RadiusServer server1 = new RadiusServer(); RadiusServer server2 = new RadiusServer(); RadiusServerSettings server1Settings = new RadiusServerSettings(); RadiusServerSettings server2Settings = new RadiusServerSettings(); RadiusClient client = new RadiusClient(); RadiusClientSettings clientSettings = new RadiusClientSettings(new NetworkBinding[] { Local_RADIUS, Local_AAA }, "hello"); RadiusServerDeelie deelie1; RadiusServerDeelie deelie2; IAsyncResult[] ar; server1Settings.RealmFormat = RealmFormat.Email; server1Settings.Devices.Add(new RadiusNasInfo(IPAddress.Loopback, "hello")); server1Settings.Devices.Add(new RadiusNasInfo(NetHelper.GetActiveAdapter(), "hello")); server1Settings.NetworkBinding = new IPEndPoint(IPAddress.Any, NetworkPort.RADIUS); server2Settings.RealmFormat = RealmFormat.Email; server2Settings.Devices.Add(new RadiusNasInfo(IPAddress.Loopback, "hello")); server2Settings.Devices.Add(new RadiusNasInfo(NetHelper.GetActiveAdapter(), "hello")); server2Settings.NetworkBinding = new IPEndPoint(IPAddress.Any, NetworkPort.AAA); clientSettings.RealmFormat = RealmFormat.Email; clientSettings.PortCount = 4; clientSettings.MaxTransmissions = 3; try { string accountInfo = @" // This is a comment line r1;jeff;password123 r2;jeff;passwordXXX r1;jane;bigfish "; server1.Start(server1Settings); server1.LoadAccountsFromString(accountInfo); deelie1 = new RadiusServerDeelie(server1, RadiusServerDeelie.Mode.Normal); server2.Start(server2Settings); server2.LoadAccountsFromString(accountInfo); deelie2 = new RadiusServerDeelie(server2, RadiusServerDeelie.Mode.Normal); client.Open(clientSettings); ar = new IAsyncResult[clientSettings.PortCount * 256]; for (int i = 0; i < ar.Length; i++) { ar[i] = client.BeginAuthenticate("r1", "jeff", "password123", null, null); } for (int i = 0; i < ar.Length; i++) { Assert.IsTrue(client.EndAuthenticate(ar[i])); } Assert.IsTrue(deelie1.Packets.Count > 0); Assert.IsTrue(deelie2.Packets.Count > 0); } finally { server1.Stop(); server2.Stop(); client.Close(); } }
public void RadiusClient_ID_Exhaustion_MultiPort() { // Verify that the client throws an exception when it is asked to // manage more than 256 parallel authentication requests. RadiusServer server = new RadiusServer(); RadiusServerSettings serverSettings = new RadiusServerSettings(); RadiusClient client = new RadiusClient(); RadiusClientSettings clientSettings = new RadiusClientSettings(Local_RADIUS, "hello"); RadiusServerDeelie deelie; IAsyncResult[] ar; serverSettings.RealmFormat = RealmFormat.Email; serverSettings.Devices.Add(new RadiusNasInfo(IPAddress.Loopback, "hello")); serverSettings.Devices.Add(new RadiusNasInfo(NetHelper.GetActiveAdapter(), "hello")); clientSettings.RealmFormat = RealmFormat.Email; clientSettings.PortCount = 2; clientSettings.MaxTransmissions = 1; try { server.Start(serverSettings); server.LoadAccountsFromString(@" // This is a comment line r1;jeff;password123 r2;jeff;passwordXXX r1;jane;bigfish "); client.Open(clientSettings); deelie = new RadiusServerDeelie(server, RadiusServerDeelie.Mode.AuthLongDelay); ar = new IAsyncResult[clientSettings.PortCount * 256 + 1]; try { for (int i = 0; i < ar.Length; i++) { ar[i] = client.BeginAuthenticate("r1", "jeff", "password123", null, null); } for (int i = 0; i < ar.Length; i++) { if (ar[i] != null) { client.EndAuthenticate(ar[i]); } } Assert.Fail("Expected a RadiusException"); } catch (Exception e) { Assert.IsInstanceOfType(e, typeof(RadiusException)); } } finally { server.Stop(); client.Close(); } }