using NUnit.Framework; using ServiceInsideTest.Controllers; using ServiceShared; using ServiceShared.Crypto; using ServiceShared.Https; using ServiceShared.Models.Database; using ServiceShared.Models.Request; using ServiceShared.Models.Response; using System; using static ServiceShared.Models.Database.Results; namespace ServiceInsideTest.Service { public class ServiceOutside : BaseTestController { [Test] public void Notify() { KeyPair keyPair = Curve25519.GenerateKeyPair(); PublicKey publicKey = Request.GetPublicKey(this.ServiceOutsideURL); Assert.IsNotNull(publicKey); Assert.IsNotNull(publicKey.key); Assert.IsNotEmpty(publicKey.key); byte[] base64Encoded = Convert.FromBase64String(publicKey.key); Assert.IsNotNull(base64Encoded); byte[] sharedKey = keyPair.GetSharedKey(publicKey.key); Notification notification = new Notification(); notification.available = true; notification.pgs = "12345"; notification.available_ts = DateTime.Now; notification.created = DateTime.Now; notification.status = ResultsStatus.CREATED; ServiceInside.Service.ServiceOutside.Notify(notification); } [Test] public void NoIpRateLimiting() { KeyPair keyPair = Curve25519.GenerateKeyPair(); bool blocked = false; for (int i = 0; i < 10; i++) { PublicKey publicKey = Request.GetPublicKey(this.ServiceOutsideURL); if (publicKey == null) { blocked = true; break; } } Assert.IsFalse(blocked); } [Test] public void Test() { string decripted = AES.Decrypt("KPkiPpu/xyF5vIkneoMreExRRwbkJozV9h8BBIEBaq5SG7uugY6CzJe4pYI57JS079a4WFXEqg==", AES.GetKey("F372328C-26B9-4D76-9432-D8C1155062F5" + AES.PGS_ENCRYPT_PARTIAL_KEY)); } } }