public void TestCreateStatusServerRequestPacket() { var expected = "0cda00268a54f4686fb394c52866e302185d062350125a665e2e1e8411f3e243822097c84fa3"; var secret = "xyzzy5461"; var packet = new RadiusPacket(PacketCode.StatusServer, 218, secret); packet.Authenticator = Utils.StringToByteArray("8a54f4686fb394c52866e302185d0623"); Assert.AreEqual(expected, packet.GetBytes(GetDictionary()).ToHexString()); }
public void TestCreateDisconnectRequestPacket() { var expected = "2801001e2ec8a0da729620319be0140bc28e92682c0a3039303432414638"; var secret = "xyzzy5461"; var packet = new RadiusPacket(PacketCode.DisconnectRequest, 1, secret); packet.AddAttribute("Acct-Session-Id", "09042AF8"); Assert.AreEqual(expected, packet.GetBytes(GetDictionary()).ToHexString()); }
public void TestCreateCoARequestPacket() { var expected = "2b0000266613591d86e32fa6dbae94f13772573601066e656d6f0406c0a80110050600000003"; var secret = "xyzzy5461"; var packet = new RadiusPacket(PacketCode.CoaRequest, 0, secret); packet.Authenticator = Utils.StringToByteArray("0f403f9473978057bd83d5cb98f4227a"); packet.AddAttribute("User-Name", "nemo"); packet.AddAttribute("NAS-IP-Address", IPAddress.Parse("192.168.1.16")); packet.AddAttribute("NAS-Port", 3); Assert.AreEqual(expected, packet.GetBytes(GetDictionary()).ToHexString()); }
public void TestCreateAndParseAccountingRequestPacket() { var secret = "xyzzy5461"; var dictionary = GetDictionary(); var packet = new RadiusPacket(PacketCode.AccountingRequest, 0, secret); packet.AddAttribute("User-Name", "nemo"); packet.AddAttribute("Acct-Status-Type", 2); packet.AddAttribute("NAS-IP-Address", IPAddress.Parse("192.168.1.16")); packet.AddAttribute("NAS-Port", 3); var bytes = packet.GetBytes(dictionary); var derp = RadiusPacket.Parse(bytes, dictionary, Encoding.UTF8.GetBytes(secret)); }
public void TestCreateAccessRequestPacket() { var expected = "010000380f403f9473978057bd83d5cb98f4227a01066e656d6f02120dbe708d93d413ce3196e43f782a0aee0406c0a80110050600000003"; var secret = "xyzzy5461"; var packet = new RadiusPacket(PacketCode.AccessRequest, 0, secret); packet.Authenticator = Utils.StringToByteArray("0f403f9473978057bd83d5cb98f4227a"); packet.AddAttribute("User-Name", "nemo"); packet.AddAttribute("User-Password", "arctangent"); packet.AddAttribute("NAS-IP-Address", IPAddress.Parse("192.168.1.16")); packet.AddAttribute("NAS-Port", 3); Assert.AreEqual(expected, packet.GetBytes(GetDictionary()).ToHexString()); }
public void TestCreateAccessRequestPacketUnknownAttribute() { var secret = "xyzzy5461"; var packet = new RadiusPacket(PacketCode.AccessRequest, 0, secret); packet.Authenticator = Utils.StringToByteArray("0f403f9473978057bd83d5cb98f4227a"); packet.AddAttribute("User-Name", "nemo"); packet.AddAttribute("hurr", "durr"); packet.AddAttribute("User-Password", "arctangent"); packet.AddAttribute("NAS-IP-Address", IPAddress.Parse("192.168.1.16")); packet.AddAttribute("NAS-Port", 3); Assert.That(() => packet.GetBytes(GetDictionary()), Throws.TypeOf <InvalidOperationException>()); }
public void TestCreatingAndParsingPacket() { var secret = "xyzzy5461"; var dictionary = GetDictionary(); var packet = new RadiusPacket(PacketCode.AccessRequest, 1, secret); packet.AddAttribute("User-Name", "*****@*****.**"); packet.AddAttribute("User-Password", "test"); packet.AddAttribute("NAS-IP-Address", IPAddress.Parse("127.0.0.1")); packet.AddAttribute("NAS-Port", 100); packet.AddAttribute("3GPP-IMSI-MCC-MNC", "24001"); packet.AddAttribute("3GPP-CG-Address", IPAddress.Parse("127.0.0.1")); var testPacket = RadiusPacket.Parse(packet.GetBytes(dictionary), dictionary, Encoding.UTF8.GetBytes(secret)); Assert.AreEqual("*****@*****.**", testPacket.GetAttribute <String>("User-Name")); Assert.AreEqual("test", testPacket.GetAttribute <String>("User-Password")); Assert.AreEqual(IPAddress.Parse("127.0.0.1"), testPacket.GetAttribute <IPAddress>("NAS-IP-Address")); Assert.AreEqual(100, testPacket.GetAttribute <UInt32>("NAS-Port")); Assert.AreEqual("24001", testPacket.GetAttribute <String>("3GPP-IMSI-MCC-MNC")); Assert.AreEqual(IPAddress.Parse("127.0.0.1"), testPacket.GetAttribute <IPAddress>("3GPP-CG-Address")); }