-
Notifications
You must be signed in to change notification settings - Fork 3
Archive client #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Archive client #230
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d4c5487
Legger til nytt prosjekt for Archive
manuelAlonsoPerez 0e3eb62
Nytt Arkive test prosjekt
manuelAlonsoPerez b37f3fe
Smoke mappe lagd til
manuelAlonsoPerez b8bca4f
Støtter opprettelse av ArchiveClient
manuelAlonsoPerez ce0808f
Archive client test og testhelper
manuelAlonsoPerez 335a515
Testet OK ved henting av feil dokument_id
manuelAlonsoPerez 1353fba
Testhelper fanger inner exception
manuelAlonsoPerez f9c5758
Fjerne unødvendig kode
manuelAlonsoPerez b19c3a7
Ny DocumentOwner
manuelAlonsoPerez 4b64159
Nytt ArchiveDocumentId object
manuelAlonsoPerez a0bbfba
Test helper instanser sine variabler
manuelAlonsoPerez 7ab3608
Add .vscode folder to gitignore
runeflobakk 6dc23bf
Rename ArchiveDocumentOwner.cs to DocumentOwner.cs
runeflobakk c643056
Rename ArchiveDocument to ArchivedDocumentId
runeflobakk 999f15b
Change scope of method to private
runeflobakk bb61f9a
Add whitespace
runeflobakk 9c62ec1
Remove Console.WriteLine
runeflobakk 5d6f29a
Fail test if it does not throw when expected to
runeflobakk 385548b
Upgrade some test dependencies
runeflobakk 544e12b
Upgrade Logging, DependencyInjection
runeflobakk 9a36aa0
Change interdependencies version to 6.*
runeflobakk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -196,6 +196,7 @@ FakesAssemblies/ | |
| *.opt | ||
|
|
||
| .idea | ||
| .vscode | ||
|
|
||
| ####################### | ||
| # Ignore certificates # | ||
|
|
||
18 changes: 18 additions & 0 deletions
18
...ost.Signature.Api.Client.Archive.Tests/Digipost.Signature.Api.Client.Archive.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" /> | ||
| <PackageReference Include="xunit" Version="2.4.1" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Digipost.Signature.Api.Client.Archive\Digipost.Signature.Api.Client.Archive.csproj" /> | ||
| <ProjectReference Include="..\Digipost.Signature.Api.Client.Core.Tests\Digipost.Signature.Api.Client.Core.Tests.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
52 changes: 52 additions & 0 deletions
52
Digipost.Signature.Api.Client.Archive.Tests/Smoke/ArchiveSmokeTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| using Digipost.Signature.Api.Client.Core; | ||
| using Digipost.Signature.Api.Client.Core.Tests.Smoke; | ||
| using Digipost.Signature.Api.Client.Core.Utilities; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Microsoft.Extensions.Logging; | ||
| using Xunit; | ||
| using static Digipost.Signature.Api.Client.Core.Tests.Utilities.CoreDomainUtility; | ||
|
|
||
|
|
||
| namespace Digipost.Signature.Api.Client.Archive.Tests.Smoke | ||
| { | ||
| public class ArchiveSmokeTestsFixture : SmokeTests | ||
| { | ||
| public ArchiveSmokeTestsFixture() | ||
| { | ||
| TestHelper = new TestHelper(ArchiveClient(Endpoint)); | ||
| } | ||
|
|
||
| public TestHelper TestHelper { get; } | ||
|
|
||
| private static ArchiveClient ArchiveClient(Environment environment) | ||
| { | ||
| var serviceProvider = LoggingUtility.CreateServiceProviderAndSetUpLogging(); | ||
|
|
||
| var clientConfig = new ClientConfiguration(environment, GetBringCertificate(), new Sender(BringPublicOrganizationNumber)) | ||
| { | ||
| LogRequestAndResponse = true | ||
| }; | ||
| var client = new ArchiveClient(clientConfig, serviceProvider.GetService<ILoggerFactory>()); | ||
|
|
||
| return client; | ||
| } | ||
| } | ||
|
|
||
| public class ArchiveClientSmokeTests : IClassFixture<ArchiveSmokeTestsFixture> | ||
| { | ||
| public ArchiveClientSmokeTests(ArchiveSmokeTestsFixture fixture) | ||
| { | ||
| _fixture = fixture; | ||
| } | ||
|
|
||
| private readonly ArchiveSmokeTestsFixture _fixture; | ||
|
|
||
| [Fact] | ||
| public void download_pades_and_expect_error() | ||
| { | ||
| _fixture.TestHelper | ||
| .Download_pades_and_expect_client_error(); | ||
| } | ||
| } | ||
|
|
||
| } | ||
36 changes: 36 additions & 0 deletions
36
Digipost.Signature.Api.Client.Archive.Tests/Smoke/TestHelper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using System; | ||
| using Digipost.Signature.Api.Client.Core.Exceptions; | ||
| using Digipost.Signature.Api.Client.Core.Tests.Smoke; | ||
| using Xunit; | ||
|
|
||
| namespace Digipost.Signature.Api.Client.Archive.Tests.Smoke | ||
| { | ||
| public class TestHelper : TestHelperBase | ||
| { | ||
| private readonly ArchiveClient _archiveClient; | ||
| private readonly DocumentOwner _documentOwner; | ||
| private readonly ArchivedDocumentId _document; | ||
|
|
||
| public TestHelper(ArchiveClient archiveClient) | ||
manuelAlonsoPerez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| _archiveClient = archiveClient; | ||
| _documentOwner = new DocumentOwner(_archiveClient.ClientConfiguration.GlobalSender.OrganizationNumber); | ||
| _document = new ArchivedDocumentId("1234"); | ||
| } | ||
|
|
||
| public TestHelper Get_PAdES() | ||
| { | ||
| var pades = _archiveClient.GetPades(_documentOwner, _document).Result; | ||
| Assert.True(pades.CanRead); | ||
| return this; | ||
| } | ||
|
|
||
| public void Download_pades_and_expect_client_error() | ||
| { | ||
| var thrown = Assert.Throws<AggregateException>(() => Get_PAdES()); | ||
| var actualError = Assert.IsType<UnexpectedResponseException>(thrown.InnerException); | ||
| Assert.Equal("ARCHIVED_DOCUMENT_NOT_FOUND", actualError.Error.Code); | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| using System; | ||
| using System.IO; | ||
| using System.Threading.Tasks; | ||
| using Digipost.Signature.Api.Client.Core; | ||
| using Microsoft.Extensions.Logging; | ||
| using Microsoft.Extensions.Logging.Abstractions; | ||
|
|
||
| namespace Digipost.Signature.Api.Client.Archive | ||
| { | ||
| public class ArchiveClient : BaseClient | ||
| { | ||
| private readonly ILogger<BaseClient> _logger; | ||
|
|
||
| public ArchiveClient(ClientConfiguration clientConfiguration) | ||
| : this(clientConfiguration, new NullLoggerFactory()) | ||
| { | ||
| } | ||
|
|
||
| public ArchiveClient(ClientConfiguration clientConfiguration, ILoggerFactory loggerFactory) | ||
| : base(clientConfiguration, loggerFactory) | ||
| { | ||
| _logger = loggerFactory.CreateLogger<ArchiveClient>(); | ||
| } | ||
|
|
||
| public async Task<Stream> GetPades(DocumentOwner owner, ArchivedDocumentId id) | ||
| { | ||
| var uri = new Uri($"{ClientConfiguration.Environment.Url}api/{owner.OrganizationNumber}/archive/documents/{id.Value}/pades"); | ||
| return await RequestHelper.GetStream(uri).ConfigureAwait(false); | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
Digipost.Signature.Api.Client.Archive/ArchivedDocumentId.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| namespace Digipost.Signature.Api.Client.Archive | ||
| { | ||
| public class ArchivedDocumentId | ||
| { | ||
| public ArchivedDocumentId(string documentId) | ||
| { | ||
| Value = documentId; | ||
| } | ||
| public string Value { get; } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
Digipost.Signature.Api.Client.Archive/Digipost.Signature.Api.Client.Archive.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <Title>Digipost Signature Api Client Archive</Title> | ||
| <PackageId>Digipost.Signature.Api.Client.Archive</PackageId> | ||
| </PropertyGroup> | ||
|
|
||
|
|
||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.*" /> | ||
| <PackageReference Include="System.Net.Requests" Version="4.*" /> | ||
|
|
||
| <PackageReference Include="Digipost.Signature.Api.Client.Core" Version="6.*" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Digipost.Signature.Api.Client.Core\Digipost.Signature.Api.Client.Core.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| namespace Digipost.Signature.Api.Client.Archive | ||
| { | ||
| public class DocumentOwner | ||
| { | ||
| public DocumentOwner(string organizationNumber) | ||
| { | ||
| OrganizationNumber = organizationNumber; | ||
| } | ||
|
|
||
| public string OrganizationNumber { get; } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Digipost.Signature.Api.Client.Core.Tests/Properties/ProjectAssemblyInfo.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| using System.Reflection; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| [assembly: ComVisible(false)] | ||
| [assembly: InternalsVisibleTo("Digipost.Signature.Api.Client.Archive.Tests")] | ||
| [assembly: InternalsVisibleTo("Digipost.Signature.Api.Client.Direct.Tests")] | ||
| [assembly: InternalsVisibleTo("Digipost.Signature.Api.Client.Portal.Tests")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
Digipost.Signature.Api.Client.Direct.Tests/Digipost.Signature.Api.Client.Direct.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Digipost.Signature.Api.Client.Docs/Digipost.Signature.Api.Client.Docs.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
Digipost.Signature.Api.Client.Portal.Tests/Digipost.Signature.Api.Client.Portal.Tests.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
Digipost.Signature.Api.Client.Program/Digipost.Signature.Api.Client.Program.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.