diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..7847b419884a776bd42109fc8ed55d2a43264ecb --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,21 @@ +include: + - project: 'fit-connect/pipeline' + ref: main + file: 'reuse.gitlab-ci.yml' + +stages: + - lint + - test + - build + +build: + stage: build + image: mcr.microsoft.com/dotnet/sdk:6.0 + script: dotnet build FitConnect + +test: + stage: test + image: mcr.microsoft.com/dotnet/sdk:6.0 + script: + - dotnet test E2ETest + diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 0000000000000000000000000000000000000000..f530c5364ffd7b1f6bcc973b1df087f33fc1b8eb --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,13 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: FitConnect/* DemoRunner/* BasicUnitTest/* E2ETest/* EncryptionTests/* IntegrationTests/* + MockContainer/* FitConnect.sln test.Dockerfile Test.pdf version.sh FitConnect.sln.DotSettings + README.md CHANGELOG.md *.md Dockerfile +Copyright: 2022 FIT-Connect contributors +License: EUPL-1.2 + + +Files: .gitlab-ci.yml .gitignore .idea/* + renovate.json checkstyle.xml config.yml +Copyright: 2022 FIT-Connect contributors +License: CC0-1.0 \ No newline at end of file diff --git a/BasicUnitTest/SenderTests.cs b/BasicUnitTest/SenderTests.cs index e824755cf22491380dab5cd161d3f1e15f6e3436..46a29fb6ef3c506dd96cd5c2e976c498bdbf565d 100644 --- a/BasicUnitTest/SenderTests.cs +++ b/BasicUnitTest/SenderTests.cs @@ -41,7 +41,7 @@ public class SenderTests { .WithDestination(Guid.NewGuid().ToString()) .WithServiceType("", "") .WithAttachments(Array.Empty<Attachment>()) - .WithData("") + .WithJsonData("") .Submit(); })!.Message.Should().Be("Invalid leika key"); } @@ -54,7 +54,7 @@ public class SenderTests { .WithDestination(Guid.NewGuid().ToString()) .WithServiceType("", leikaKey) .WithAttachments(Array.Empty<Attachment>()) - .WithData("") + .WithJsonData("") .Submit(); } @@ -69,6 +69,72 @@ public class SenderTests { .Submit(); } + [Test] + public void FluentSender_ShouldNotThrowAnError_MockingServicesWithJsonData() { + new Sender(FitConnectEnvironment.Testing, + clientId, clientSecret, + Container.Create()) + .WithDestination(Guid.NewGuid().ToString()) + .WithServiceType("", leikaKey) + .WithAttachments(Array.Empty<Attachment>()) + .WithJsonData(@"{ + ""name"": ""John Doe"", + ""age"": 42 + }") + .Submit(); + } + + [Test] + public void FluentSender_ShouldNotThrowsInvalidJsonError_MockingServicesWithJsonData() { + Assert.Throws<ArgumentException>(() => { + new Sender(FitConnectEnvironment.Testing, + clientId, clientSecret, + Container.Create()) + .WithDestination(Guid.NewGuid().ToString()) + .WithServiceType("", leikaKey) + .WithAttachments(Array.Empty<Attachment>()) + .WithJsonData(@"{ + ""name"": ""John Doe, + ""age"": 42 + }") + .Submit(); + }); + } + + [Test] + public void FluentSender_ShouldNotThrowAnError_MockingServicesWithXmlData() { + new Sender(FitConnectEnvironment.Testing, + clientId, clientSecret, + Container.Create()) + .WithDestination(Guid.NewGuid().ToString()) + .WithServiceType("", leikaKey) + .WithAttachments(Array.Empty<Attachment>()) + .WithXmlData(@"<?xml version=""1.0"" encoding=""UTF-8"" ?> + <root> + <name>John Doe</name> + <age>42</age> + </root>") + .Submit(); + } + + [Test] + public void FluentSender_ShouldNotThrowInvalidXml_MockingServicesWithXmlData() { + Assert.Throws<ArgumentException>(() => { + new Sender(FitConnectEnvironment.Testing, + clientId, clientSecret, + Container.Create()) + .WithDestination(Guid.NewGuid().ToString()) + .WithServiceType("", leikaKey) + .WithAttachments(Array.Empty<Attachment>()) + .WithXmlData(@"<?xml version=""1.0"" encoding=""UTF-8"" ?> + <root> + <name>John Doe</> + <age>42</age> + </root>") + .Submit(); + }); + } + [Test] public void VerifyMetaData_ValidData_Fine() { // Arrange @@ -85,7 +151,7 @@ public class SenderTests { } [Test] - public void VerifyMetaData_MissingLeikaKey_ThorwsAnError() { + public void VerifyMetaData_MissingLeikaKey_ThrowsAnError() { // Arrange var submission = new Submission(); diff --git a/DemoRunner/SenderDemo.cs b/DemoRunner/SenderDemo.cs index 8242b072004d9323bbff923c217fd143eec5fb4a..01e7bb926a7b6209f52ba01b9aba3e97af0308ab 100644 --- a/DemoRunner/SenderDemo.cs +++ b/DemoRunner/SenderDemo.cs @@ -1,4 +1,6 @@ +using System.Threading.Channels; using FitConnect; +using FitConnect.Encryption; using FitConnect.Models; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; @@ -19,7 +21,40 @@ public static class SenderDemo { .WithDestination(destinationId) .WithServiceType("FIT Connect Demo", leikaKey) .WithAttachments(new Attachment("Test.pdf", "Test Attachment")) - .WithData("{\"message\":\"Hello World\"}") + .WithJsonData("{\"message\":\"Hello World\"}") + .Submit(); + } + + public static void RunEncrypted(IConfigurationRoot config, ILogger logger) { + var clientId = config["FitConnect:Sender:ClientId"]; + var clientSecret = config["FitConnect:Sender:ClientSecret"]; + var destinationId = config["FitConnect:Sender:DestinationId"]; + var leikaKey = config["FitConnect:Sender:LeikaKey"]; + + + FitEncryption encryption; + Dictionary<string, string>? encryptedAttachments = null; + string? encryptedMetadata = null; + string? encryptedData = null; + + var sender = Client + .GetSender(FitConnectEnvironment.Testing, clientId, clientSecret, logger) + .WithDestination(destinationId, + (k) => { + logger?.LogInformation("Received public key: {Key}", k); + encryption = new FitEncryption(k, logger); + encryptedAttachments = new Dictionary<string, string>() { { "", "" } }; + encryptedMetadata = ""; + encryptedData = encryption.Encrypt("{\"message\":\"Hello World\"}"); + }); + + // Return the public key to the JavaScript client + // Come back later with the encrypted data + + sender.WithServiceType("FIT Connect Demo", leikaKey) + .WithEncryptedAttachments(encryptedAttachments!) + .WithEncryptedMetaData(encryptedMetadata!) + .WithEncryptedData(encryptedData!) .Submit(); } } diff --git a/E2ETest/E2ETest.csproj b/E2ETest/E2ETest.csproj index 974a92a07342e19b27e979c3c468d7658703bc45..4881ea4ea7b9544e4aa7973b007a2f3141b5bead 100644 --- a/E2ETest/E2ETest.csproj +++ b/E2ETest/E2ETest.csproj @@ -9,17 +9,17 @@ </PropertyGroup> <ItemGroup> - <PackageReference Include="FluentAssertions" Version="6.7.0"/> - <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0"/> - <PackageReference Include="NUnit" Version="3.13.3"/> - <PackageReference Include="NUnit3TestAdapter" Version="4.2.1"/> - <PackageReference Include="NUnit.Analyzers" Version="3.3.0"/> - <PackageReference Include="coverlet.collector" Version="3.1.2"/> + <PackageReference Include="FluentAssertions" Version="6.7.0" /> + <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" /> + <PackageReference Include="NUnit" Version="3.13.3" /> + <PackageReference Include="NUnit3TestAdapter" Version="4.2.1" /> + <PackageReference Include="NUnit.Analyzers" Version="3.3.0" /> + <PackageReference Include="coverlet.collector" Version="3.1.2" /> </ItemGroup> <ItemGroup> - <ProjectReference Include="..\FitConnect\FitConnect.csproj"/> - <ProjectReference Include="..\MockContainer\MockContainer.csproj"/> + <ProjectReference Include="..\FitConnect\FitConnect.csproj" /> + <ProjectReference Include="..\MockContainer\MockContainer.csproj" /> </ItemGroup> </Project> diff --git a/E2ETest/EndToEndTestBase.cs b/E2ETest/EndToEndTestBase.cs index 4052e4d4985699624cb5be89e707846f677134eb..85bc6975295708efd63b20c45011c519d867edea 100644 --- a/E2ETest/EndToEndTestBase.cs +++ b/E2ETest/EndToEndTestBase.cs @@ -22,7 +22,7 @@ public abstract class EndToEndTestBase { Logger = LoggerFactory.Create( builder => { builder.AddConsole(); - builder.SetMinimumLevel(LogLevel.Debug); + builder.SetMinimumLevel(LogLevel.Trace); }).CreateLogger("E2E Test"); diff --git a/E2ETest/RejectSubmissionTest.cs b/E2ETest/RejectSubmissionTest.cs index 69ea1e2d8f7dd82cb221787df1b56db8731b791f..70c3b5b5f6ccaa54b98d7952019ca3ffe4f7ece9 100644 --- a/E2ETest/RejectSubmissionTest.cs +++ b/E2ETest/RejectSubmissionTest.cs @@ -16,7 +16,7 @@ public class RejectSubmissionTest : EndToEndTestBase { var submission = Sender.WithDestination(Settings.DestinationId) .WithServiceType("Straight forward test", Settings.LeikaKey) .WithAttachments(new Attachment("Test.pdf", "A simple PDF")) - .WithData(@"{""data"":""value""}") + .WithJsonData(@"{""data"":""value""}") .Submit(); _caseId = submission.CaseId!; diff --git a/E2ETest/StraightForwardTest.cs b/E2ETest/StraightForwardTest.cs index 19a3000b38c5d3a3d60fa82ef2dfff4c3d6f50e4..272561f0c10f3bb5d07b05fb22dd0cbe74351ade 100644 --- a/E2ETest/StraightForwardTest.cs +++ b/E2ETest/StraightForwardTest.cs @@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging; namespace E2ETest; +[TestFixture] public class StraightForwardTest : EndToEndTestBase { private string _caseId = null!; private string _submissionId = null!; @@ -14,7 +15,7 @@ public class StraightForwardTest : EndToEndTestBase { var submission = Sender.WithDestination(Settings.DestinationId) .WithServiceType("Straight forward test", Settings.LeikaKey) .WithAttachments(new Attachment("Test.pdf", "A simple PDF")) - .WithData(@"{""data"":""value""}") + .WithJsonData(@"{""data"":""value""}") .Submit(); _caseId = submission.CaseId!; @@ -47,7 +48,7 @@ public class StraightForwardTest : EndToEndTestBase { status.ForEach( s => Logger.LogInformation("Status {When} {Event}", s.EventTime, s.EventType)); } - + [Test] [Order(40)] public void RequestSubmission() { diff --git a/E2ETest/StraightPreEncryptedForwardTest.cs b/E2ETest/StraightPreEncryptedForwardTest.cs new file mode 100644 index 0000000000000000000000000000000000000000..a7c31756b221fadee5cafa2d8f6dab3a5d7eecb9 --- /dev/null +++ b/E2ETest/StraightPreEncryptedForwardTest.cs @@ -0,0 +1,88 @@ +using FitConnect.Encryption; +using FitConnect.Models; +using FluentAssertions; +using Microsoft.Extensions.Logging; + +namespace E2ETest; + +[TestFixture] +public class StraightPreEncryptedForwardTest : EndToEndTestBase { + private string _caseId = null!; + private string _submissionId = null!; + + [Order(10)] + [Test] + public void SendingSubmission() { + var submission = Sender.WithDestination(Settings.DestinationId) + .WithServiceType("Straight forward test", Settings.LeikaKey) + .WithEncryptedAttachments(new Dictionary<string, string>() { + { + "a2c0667a-8162-443b-a08a-a80936709ba0", + "eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2R0NNIiwia2lkIjoidnI3Y1dLR2wtZzRXYV9DUkdvd05oQVlXX2dRYi1ha01iaWlneE4wRWtESSIsImN0eSI6ImFwcGxpY2F0aW9uL2pzb24iLCJ6aXAiOiJERUYifQ.dIJJGlWOaV5HqJxcLUyHngWwE6fLk66iOvrLfbP8pLfcYcuPU6HFdScVKBWTWAtWCBO62--uEagzW2kmbWnBcj8eZo6Nus4JLLq28Bk03S3ZXyMjHy4wHaHW_oXdSogSi5KJLEr-xR6fj3ztAmReNwa3zRmKb7VncknxtI4AzQuC3WEO4SnwAhUJYCxzNoFf7ewgjkNJcJK5un9ZlJe6Xljbd9RGQ47FnPbKSqQDlBFVeapwK6WjZmjQktpxQN2sROAcjP1xeYxGlEDo5OmLJ-Nd-QbQ3eTn8d5rfT9pyTZiG1Mm7-DsmtQCM-KHBsygQR4Zk7PxD6tuOvwo0YthiC_aCxIa4KtJRdL2Tk-YUv9QMYT9pKrHlXK_v97mgsmNWU8jp6MKSk-7baKTGqlXB9wMgGpOBzTPulGpaYaPn9QcoGg_xSrL6m781RYkYDsiUfW5QBxfbiaWhAKbIsohmA6GLfdAZaTFJM7Ic4Cryh2Rzh8CMI13b5OZxZu0XoHwM8d5G7cYI5S99S0cBy6V4OMMJSvwvKXrAldUkR83nZrJMAT7O78GmeXWWNvmO2zFeXFWv6HEikd12EaZ472qy2pMmotKbW4VdX2Mp3fg67ECdn_9DjmMdIdvcr-9hrvxlDVerpZA71wZ5SX2p37KGTkTWpijJ99qHKZLfvkQumg.byGlrhJG-rwiSjyv.uofMXOJKsnBvY-NUs408UKyKoR2hlWom_CM5aXHS67i5V64WNkt_XcEUHbdGmJA1J-y-AGutVjrO8O6OG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+ .Submit(); + + _caseId = submission.CaseId!; + _submissionId = submission.Id!; + + _caseId.Should().NotBeNull(); + _submissionId.Should().NotBeNull(); + } + + [Test] + [Order(20)] + public void Sender_GetSubmissionState() { + // Act + var status = Sender.GetStatusForSubmission(_caseId, Settings.DestinationId); + + // Assert + status.Count.Should().BeGreaterThan(0); + status.ForEach( + s => Logger.LogInformation("Status {When} {Event}", s.EventTime, s.EventType)); + } + + [Test] + [Order(30)] + public void Subscriber_GetSubmissionState() { + // Act + var status = Subscriber.GetStatusForSubmission(_caseId, Settings.DestinationId); + + // Assert + status.Count.Should().BeGreaterThan(0); + status.ForEach( + s => Logger.LogInformation("Status {When} {Event}", s.EventTime, s.EventType)); + } + + [Test] + [Order(40)] + public void RequestSubmission() { + var subscriberWithSubmission = Subscriber.RequestSubmission(_submissionId); + + var data = subscriberWithSubmission.GetDataJson(); + Logger.LogInformation("Data {Data}", data); + + data.Should().Be(@"{""data"":""value""}"); + + var attachments = subscriberWithSubmission.GetAttachments(); + attachments.First().Filename.Should().Be("Test.pdf"); + + subscriberWithSubmission.AcceptSubmission(); + } + + [Test] + [Order(50)] + public void Sender_GetSubmissionState_AfterAccepting() { + // Act + var status = Sender.GetStatusForSubmission(_caseId, Settings.DestinationId); + + // Assert + status.Count.Should().BeGreaterThan(0); + status.ForEach( + s => Logger.LogInformation("Status {When} {Event}", s.EventTime, s.EventType)); + } +} diff --git a/FitConnect/EncryptedSender.cs b/FitConnect/EncryptedSender.cs new file mode 100644 index 0000000000000000000000000000000000000000..b9fa33f6056b379486d94ba98d995f82fbff642d --- /dev/null +++ b/FitConnect/EncryptedSender.cs @@ -0,0 +1,60 @@ +using FitConnect.Interfaces.Sender; +using FitConnect.Models; +using FitConnect.Services.Models.v1.Submission; +using Microsoft.Extensions.Logging; + +namespace FitConnect; + +public partial class Sender { + public IWithEncryptedAttachments WithEncryptedAttachments( + Dictionary<string, string> attachments) { + if (Submission?.ServiceType == null) { + Logger?.LogError("Submission has no service type"); + throw new ArgumentException("Submission has no service type"); + } + + var createSubmissionDto = (CreateSubmissionDto)Submission; + createSubmissionDto.AnnouncedAttachments = attachments.Keys.ToList(); + var created = SubmissionService.CreateSubmission(createSubmissionDto); + Submission.Id = created.SubmissionId; + Submission.CaseId = created.CaseId; + + if (Submission?.Id == null) + throw new ArgumentException("Submission is not ready"); + + Logger?.LogInformation("Uploading pre encrypted attachments"); + UploadAttachmentsAsync(Submission.Id!, attachments); + return this; + } + + public ISenderWithEncryptedData WithEncryptedData(string data) { + if (Submission?.Id == null) + throw new ArgumentException("Submission is not ready"); + + Submission.EncryptedData = data; + return this; + } + + public ISenderWithEncryptedMetaData WithEncryptedMetaData(string metaData) { + if (Submission?.Id == null) + throw new ArgumentException("Submission is not ready"); + + Submission.EncryptedMetadata = metaData; + return this; + } + + + Submission ISenderWithEncryptedData.Submit() { + if (Submission == null) { + Logger?.LogCritical("Submission is null on submit"); + throw new InvalidOperationException("Submission is not ready"); + } + + Logger?.LogTrace("Encrypted metadata: {EncryptedMeta}", Submission.EncryptedMetadata); + var result = SubmissionService + .SubmitSubmission(Submission.Id!, (SubmitSubmissionDto)Submission).Result; + + Logger?.LogInformation("Submission sent"); + return Submission; + } +} diff --git a/FitConnect/Encryption/FitEncryption.cs b/FitConnect/Encryption/FitEncryption.cs index 4975ed142f25316c18ce1b3f94aecfe7e4ca9d20..9a611b597f5087c6e67278f680b19704f87e7cc5 100644 --- a/FitConnect/Encryption/FitEncryption.cs +++ b/FitConnect/Encryption/FitEncryption.cs @@ -49,6 +49,10 @@ public class FitEncryption { PublicKeySignatureVerification = keySet.PublicKeySignatureVerification; } + public FitEncryption(string publicKeyEncryption, ILogger? logger) : this(logger) { + PublicKeyEncryption = publicKeyEncryption; + } + public (string plainText, byte[] plainBytes, byte[] tag) Decrypt(string cypherText, string key) { @@ -270,4 +274,4 @@ public class FitEncryption { return result.IsValid; } -} \ No newline at end of file +} diff --git a/FitConnect/Interfaces/Sender/ISender.cs b/FitConnect/Interfaces/Sender/ISender.cs index cbd6bfa5d0b8e8a31475276b4a42814f36fa5cc6..816d365d9dc2ab57a9065e3025e53bdcbdc3b336 100644 --- a/FitConnect/Interfaces/Sender/ISender.cs +++ b/FitConnect/Interfaces/Sender/ISender.cs @@ -10,10 +10,12 @@ public interface ISender : IFitConnectClient { /// <param name="ags"></param> /// <param name="ars"></param> /// <param name="areaId"></param> + /// <param name="receivedPublicKey">Callback for presenting the public key</param> /// <returns></returns> public ISenderWithDestination FindDestinationId(string leiaKey, string? ags = null, string? ars = null, - string? areaId = null); + string? areaId = null, + Action<string>? receivedPublicKey = null); /// <summary> /// Configures the client for the given destination and loads the public key @@ -22,6 +24,8 @@ public interface ISender : IFitConnectClient { /// unique identifier of the clients destination /// <para>eg: 00000000-0000-0000-0000-000000000000</para> /// </param> + /// <param name="receivedPublicKey">Callback for presenting the public key</param> /// <returns>the upload step for attachments</returns> - public ISenderWithDestination WithDestination(string destinationId); + public ISenderWithDestination WithDestination(string destinationId, + Action<string>? receivedPublicKey = null); } diff --git a/FitConnect/Interfaces/Sender/ISenderWithAttachments.cs b/FitConnect/Interfaces/Sender/ISenderWithAttachments.cs index d25ea83e297998541a8f27b64d5a39eeffb3103b..ede12e27995b57f2a31e569205502c2dd05f38be 100644 --- a/FitConnect/Interfaces/Sender/ISenderWithAttachments.cs +++ b/FitConnect/Interfaces/Sender/ISenderWithAttachments.cs @@ -1,13 +1,24 @@ +using FitConnect.Models; + namespace FitConnect.Interfaces.Sender; public interface ISenderWithAttachments : ISenderReady { /// <summary> /// Data as string. /// </summary> - /// <param name="data">json or xml as string</param> + /// <param name="data">json as string</param> /// <example> - /// .WithData(@"{ ""name"": ""John Doe"" }") + /// .WithJsonData(@"{ ""name"": ""John Doe"" }") /// </example> /// <returns>next step to submit the data</returns> - public ISenderWithData WithData(string data); + public ISenderWithData WithJsonData(string data); + + /// <summary> + /// Data as string. + /// </summary> + /// <param name="data">xml as string</param> + /// <returns>next step to submit the data</returns> + public ISenderWithData WithXmlData(string data); } + + diff --git a/FitConnect/Interfaces/Sender/ISenderWithService.cs b/FitConnect/Interfaces/Sender/ISenderWithService.cs index 2ce1321028967510fc5d2bdcd9441a0215eba562..680e5f8fb1991387217630e1f1219b6358318d3c 100644 --- a/FitConnect/Interfaces/Sender/ISenderWithService.cs +++ b/FitConnect/Interfaces/Sender/ISenderWithService.cs @@ -16,4 +16,24 @@ public interface ISenderWithService { /// <param name="attachments">that are sent with the submission</param> /// <returns>the step where additional data can be added to the submission</returns> public ISenderWithAttachments WithAttachments(params Attachment[] attachments); + + /// <summary> + /// Adding the encrypted attachments to the submission + /// </summary> + /// <param name="attachments">Dictionary with the UUID and the encrypted attachment</param> + /// <returns></returns> + public IWithEncryptedAttachments WithEncryptedAttachments( + Dictionary<string, string> attachments); +} + +public interface IWithEncryptedAttachments { + public ISenderWithEncryptedMetaData WithEncryptedMetaData(string metaData); +} + +public interface ISenderWithEncryptedMetaData : ISenderWithEncryptedData { + public ISenderWithEncryptedData WithEncryptedData(string data); +} + +public interface ISenderWithEncryptedData { + public Submission Submit(); } diff --git a/FitConnect/Models/Submission.cs b/FitConnect/Models/Submission.cs index b8792a1d46a3790e20986c32dc9b4a42afad5ee0..d12e5dea2e1851eb11981b167d62ee85e4a4c141 100644 --- a/FitConnect/Models/Submission.cs +++ b/FitConnect/Models/Submission.cs @@ -26,6 +26,7 @@ public class Submission { public string? EncryptedData { get; set; } public string? MetaAuthentication => EncryptedMetadata?.Split('.').Last(); public string? DataAuthentication => EncryptedData?.Split('.').Last(); + public string? DataMimeType { get; set; } public bool IsSubmissionReadyToAdd(out string? error) { var innerError = ""; diff --git a/FitConnect/Properties/AssemblyInfo.cs b/FitConnect/Properties/AssemblyInfo.cs index 49986d47feefcf501c1b2de8b2b4b8d7025ecd6f..5a9aa85b20efa09d0c3536b5d3edd8d71205c4e2 100644 --- a/FitConnect/Properties/AssemblyInfo.cs +++ b/FitConnect/Properties/AssemblyInfo.cs @@ -13,6 +13,7 @@ using System.Runtime.CompilerServices; [assembly:InternalsVisibleTo("IntegrationTests")] +[assembly:InternalsVisibleTo("BasicUnitTest")] // Von der MSBuild WriteCodeFragment-Klasse generiert. diff --git a/FitConnect/Sender.cs b/FitConnect/Sender.cs index a140a1e438302b4f29b79917226a5ab7835e0c19..d487b9c1de9e2871e1eb9a1c32493554647cbf65 100644 --- a/FitConnect/Sender.cs +++ b/FitConnect/Sender.cs @@ -1,5 +1,6 @@ using System.Security; using System.Text.RegularExpressions; +using System.Xml; using Autofac; using FitConnect.Encryption; using FitConnect.Interfaces.Sender; @@ -28,8 +29,9 @@ namespace FitConnect; /// .Subm@it(); /// </code> /// </example> -public class Sender : FitConnectClient, ISender, ISenderWithDestination, - ISenderWithAttachments, ISenderWithData, ISenderWithService { +public partial class Sender : FitConnectClient, ISender, ISenderWithDestination, + ISenderWithAttachments, ISenderWithData, ISenderWithService, IWithEncryptedAttachments, + ISenderWithEncryptedMetaData, ISenderWithEncryptedData { public string? PublicKey { get; set; } public Submission? Submission { get; set; } @@ -45,26 +47,29 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, public ISenderWithDestination FindDestinationId(string leiaKey, string? ags = null, string? ars = null, - string? areaId = null) { + string? areaId = null, Action<string>? receivedPublicKey = null) { if (ags == null && ars == null && areaId == null) throw new ArgumentException("One of the following must be provided: ags, ars, areaId"); var destinationId = RouteService.GetDestinationIdAsync(leiaKey, ags, ars, areaId).Result; Logger?.LogInformation("Received destinations: {Destinations}", destinationId.Select(d => d.DestinationId).Aggregate((a, b) => a + "," + b)); - return WithDestination(destinationId.First().DestinationId); + return WithDestination(destinationId.First().DestinationId, receivedPublicKey); } - public ISenderWithDestination WithDestination(string destinationId) { + public ISenderWithDestination WithDestination(string destinationId, + Action<string>? receivedPublicKey = null) { if (!Regex.IsMatch(destinationId, "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$")) throw new ArgumentException("The destination must be a valid GUID"); Submission = CreateSubmission(destinationId).Result; + if (PublicKey != null) + receivedPublicKey?.Invoke(PublicKey!); return this; } - public ISenderWithData WithData(string data) { + public ISenderWithData WithJsonData(string data) { try { JsonConvert.DeserializeObject(data); } @@ -74,6 +79,21 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, Submission!.Data = data; + Submission.DataMimeType = "application/json"; + return this; + } + + public ISenderWithData WithXmlData(string data) { + try { + var doc = new XmlDocument(); + doc.LoadXml(data); + } + catch (Exception e) { + throw new ArgumentException("The data must be valid XML string", e); + } + + Submission!.Data = data; + Submission.DataMimeType = "application/xml"; return this; } @@ -159,6 +179,7 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, return this; } + public ISenderWithDestination FindDestinationId(Destination destination) { throw new NotImplementedException(); } @@ -181,7 +202,7 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, return submission; } - internal async Task<string> GetPublicKeyFromDestination(string destinationId) { + public async Task<string> GetPublicKeyFromDestination(string destinationId) { var publicKey = await DestinationService.GetPublicKey(destinationId); var keyIsValid = new CertificateHelper(Logger).ValidateCertificate(publicKey, @@ -197,7 +218,7 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, /// </summary> /// <param name="submission"></param> /// <returns></returns> - public static string CreateMetadata(Submission submission) { + internal static string CreateMetadata(Submission submission) { var data = new Data { Hash = new DataHash { Type = "sha512", @@ -205,9 +226,9 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, }, SubmissionSchema = new Fachdatenschema { - SchemaUri = submission.ServiceType.Identifier, - MimeType = "application/json" - } + SchemaUri = submission.ServiceType.Identifier, + MimeType = submission.DataMimeType ?? "application/json" + } }; var contentStructure = new ContentStructure { Data = data, @@ -231,6 +252,7 @@ public class Sender : FitConnectClient, ISender, ISenderWithDestination, return JsonConvert.SerializeObject(metaData); } + /// <summary> /// Finding Areas /// </summary> diff --git a/IntegrationTests/CertificateValidation.cs b/IntegrationTests/CertificateValidation.cs index 6a24b057720eba67e86b69fe8ced86098c8e9981..d7367decf578e5bc2d9447321d83310fd57f37f2 100644 --- a/IntegrationTests/CertificateValidation.cs +++ b/IntegrationTests/CertificateValidation.cs @@ -132,6 +132,7 @@ public class CertificateValidation { } [Test] + [Ignore("Not implemented")] public void CheckPemFiles() { if (!Directory.Exists("./certificates") || !Directory.Exists("./certificates/roots")) { Assert.Inconclusive("No certificates found"); diff --git a/IntegrationTests/Sender/SenderTestHappyPath.cs b/IntegrationTests/Sender/SenderTestHappyPath.cs index 89b33074301e82595b1b68adced0f28b72a11b04..b8f0f7d46de4c98f626a3fd0b622b03c5227f63e 100644 --- a/IntegrationTests/Sender/SenderTestHappyPath.cs +++ b/IntegrationTests/Sender/SenderTestHappyPath.cs @@ -107,7 +107,7 @@ public class SenderTestHappyPath : SenderTestBase { .WithDestination(DestinationId) .WithServiceType("ServiceName", "urn:de:fim:leika:leistung:99400048079000") .WithAttachments(attachments) - .WithData(JsonConvert.SerializeObject(new { + .WithJsonData(JsonConvert.SerializeObject(new { FirstName = "John", LastName = "Doe", Age = 42, @@ -148,7 +148,7 @@ public class SenderTestHappyPath : SenderTestBase { .FindDestinationId("99400048079000", ars: "09372126") .WithServiceType("ServiceName", "urn:de:fim:leika:leistung:99400048079000") .WithAttachments(attachments) - .WithData(JsonConvert.SerializeObject(new { + .WithJsonData(JsonConvert.SerializeObject(new { FirstName = "John", LastName = "Doe", Age = 42, diff --git a/IntegrationTests/Sender/SenderTestUnhappyPath.cs b/IntegrationTests/Sender/SenderTestUnhappyPath.cs index 6e0f9c7e4bff7d67266d6c792b87971d00d00139..e0298aec861a2b94e4125b705e1dbd55cc9d028b 100644 --- a/IntegrationTests/Sender/SenderTestUnhappyPath.cs +++ b/IntegrationTests/Sender/SenderTestUnhappyPath.cs @@ -27,7 +27,7 @@ public class SenderTestUnhappyPath : SenderTestBase { Sender.WithDestination(DestinationId) .WithServiceType("Name", "urn:de:fim:leika:leistung:00000000000000") .WithAttachments(new Attachment("Test.pdf", "Test PDF")) - .WithData("This is very wrong"); + .WithJsonData("This is very wrong"); })! .Message.Should().Be("The data must be valid JSON string"); } diff --git a/IntegrationTests/Sender/ThreadTest.cs b/IntegrationTests/Sender/ThreadTest.cs index 2588b1db76c0418696901346514e9156392bab15..962a32f28237b2d9e2a98212033db79caadfc45e 100644 --- a/IntegrationTests/Sender/ThreadTest.cs +++ b/IntegrationTests/Sender/ThreadTest.cs @@ -52,7 +52,7 @@ public class ThreadTest { Thread.Sleep(RandomNumberGenerator.GetInt32(100, 500)); delayed - .WithData(JsonConvert.SerializeObject(new { + .WithJsonData(JsonConvert.SerializeObject(new { Name = $"ThreadTest_{counter}", ThreadId = counter })) diff --git a/LICENSES/CC0-1.0.txt b/LICENSES/CC0-1.0.txt new file mode 100644 index 0000000000000000000000000000000000000000..0e259d42c996742e9e3cba14c677129b2c1b6311 --- /dev/null +++ b/LICENSES/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/LICENSES/EUPL-1.2.txt b/LICENSES/EUPL-1.2.txt new file mode 100644 index 0000000000000000000000000000000000000000..6d8cea430e21d06532225018850da91a3f44abf5 --- /dev/null +++ b/LICENSES/EUPL-1.2.txt @@ -0,0 +1,190 @@ +EUROPEAN UNION PUBLIC LICENCE v. 1.2 +EUPL © the European Union 2007, 2016 + +This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the +terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such +use is covered by a right of the copyright holder of the Work). +The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following +notice immediately following the copyright notice for the Work: + Licensed under the EUPL +or has expressed by any other means his willingness to license under the EUPL. + +1.Definitions +In this Licence, the following terms have the following meaning: +— ‘The Licence’:this Licence. +— ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available +as Source Code and also as Executable Code as the case may be. +— ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or +modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work +required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in +the country mentioned in Article 15. +— ‘The Work’:the Original Work or its Derivative Works. +— ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and +modify. +— ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by +a computer as a program. +— ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence. +— ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to +the creation of a Derivative Work. +— ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the +Licence. +— ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating, +transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential +functionalities at the disposal of any other natural or legal person. + +2.Scope of the rights granted by the Licence +The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for +the duration of copyright vested in the Original Work: +— use the Work in any circumstance and for all usage, +— reproduce the Work, +— modify the Work, and make Derivative Works based upon the Work, +— communicate to the public, including the right to make available or display the Work or copies thereof to the public +and perform publicly, as the case may be, the Work, +— distribute the Work or copies thereof, +— lend and rent the Work or copies thereof, +— sublicense rights in the Work or copies thereof. +Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the +applicable law permits so. +In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed +by law in order to make effective the licence of the economic rights here above listed. +The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the +extent necessary to make use of the rights granted on the Work under this Licence. + +3.Communication of the Source Code +The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as +Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with +each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to +the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to +distribute or communicate the Work. + +4.Limitations on copyright +Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the +exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations +thereto. + +5.Obligations of the Licensee +The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those +obligations are the following: + +Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to +the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the +Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work +to carry prominent notices stating that the Work has been modified and the date of modification. + +Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this +Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless +the Original Work is expressly distributed only under this version of the Licence — for example by communicating +‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the +Work or Derivative Work that alter or restrict the terms of the Licence. + +Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both +the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done +under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed +in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with +his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail. + +Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide +a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available +for as long as the Licensee continues to distribute or communicate the Work. +Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names +of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and +reproducing the content of the copyright notice. + +6.Chain of Authorship +The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or +licensed to him/her and that he/she has the power and authority to grant the Licence. +Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or +licensed to him/her and that he/she has the power and authority to grant the Licence. +Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions +to the Work, under the terms of this Licence. + +7.Disclaimer of Warranty +The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work +and may therefore contain defects or ‘bugs’ inherent to this type of development. +For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind +concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or +errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this +Licence. +This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work. + +8.Disclaimer of Liability +Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be +liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the +Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss +of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, +the Licensor will be liable under statutory product liability laws as far such laws apply to the Work. + +9.Additional agreements +While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services +consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole +responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by +the fact You have accepted any warranty or additional liability. + +10.Acceptance of the Licence +The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window +displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of +applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms +and conditions. +Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You +by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution +or Communication by You of the Work or copies thereof. + +11.Information to the public +In case of any Distribution or Communication of the Work by means of electronic communication by You (for example, +by offering to download the Work from a remote location) the distribution channel or media (for example, a website) +must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence +and the way it may be accessible, concluded, stored and reproduced by the Licensee. + +12.Termination of the Licence +The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms +of the Licence. +Such a termination will not terminate the licences of any person who has received the Work from the Licensee under +the Licence, provided such persons remain in full compliance with the Licence. + +13.Miscellaneous +Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the +Work. +If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or +enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid +and enforceable. +The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of +the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. +New versions of the Licence will be published with a unique version number. +All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take +advantage of the linguistic version of their choice. + +14.Jurisdiction +Without prejudice to specific agreement between parties, +— any litigation resulting from the interpretation of this License, arising between the European Union institutions, +bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice +of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union, +— any litigation arising between other parties and resulting from the interpretation of this License, will be subject to +the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business. + +15.Applicable Law +Without prejudice to specific agreement between parties, +— this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat, +resides or has his registered office, +— this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside +a European Union Member State. + + + Appendix + +‘Compatible Licences’ according to Article 5 EUPL are: +— GNU General Public License (GPL) v. 2, v. 3 +— GNU Affero General Public License (AGPL) v. 3 +— Open Software License (OSL) v. 2.1, v. 3.0 +— Eclipse Public License (EPL) v. 1.0 +— CeCILL v. 2.0, v. 2.1 +— Mozilla Public Licence (MPL) v. 2 +— GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 +— Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software +— European Union Public Licence (EUPL) v. 1.1, v. 1.2 +— Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+). + +The European Commission may update this Appendix to later versions of the above licences without producing +a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the +covered Source Code from exclusive appropriation. +All other changes or additions to this Appendix require the production of a new EUPL version. diff --git a/MockContainer/MockContainer.cs b/MockContainer/MockContainer.cs index 81f9b7f91b6a42029106470c8e250117e7e9453d..b931ee64c54aaf90075c5159d21c0a813f4aa79b 100644 --- a/MockContainer/MockContainer.cs +++ b/MockContainer/MockContainer.cs @@ -31,65 +31,107 @@ public class TestFile { public static class Container { public static IContainer Create() { var builder = new ContainerBuilder(); + var settings = CreateEncryptionSettings(builder); builder.Register(c => new TestFile()).As<TestFile>(); builder.Register(c => CreateOAuthService().Object).As<IOAuthService>(); builder.Register(c => CreateRouteService().Object).As<IRouteService>(); builder.Register(c => CreateSubmissionService().Object).As<ISubmissionService>(); - builder.Register(c => CreateDestinationService().Object).As<IDestinationService>(); + builder.Register(c => CreateDestinationService(settings).Object).As<IDestinationService>(); builder.Register(c => Mock.Of<ICasesService>()).As<ICasesService>(); builder.Register(c => LoggerFactory.Create( b => { b.AddConsole(); b.SetMinimumLevel(LogLevel.Information); - }).CreateLogger("FluentSenderTests") + }).CreateLogger("E2E Tests") ).As<ILogger>(); - CreateEncryptionSettings(builder); return builder.Build(); } - private static Mock<IDestinationService> CreateDestinationService() { + private static Mock<IDestinationService> CreateDestinationService(MockSettings settings) { var mock = new Mock<IDestinationService>(); mock.Setup(x => x.GetPublicKey(It.IsAny<string>())).Returns(() => - File.ReadAllTextAsync("./encryptionKeys/publicKey_encryption.json")); + Task.FromResult(settings.PublicKeyEncryption)); return mock; } - private static void CreateEncryptionSettings(ContainerBuilder builder) { - var privateKeyDecryption = File.ReadAllText("./encryptionKeys/privateKey_decryption.json"); - var privateKeySigning = File.ReadAllText("./encryptionKeys/privateKey_signing.json"); - var publicKeyEncryption = File.ReadAllText("./encryptionKeys/publicKey_encryption.json"); - var publicKeySignature = - File.ReadAllText("./encryptionKeys/publicKey_signature_verification.json"); - var setPublicKeys = File.ReadAllText("./encryptionKeys/set-public-keys.json"); - - var credentials = - JsonConvert.DeserializeObject<dynamic>( - File.ReadAllText("./encryptionKeys/credentials.json"))!; - - var senderClientId = (string)credentials.sender.clientId; - var senderClientSecret = (string)credentials.sender.clientSecret; - var subscriberClientId = (string)credentials.subscriber.clientId; - var subscriberClientSecret = (string)credentials.subscriber.clientSecret; - var destinationId = (string)credentials.destinationId; - var leikaKey = (string)credentials.leikaKey; - var callbackSecret = (string)credentials.callbackSecret; - - builder.Register(c => new MockSettings( + private static MockSettings? GetSettingsFromEnvironment() { + Console.WriteLine("Getting settings from environment"); + var privateKeyDecryption = + Environment.GetEnvironmentVariable("MOCK_PRIVATE_KEY_DECRYPTION")!; + var privateKeySigning = Environment.GetEnvironmentVariable("MOCK_PRIVATE_KEY_SIGNING")!; + var publicKeyEncryption = Environment.GetEnvironmentVariable("MOCK_PUBLIC_KEY_ENCRYPTION")!; + var publicKeySignature = Environment.GetEnvironmentVariable("MOCK_PUBLIC_KEY_SIGNATURE")!; + var setPublicKeys = Environment.GetEnvironmentVariable("MOCK_SET_PUBLIC_KEYS")!; + var senderClientId = Environment.GetEnvironmentVariable("MOCK_SENDER_CLIENT_ID")!; + var senderClientSecret = Environment.GetEnvironmentVariable("MOCK_SENDER_CLIENT_SECRET")!; + var subscriberClientId = Environment.GetEnvironmentVariable("MOCK_SUBSCRIBER_CLIENT_ID")!; + var subscriberClientSecret = + Environment.GetEnvironmentVariable("MOCK_SUBSCRIBER_CLIENT_SECRET")!; + var destinationId = Environment.GetEnvironmentVariable("MOCK_DESTINATION_ID")!; + var leikaKey = Environment.GetEnvironmentVariable("MOCK_LEIKA_KEY")!; + var callbackSecret = Environment.GetEnvironmentVariable("MOCK_CALLBACK_SECRET")!; + + return new MockSettings( + privateKeyDecryption, privateKeySigning, + publicKeyEncryption, publicKeySignature, + senderClientId, senderClientSecret, + subscriberClientId, subscriberClientSecret, + destinationId, leikaKey, callbackSecret, setPublicKeys); + } + + private static MockSettings? GetSettingsFromFiles() { + Console.WriteLine("Reading settings from files"); + try { + var privateKeyDecryption = + File.ReadAllText("./encryptionKeys/privateKey_decryption.json"); + var privateKeySigning = File.ReadAllText("./encryptionKeys/privateKey_signing.json"); + var publicKeyEncryption = + File.ReadAllText("./encryptionKeys/publicKey_encryption.json"); + var publicKeySignature = + File.ReadAllText("./encryptionKeys/publicKey_signature_verification.json"); + var setPublicKeys = File.ReadAllText("./encryptionKeys/set-public-keys.json"); + + var credentials = + JsonConvert.DeserializeObject<dynamic>( + File.ReadAllText("./encryptionKeys/credentials.json"))!; + + var senderClientId = (string)credentials.sender.clientId; + var senderClientSecret = (string)credentials.sender.clientSecret; + var subscriberClientId = (string)credentials.subscriber.clientId; + var subscriberClientSecret = (string)credentials.subscriber.clientSecret; + var destinationId = (string)credentials.destinationId; + var leikaKey = (string)credentials.leikaKey; + var callbackSecret = (string)credentials.callbackSecret; + + return new MockSettings( privateKeyDecryption, privateKeySigning, publicKeyEncryption, publicKeySignature, senderClientId, senderClientSecret, subscriberClientId, subscriberClientSecret, - destinationId, leikaKey, callbackSecret, setPublicKeys)) + destinationId, leikaKey, callbackSecret, setPublicKeys); + } + catch { + Console.WriteLine("Files not found, using environment variables"); + return null; + } + } + + + private static MockSettings CreateEncryptionSettings(ContainerBuilder builder) { + var settings = Environment.GetEnvironmentVariable("ENVIRONMENT_DRIVEN_TEST") == null + ? GetSettingsFromFiles() + : GetSettingsFromEnvironment(); + if (settings == null) + throw new ArgumentException("Could not find settings file nor environment variables"); + + builder.Register(c => settings) .As<MockSettings>(); - builder.Register(c => new KeySet { - PrivateKeyDecryption = privateKeyDecryption, - PrivateKeySigning = privateKeySigning, - PublicKeyEncryption = publicKeyEncryption, - PublicKeySignatureVerification = publicKeySignature - }).As<KeySet>(); + builder.Register(c => settings.ToKeySet()).As<KeySet>(); + + return settings; } private static Mock<IRouteService> CreateRouteService() { @@ -175,3 +217,14 @@ public static class Container { return submissionService; } } + +public static class MockSettingsExtensions { + public static KeySet ToKeySet(this MockSettings settings) { + return new KeySet() { + PrivateKeyDecryption = settings.PrivateKeyDecryption, + PrivateKeySigning = settings.PrivateKeySigning, + PublicKeyEncryption = settings.PublicKeyEncryption, + PublicKeySignatureVerification = settings.PublicKeySignatureVerification + }; + } +} diff --git a/install_reuse.sh b/install_reuse.sh new file mode 100755 index 0000000000000000000000000000000000000000..c10672a78718c52a932771b6071283aabbc045cc --- /dev/null +++ b/install_reuse.sh @@ -0,0 +1,12 @@ +#!/bin/zsh + +# SPDX-FileCopyrightText: 2022 2022 FIT-Connect contributors +# +# SPDX-License-Identifier: EUPL-1.2 + +brew install pipx +pipx ensurepath + +# pipx run reuse addheader --copyright='2022 FIT-Connect contributors' --license 'EUPL-1.2' --skip-unrecognised --recursive . + +pipx run reuse lint diff --git a/readme.md b/readme.md index d8d28ef326e036a932a58e9f13e963b38af8748d..be4687f084b3224d4e85a290410c43b21f4c1ca0 100644 --- a/readme.md +++ b/readme.md @@ -35,8 +35,7 @@ Das FitConnect SDK kann an die folgenden Umgebungen angeschlossen werden: - Staging: ```FitConnectEnvironment.Staging``` - Production: ```FitConnectEnvironment.Production``` - -[FIT Connect Umgebungen](https://docs.fitko.de/FIT-Connect/docs/getting-started/first-steps/#environments) +[FIT Connect Umgebungen](https://docs.fitko.de/fit-connect/docs/getting-started/first-steps/#environments) Hierfür muss der Client die Environment auswählen oder einen eigenen Environment-Parameter übergeben. @@ -53,9 +52,16 @@ flowchart LR destination(WithDestination) service(WithServiceType) attachments(WithAttachments) - data([WithData]) + data(WithData) + encAttachments(WithEncryptedAttachments) + encMetadata(WithEncryptedMetadata) + encData(WithEncryptedData) + submit([Submit]) start-->destination-->service-->attachments-->data + service-->encAttachments-->encMetadata-->encData + data-->submit + encData-->submit ``` Das SDK verhindert auf Grund der FluentAPI, dass die Methoden in der falschen Reihe aufgerufen werden können. @@ -208,10 +214,16 @@ Weißt die Submission zurück. # Router -Die Client-Implementierung der Router API +Die Client-Implementierung der Router API ```csharp Client.GetRouter(FitConnectEnvironment.Development, logger); ``` -[glossary](https://docs.fitko.de/FIT-Connect/docs/glossary/) +[glossary](https://docs.fitko.de/fit-connect/docs/glossary/) + +### License + +Source code is licensed under the [EUPL](LICENSES/EUPL-1.2.txt). + +Rechtlicher Hinweis: Dieses Software Development Kit (SDK) ist dazu bestimmt, die Anbindung einer Software an die FIT-Connect-Infrastruktur zu ermöglichen. Hierfür kann das SDK in die anzubindenden Software integriert werden. Erfolgt die Integration des SDK in unveränderter Form, liegt keine Bearbeitung im Sinne der EUPL bzw. des deutschen Urheberrechts vor. Die Art und Weise der Verlinkung des SDK führt insbesondere nicht zur Schaffung eines abgeleiteten Werkes. Die unveränderte Übernahme des SDK in eine anzubindende Software führt damit nicht dazu, dass die anzubindende Software unter den Bedingungen der EUPL zu lizenzieren ist. Für die Weitergabe des SDK selbst - in unveränderter oder bearbeiteter Form, als Quellcode oder ausführbares Programm - gelten die Lizenzbedingungen der EUPL in unveränderter Weise.