From 91eb65bd6c874757295684a5194b8561de3bf207 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 4 Jul 2022 13:02:25 -0500 Subject: [PATCH] ProtectionService Test Fixture --- .../SecurityTests/ProtectionServiceFixture.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/NzbDrone.Core.Test/SecurityTests/ProtectionServiceFixture.cs diff --git a/src/NzbDrone.Core.Test/SecurityTests/ProtectionServiceFixture.cs b/src/NzbDrone.Core.Test/SecurityTests/ProtectionServiceFixture.cs new file mode 100644 index 000000000..1030ecaba --- /dev/null +++ b/src/NzbDrone.Core.Test/SecurityTests/ProtectionServiceFixture.cs @@ -0,0 +1,36 @@ +using System; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.Security; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.SecurityTests +{ + [TestFixture] + public class ProtectionServiceFixture : CoreTest + { + private string _protectionKey; + + [SetUp] + public void Setup() + { + _protectionKey = Guid.NewGuid().ToString().Replace("-", ""); + + Mocker.GetMock() + .SetupGet(s => s.DownloadProtectionKey) + .Returns(_protectionKey); + } + + [Test] + public void should_encrypt_and_decrypt_string() + { + const string plainText = "https://prowlarr.com"; + + var encrypted = Subject.Protect(plainText); + var decrypted = Subject.UnProtect(encrypted); + + decrypted.Should().Be(plainText); + } + } +}