QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142) getrackt, ohne .gitmodules und ohne erreichbares Remote. Der Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen. Umstellung: - Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6) - Gitlink aus dem Index entfernt - Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
176 lines
6.5 KiB
C#
176 lines
6.5 KiB
C#
using System;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Centron.BusinessLogic.Administration.Logins.TwoFactor;
|
|
using Centron.Common.Transfer.UDP;
|
|
using Centron.Host.Messages;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Microsoft.Graph;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
using NotImplementedException = System.NotImplementedException;
|
|
|
|
|
|
namespace Centron.Tests.EndToEnd.Tests.Radius
|
|
{
|
|
public class DummyUdpClient : IUdpClient
|
|
{
|
|
private byte[] Response;
|
|
|
|
public DummyUdpClient(byte[] Response)
|
|
{
|
|
this.Response = Response;
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
}
|
|
|
|
|
|
public Task send(byte[] packet) => Task.Run(() => { });
|
|
|
|
public Task<byte[]> receive() => Task<byte[]>.Run(() => this.Response);
|
|
}
|
|
|
|
public class RadiusMessageAuthenticationTest : CentronTest
|
|
{
|
|
public RadiusMessageAuthenticationTest(ITestOutputHelper testOutputHelper) : base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
[Fact]
|
|
public void PacketTestAccessRequestWithoutClass()
|
|
{
|
|
var requestAuthenticator = new byte[]
|
|
{
|
|
0x85, 0x1e, 0xa4, 0xf2, 0x54, 0xe6, 0x87, 0xca, 0xab, 0xa2, 0x47, 0x47, 0x96, 0x28, 0x60, 0x6b,
|
|
};
|
|
var packetBytes = new byte[]
|
|
{
|
|
// code
|
|
0x01,
|
|
// id
|
|
0x77,
|
|
//length
|
|
0x00, 0x4b,
|
|
// request authenticator
|
|
0x85, 0x1e, 0xa4, 0xf2, 0x54, 0xe6, 0x87, 0xca, 0xab, 0xa2, 0x47, 0x47, 0x96, 0x28, 0x60, 0x6b,
|
|
// attributes
|
|
0x01, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x02, 0x12, 0x49, 0xe1, 0xb9,
|
|
0x58, 0x7d, 0x07, 0xc2, 0xed, 0x6c, 0x4b, 0x1d, 0xb9, 0xea, 0x30, 0xa9, 0x1c, 0x04, 0x06, 0x7f,
|
|
0x00, 0x01, 0x01, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x50, 0x12, 0x0c, 0x9d, 0x8b, 0x14, 0x29,
|
|
0x30, 0xa1, 0x18, 0x40, 0x6f, 0xcd, 0x3d, 0x3f, 0xa4, 0x7d, 0x98,
|
|
};
|
|
var secret = Encoding.ASCII.GetBytes("testing123");
|
|
var parser = new RadiusPacketParser();
|
|
var packet = parser.Parse(packetBytes, secret, requestAuthenticator);
|
|
Console.WriteLine(packet.Code);
|
|
}
|
|
|
|
[Fact]
|
|
public void PacketTestAccesResponseWithoutClass()
|
|
{
|
|
var requestAuthenticator = new byte[]
|
|
{
|
|
0x85, 0x1e, 0xa4, 0xf2, 0x54, 0xe6, 0x87, 0xca, 0xab, 0xa2, 0x47, 0x47, 0x96, 0x28, 0x60, 0x6b,
|
|
};
|
|
|
|
var packetBytes = new byte[]
|
|
{
|
|
0x02, 0x77, 0x00, 0x26, 0xfc, 0x1e, 0x4d, 0x37, 0xc8, 0x02, 0x7f, 0x6a, 0x0b, 0xa9, 0x39, 0x98,
|
|
0x36, 0x74, 0x6d, 0x6a, 0x50, 0x12, 0x7d, 0xf9, 0x61, 0x81, 0xce, 0xfc, 0x12, 0xd6, 0xdb, 0x7b,
|
|
0xc1, 0xf8, 0xba, 0xe5, 0x4c, 0xcf
|
|
};
|
|
// Buffer.BlockCopy(packetBytes, 0, tempPacket, 0, packetBytes.Length);
|
|
var secret = Encoding.ASCII.GetBytes("testing123");
|
|
var parser = new RadiusPacketParser();
|
|
parser.Parse(packetBytes, secret, requestAuthenticator);
|
|
// parser.CalculateMessageAuthenticator(tempPacket, secret, requestAuthenticator);
|
|
// var packet = parser.Parse(packetBytes, secret);
|
|
}
|
|
|
|
[Fact]
|
|
public void ResponsePacketTestWithClass()
|
|
{
|
|
var RequestAuthenticator = new byte[]
|
|
{
|
|
0xa4, 0x95, 0x20, 0x93, 0x8a, 0xe2, 0xa7, 0x83, 0xc5, 0x91, 0x86, 0x25, 0x96, 0x13, 0x5a, 0x6e
|
|
};
|
|
|
|
var packetBytes = new byte[]
|
|
{
|
|
// type
|
|
0x02,
|
|
// id
|
|
0x93,
|
|
// length
|
|
0x00, 0x4b,
|
|
//request authenticator
|
|
0xb3, 0x52, 0x1d, 0x1d,
|
|
0x6f, 0xa1, 0x48, 0xf1,
|
|
0xaf, 0x3b, 0xb9, 0x0e,
|
|
0x2f, 0x0e, 0x1c, 0x5d,
|
|
|
|
//attrs
|
|
//message authenticator
|
|
0x50, 0x12,
|
|
0x1f, 0x27, 0x11, 0x5c,
|
|
0xcb, 0xfd, 0x00, 0xdc,
|
|
0x54, 0x51, 0xaf, 0x22,
|
|
0x09, 0x0f, 0xae, 0xa9,
|
|
//class
|
|
0x19, 0x25,
|
|
0x61, 0x69, 0x3a, 0x38,
|
|
0x38, 0x63, 0x34, 0x66,
|
|
0x39, 0x62, 0x38, 0x34,
|
|
0x31, 0x65, 0x62, 0x30,
|
|
0x61, 0x30, 0x61, 0x31,
|
|
0x34, 0x64, 0x64, 0x34,
|
|
0x38, 0x38, 0x31, 0x38,
|
|
0x36, 0x36, 0x63, 0x33,
|
|
0x39, 0x31, 0x36
|
|
};
|
|
var secret = Encoding.ASCII.GetBytes("testing123");
|
|
var parser = new RadiusPacketParser();
|
|
var packet = parser.Parse(packetBytes, secret, RequestAuthenticator);
|
|
Console.WriteLine(packet.Code);
|
|
}
|
|
|
|
|
|
[Fact]
|
|
public async Task SendFlow()
|
|
{
|
|
var secret = "testing123";
|
|
|
|
var parser = new RadiusPacketParser();
|
|
var request = new byte[]
|
|
{
|
|
// code
|
|
0x01,
|
|
// id
|
|
0x77,
|
|
//length
|
|
0x00, 0x4b,
|
|
// request authenticator
|
|
0x85, 0x1e, 0xa4, 0xf2, 0x54, 0xe6, 0x87, 0xca, 0xab, 0xa2, 0x47, 0x47, 0x96, 0x28, 0x60, 0x6b,
|
|
// attributes
|
|
0x01, 0x07, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x02, 0x12, 0x49, 0xe1, 0xb9,
|
|
0x58, 0x7d, 0x07, 0xc2, 0xed, 0x6c, 0x4b, 0x1d, 0xb9, 0xea, 0x30, 0xa9, 0x1c, 0x04, 0x06, 0x7f,
|
|
0x00, 0x01, 0x01, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x50, 0x12, 0x0c, 0x9d, 0x8b, 0x14, 0x29,
|
|
0x30, 0xa1, 0x18, 0x40, 0x6f, 0xcd, 0x3d, 0x3f, 0xa4, 0x7d, 0x98,
|
|
};
|
|
var RequestPaket = parser.Parse(request, Encoding.ASCII.GetBytes("testing123"), null);
|
|
|
|
var expectedResponse = new byte[]
|
|
{
|
|
0x02, 0x77, 0x00, 0x26, 0xfc, 0x1e, 0x4d, 0x37, 0xc8, 0x02, 0x7f, 0x6a, 0x0b, 0xa9, 0x39, 0x98,
|
|
0x36, 0x74, 0x6d, 0x6a, 0x50, 0x12, 0x7d, 0xf9, 0x61, 0x81, 0xce, 0xfc, 0x12, 0xd6, 0xdb, 0x7b,
|
|
0xc1, 0xf8, 0xba, 0xe5, 0x4c, 0xcf
|
|
};
|
|
|
|
var radiusClient = new RadiusClient(new DummyUdpClient(expectedResponse), secret, 1);
|
|
var response = await radiusClient.SendAsync(RequestPaket);
|
|
Assert.Equal(PacketCode.AccessAccept, response.Code);
|
|
}
|
|
}
|
|
} |