From 88cb71f31878af9da126ff5f450f32635002f19f Mon Sep 17 00:00:00 2001
From: Klaus Fischer <klaus.fischer@eloware.com>
Date: Wed, 8 Jun 2022 11:48:32 +0200
Subject: [PATCH] Updated test names

---
 E2ETests/SenderTest.cs                        |  8 ++++++--
 FitConnect/EncryptionBaseClass.cs             |  2 +-
 FitConnect/Subscriber.cs                      | 14 ++++++--------
 .../BaseClassConstructorTests.cs              |  8 ++++----
 .../SenderEncryptionWithoutCertificateTest.cs | 19 +++++--------------
 5 files changed, 22 insertions(+), 29 deletions(-)

diff --git a/E2ETests/SenderTest.cs b/E2ETests/SenderTest.cs
index d912585e..f7f4372b 100644
--- a/E2ETests/SenderTest.cs
+++ b/E2ETests/SenderTest.cs
@@ -12,6 +12,10 @@ public class SenderTest {
     private string _clientSecret = "";
     private Sender _sender;
 
+    /// <summary>
+    /// Setup creates json file for credentials if not found
+    /// </summary>
+    /// <exception cref="Exception"></exception>
     [OneTimeSetUp]
     public void OneTimeSetup() {
         // relative to the project execution directory
@@ -50,7 +54,7 @@ public class SenderTest {
     }
 
     [Test]
-    public void GetAccessToken() {
+    public void GetAccessToken_ExpiresInShouldBe1800_WithoutScope() {
         var token = _sender.GetTokenAsync(_clientId, _clientSecret).Result;
         token.Should().NotBeNull();
         token!.ExpiresIn.Should().Be(1800);
@@ -58,7 +62,7 @@ public class SenderTest {
     }
 
     [Test]
-    public void GetAccessTokenWithScope() {
+    public void GetAccessToken_ScopeShouldMatch_WithScope() {
         var token = _sender.GetTokenAsync(_clientId, _clientSecret, "send:region:DE01010").Result;
         token.Should().NotBeNull();
         token!.ExpiresIn.Should().Be(1800);
diff --git a/FitConnect/EncryptionBaseClass.cs b/FitConnect/EncryptionBaseClass.cs
index 60581a49..8e7919c0 100644
--- a/FitConnect/EncryptionBaseClass.cs
+++ b/FitConnect/EncryptionBaseClass.cs
@@ -12,7 +12,7 @@ public class EncryptionBaseClass {
 
     protected EncryptionBaseClass(ILogger? logger) {
         _logger = logger;
-        _rsa = RSA.Create(2048);
+        _rsa = RSA.Create(4096);
     }
 
 
diff --git a/FitConnect/Subscriber.cs b/FitConnect/Subscriber.cs
index 22775215..d96cc0d1 100644
--- a/FitConnect/Subscriber.cs
+++ b/FitConnect/Subscriber.cs
@@ -14,15 +14,13 @@ public class Subscriber : FunctionalBaseClass {
     private async Task<string> GetContentFromEmbeddedResource(string filename) {
         var assembly = typeof(Subscriber).GetTypeInfo().Assembly;
         var resourceName = $"{assembly.GetName().Name}.{filename}";
-        using (var stream = assembly.GetManifestResourceStream(resourceName)) {
-            if (stream == null) {
-                throw new Exception($"Could not find embedded resource {resourceName}");
-            }
-
-            using (var reader = new StreamReader(stream)) {
-                return await reader.ReadToEndAsync();
-            }
+        await using var stream = assembly.GetManifestResourceStream(resourceName);
+        if (stream == null) {
+            throw new Exception($"Could not find embedded resource {resourceName}");
         }
+
+        using var reader = new StreamReader(stream);
+        return await reader.ReadToEndAsync();
     }
 
     /// <summary>
diff --git a/InitializationTests/BaseClassConstructorTests.cs b/InitializationTests/BaseClassConstructorTests.cs
index 0c837967..32a01111 100644
--- a/InitializationTests/BaseClassConstructorTests.cs
+++ b/InitializationTests/BaseClassConstructorTests.cs
@@ -16,7 +16,7 @@ public class BaseClassConstructorTests {
     }
 
     [Test]
-    public void CreateCustomEndpoints() {
+    public void Sender_CreateCustomEndpoints() {
         var dut = new Sender(_logger, new FitConnectEndpoints(
             "http://localhost:5050/token",
             "http://localhost:5050/submission",
@@ -28,7 +28,7 @@ public class BaseClassConstructorTests {
     }
 
     [Test]
-    public void CreateDevEndpoints() {
+    public void Sender_CreateDevEndpoints() {
         var dut = new Sender(_logger,
             FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Development));
 
@@ -39,7 +39,7 @@ public class BaseClassConstructorTests {
     }
 
     [Test]
-    public void CreateTestingEndpoints() {
+    public void Sender_CreateTestingEndpoints_ShouldThrowArgumentException() {
         Assert.Throws<ArgumentException>(() => {
             var sender = new Subscriber(_logger,
                 FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Testing));
@@ -47,7 +47,7 @@ public class BaseClassConstructorTests {
     }
 
     [Test]
-    public void CreateProductionEndpoints() {
+    public void Sender_CreateProductionEndpoints_ShouldThrowArgumentException() {
         Assert.Throws<ArgumentException>(() => {
             var sender = new Sender(_logger,
                 FitConnectEndpoints.Create(FitConnectEndpoints.EndpointType.Production));
diff --git a/SenderTest/SenderEncryptionWithoutCertificateTest.cs b/SenderTest/SenderEncryptionWithoutCertificateTest.cs
index 06bd1d06..2dccbee7 100644
--- a/SenderTest/SenderEncryptionWithoutCertificateTest.cs
+++ b/SenderTest/SenderEncryptionWithoutCertificateTest.cs
@@ -26,28 +26,19 @@ public class SenderEncryptionWithoutCertificateTest {
 
 
     [Test]
-    public void CryptWithOutPublicKeyImport() {
+    public void EncryptData_ShouldNotThrowAnyException() {
         var cypher = _sender.EncryptData(Encoding.UTF8.GetBytes("test"));
 
         _logger.LogInformation("Cypher: {}", Convert.ToBase64String(cypher));
     }
 
-
-    [Test]
-    [Ignore("Not applicable for production")]
-    public void CryptWithPublicKeyImport() {
-        var publicKey = Convert.FromBase64String(
-            "MIIBCgKCAQEAzu/ek6A5AMuROs+12pncbYNteGkd6ReU28ZY5gCM4hNFI0h1E+0+OST+Yxw7zhvbFhZbYdVt8LmzonMAtENituLxzZj7MsWom/ZzxTdp4Cx5zlx8x6Qx/ZPoSS2T2Sf0ttymaMc6ZadpWsDhg/Mnf6beF1W/QoGH/bHBa8U4rhkUa+OKf3wyo08km8oyUJaj6kkB0VdhRp5rSyvXJtUMZ5A0LcYFygnkHTSQlQhdrAK+6nTo//mfNfPtqta2wBb9ONpVwN0V7I5PSdH2WxZMZsYFicLOGbNeF08gibmL+7TeBTssYtrNVM88cG0v+aWeBun0WVrpCntDIA9HIujWowIDAQAB");
-
-        var cypher = _sender.EncryptData(Encoding.UTF8.GetBytes("test"), publicKey);
-
-        _logger.LogInformation("Cypher: {}", Convert.ToBase64String(cypher));
-    }
-
+    
     [Test]
-    public void ExportPrivateKey() {
+    public void ExportPrivateKey_ShouldNotThrowAnyException() {
         var privateKey = _sender.ExportPrivateKey();
         _logger.LogInformation("Private key: {}", Convert.ToBase64String(privateKey));
     }
+    
+    
 
 }
-- 
GitLab