diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
new file mode 100644
index 00000000..c54ea902
--- /dev/null
+++ b/.github/workflows/dotnet.yml
@@ -0,0 +1,31 @@
+# This workflow will build a .NET project
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
+
+name: .NET
+
+on:
+ pull_request:
+ branches:
+ - "devel"
+ - "qa"
+ - "master"
+ - "main"
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v3
+ with:
+ dotnet-version: 6.0.x
+ - name: Restore dependencies
+ run: dotnet restore
+ working-directory: aspnetcore/
+ - name: Build
+ run: dotnet build --no-restore
+ working-directory: aspnetcore/
+ - name: Test
+ run: dotnet test --no-build --verbosity normal
+ working-directory: aspnetcore/
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 21d9bcaf..c53857d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -194,6 +194,8 @@ PublishScripts/
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
+# except custom packages
+!**/custom_nuget/*
# Microsoft Azure Build Output
csx/
diff --git a/aspnetcore/custom_nuget/Serilog.Formatting.OpenSearch.1.0.0.nupkg b/aspnetcore/custom_nuget/Serilog.Formatting.OpenSearch.1.0.0.nupkg
new file mode 100644
index 00000000..2fd1c7bb
Binary files /dev/null and b/aspnetcore/custom_nuget/Serilog.Formatting.OpenSearch.1.0.0.nupkg differ
diff --git a/aspnetcore/custom_nuget/Serilog.Sinks.OpenSearch.1.0.0.nupkg b/aspnetcore/custom_nuget/Serilog.Sinks.OpenSearch.1.0.0.nupkg
new file mode 100644
index 00000000..ad29bc0e
Binary files /dev/null and b/aspnetcore/custom_nuget/Serilog.Sinks.OpenSearch.1.0.0.nupkg differ
diff --git a/aspnetcore/nuget.config b/aspnetcore/nuget.config
new file mode 100644
index 00000000..cd211a0a
--- /dev/null
+++ b/aspnetcore/nuget.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/aspnetcore/openshift/api/Dockerfile b/aspnetcore/openshift/api/Dockerfile
index 55a3224d..919ef756 100644
--- a/aspnetcore/openshift/api/Dockerfile
+++ b/aspnetcore/openshift/api/Dockerfile
@@ -2,6 +2,8 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
+COPY aspnetcore/custom_nuget/ /app/custom_nuget
+COPY aspnetcore/nuget.config ./
COPY aspnetcore/src/api/api.csproj ./
RUN dotnet restore
# Copy everything else and build
diff --git a/aspnetcore/src/api.Tests/Infrastructure/orcidSandbox_0000-0002-9227-8514_record.json b/aspnetcore/src/api.Tests/Infrastructure/orcidSandbox_0000-0002-9227-8514_record.json
index 655c03e7..c59f9d41 100644
--- a/aspnetcore/src/api.Tests/Infrastructure/orcidSandbox_0000-0002-9227-8514_record.json
+++ b/aspnetcore/src/api.Tests/Infrastructure/orcidSandbox_0000-0002-9227-8514_record.json
@@ -2461,17 +2461,7 @@
},
"url": null,
"type": "journal-article C",
- "publication-date": {
- "year": {
- "value": "2012"
- },
- "month": {
- "value": "10"
- },
- "day": {
- "value": "01"
- }
- },
+ "publication-date": null,
"journal-title": {
"value": "Learned Publishing"
},
diff --git a/aspnetcore/src/api.Tests/Services_Tests/DuplicateHandlerServiceTest.cs b/aspnetcore/src/api.Tests/Services_Tests/DuplicateHandlerServiceTest.cs
index f885080d..b9d4fbb7 100644
--- a/aspnetcore/src/api.Tests/Services_Tests/DuplicateHandlerServiceTest.cs
+++ b/aspnetcore/src/api.Tests/Services_Tests/DuplicateHandlerServiceTest.cs
@@ -283,13 +283,13 @@ public void addPublicationToProfileEditorData_020()
{
Id = 1,
RegisteredDataSource = "Virta",
- Organization = new Organization() {}
+ Organization = new Organization() { }
};
ProfileEditorSource profileEditorSourceOrcid = new()
{
Id = 2,
RegisteredDataSource = "ORCID",
- Organization = new Organization() {}
+ Organization = new Organization() { }
};
// Create ProfileDataRaw for Virta publication 1
@@ -351,5 +351,21 @@ public void addPublicationToProfileEditorData_020()
// Check that publication list contains two publications
Assert.Equal(2, publications3.Count);
}
+
+
+ [Fact(DisplayName = "TestPublicationYearHandling")]
+ public void testPublicationYearHandling()
+ {
+ DuplicateHandlerService duplicateHandlerService = new();
+
+ // Valid publication year
+ Assert.Equal(2022, duplicateHandlerService.HandlePublicationYear(2022));
+ // Publication year 0
+ Assert.Null(duplicateHandlerService.HandlePublicationYear(0));
+ // Publication year negative
+ Assert.Null(duplicateHandlerService.HandlePublicationYear(-1));
+ // Publication year null
+ Assert.Null(duplicateHandlerService.HandlePublicationYear(null));
+ }
}
}
\ No newline at end of file
diff --git a/aspnetcore/src/api.Tests/Services_Tests/OrcidApiServicetest.cs b/aspnetcore/src/api.Tests/Services_Tests/OrcidApiServicetest.cs
new file mode 100644
index 00000000..e44c639b
--- /dev/null
+++ b/aspnetcore/src/api.Tests/Services_Tests/OrcidApiServicetest.cs
@@ -0,0 +1,190 @@
+using Xunit;
+using Moq;
+using api.Services;
+using Microsoft.Extensions.Configuration;
+using System.Collections.Generic;
+using static System.Net.WebRequestMethods;
+using System.Security.Cryptography;
+using System.Collections;
+
+namespace api.Tests
+{
+ [Collection("ORCID api service tests")]
+ public class OrcidApiServiceTests
+ {
+ /*
+ * Helper method for setting up IConfiguration
+ */
+ public IConfiguration CreateTestConfiguration()
+ {
+ Dictionary inMemorySettings = new Dictionary {
+ { "SERVICEURL", "https://mydata-api.service.example.fi"},
+ { "ORCID:WEBHOOK:ENABLED", "true"},
+ { "ORCID:WEBHOOK:API", "https://api.sandbox.orcid.org/"},
+ { "ORCID:WEBHOOK:ACCESSTOKEN", "fake20e90b06-0384f05d-3ffc9bd9-31ab06ff" }
+ };
+ IConfiguration testConfiguration = new ConfigurationBuilder()
+ .AddInMemoryCollection(inMemorySettings)
+ .Build();
+ return testConfiguration;
+ }
+
+ /*
+ * Create test data for unit test IsOrcidWebhookEnabled_ReturnsIsOrcidWebhookFeatureEnabled
+ */
+ public class IsOrcidWebhookEnabledTestData : IEnumerable