Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Merge pull request #183 from difi/StoppSendingMotFeilMlijo
Browse files Browse the repository at this point in the history
Stopp sending mot feil mlijø
  • Loading branch information
asjafjell authored Sep 28, 2016
2 parents c7ca4ef + 8db5310 commit 4974c7b
Show file tree
Hide file tree
Showing 24 changed files with 374 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@
<AssemblyOriginatorKeyFile>C:\Keys\digipost.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="ApiClientShared, Version=1.0.5941.27271, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\api-client-shared.1.0.5941.27271\lib\net45\ApiClientShared.dll</HintPath>
<Reference Include="ApiClientShared, Version=1.0.5968.19413, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\api-client-shared.1.0.5968.19413\lib\net45\ApiClientShared.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Difi.Felles.Utility, Version=0.8.0.27738, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\difi-felles-utility-dotnet.0.8.0.27738\lib\net45\Difi.Felles.Utility.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down Expand Up @@ -107,6 +111,7 @@
<Compile Include="Exceptions\XmlParseException.cs" />
<Compile Include="Exceptions\XmlValidationException.cs" />
<Compile Include="Extensions\DateTimeExtensions.cs" />
<Compile Include="Extensions\EnumExtensions.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Extensions\XmlElementExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public XmlValidationException(string message)

}

public XmlValidationException()
{

}

public List<string> ValidationMessages { get; private set; }
}
}
24 changes: 24 additions & 0 deletions Difi.SikkerDigitalPost.Klient.Domene/Extensions/EnumExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using Difi.Felles.Utility;

namespace Difi.SikkerDigitalPost.Klient.Domene.Extensions
{
internal static class EnumExtensions
{
public static string ToNorwegianString(this CertificateValidationType certificateValidationType)
{
switch (certificateValidationType)
{
case CertificateValidationType.Valid:
return "Gyldig";
case CertificateValidationType.InvalidCertificate:
return "UgyldigSertifikat";
case CertificateValidationType.InvalidChain:
return "UgyldigKjede";
default:
throw new ArgumentOutOfRangeException(nameof(certificateValidationType), certificateValidationType, null);
}
}

}
}
3 changes: 2 additions & 1 deletion Difi.SikkerDigitalPost.Klient.Domene/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="api-client-shared" version="1.0.5941.27271" targetFramework="net45" />
<package id="api-client-shared" version="1.0.5968.19413" targetFramework="net45" />
<package id="difi-felles-utility-dotnet" version="0.8.0.27738" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<AssemblyOriginatorKeyFile>C:\Keys\digipost.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="ApiClientShared, Version=1.0.5941.27271, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\api-client-shared.1.0.5941.27271\lib\net45\ApiClientShared.dll</HintPath>
<Reference Include="ApiClientShared, Version=1.0.5968.19413, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\api-client-shared.1.0.5968.19413\lib\net45\ApiClientShared.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand Down
2 changes: 1 addition & 1 deletion Difi.SikkerDigitalPost.Klient.Resources/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="api-client-shared" version="1.0.5941.27271" targetFramework="net45" />
<package id="api-client-shared" version="1.0.5968.19413" targetFramework="net45" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Difi.Felles.Utility.Exceptions;
using Difi.SikkerDigitalPost.Klient.Api;
using Difi.SikkerDigitalPost.Klient.Domene.Entiteter;
using Difi.SikkerDigitalPost.Klient.Domene.Entiteter.Aktører;
Expand All @@ -24,10 +25,10 @@ public class SikkerDigitalPostKlientTests
public class ConstructorMethod : SikkerDigitalPostKlientTests
{
[Fact]
public void InitializesFields()
public void Initializes_fields()
{
//Arrange
var databehandler = new Databehandler(new Organisasjonsnummer("999999999"), DomainUtility.GetAvsenderCertificate());
var databehandler = new Databehandler(new Organisasjonsnummer("988015814"), DomainUtility.GetAvsenderCertificate());
var klientkonfigurasjon = new Klientkonfigurasjon(Miljø.FunksjoneltTestmiljø);

//Act
Expand All @@ -38,12 +39,23 @@ public void InitializesFields()
Assert.Equal(databehandler, sikkerDigitalPostKlient.Databehandler);
Assert.IsType<RequestHelper>(sikkerDigitalPostKlient.RequestHelper);
}

[Fact]
public void Fails_if_invalid_certificate()
{
//Arrange
var databehandler = new Databehandler(new Organisasjonsnummer("988015814"), DomainUtility.GetAvsenderEnhetstesterSertifikat());
var klientkonfigurasjon = new Klientkonfigurasjon(Miljø.FunksjoneltTestmiljø);

//Act
Assert.Throws<SecurityException>(()=> new SikkerDigitalPostKlient(databehandler, klientkonfigurasjon));
}
}

public class SendMethod : SikkerDigitalPostKlientTests
{
[Fact]
public async Task SuccessfullyReturnsTransportErrorReceipt()
public async Task Returns_transport_error_receipt()
{
//Arrange
var sikkerDigitalPostKlient = DomainUtility.GetSikkerDigitalPostKlientQaOffentlig();
Expand All @@ -59,7 +71,7 @@ public async Task SuccessfullyReturnsTransportErrorReceipt()
}

[Fact]
public async Task SuccessfullyCallsAllDokumentpakkeProsessors()
public async Task Calls_all_dokumentpakke_prosessors()
{
//Arrange
var klientkonfigurasjon = new Klientkonfigurasjon(Miljø.FunksjoneltTestmiljø)
Expand Down Expand Up @@ -100,7 +112,7 @@ public async Task SuccessfullyCallsAllDokumentpakkeProsessors()
}

[Fact]
public async Task ThrowsExceptionOnResponseNotMatchingRequest()
public async Task Throws_exception_on_response_not_matching_request()
{
//Arrange
var sikkerDigitalPostKlient = DomainUtility.GetSikkerDigitalPostKlientQaOffentlig();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -46,8 +45,8 @@
<AssemblyOriginatorKeyFile>C:\Keys\digipost.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="ApiClientShared, Version=1.0.5941.27271, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\api-client-shared.1.0.5941.27271\lib\net45\ApiClientShared.dll</HintPath>
<Reference Include="ApiClientShared, Version=1.0.5968.19413, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\api-client-shared.1.0.5968.19413\lib\net45\ApiClientShared.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
Expand All @@ -58,12 +57,12 @@
<HintPath>..\packages\Common.Logging.Core.3.3.1\lib\net40\Common.Logging.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Difi.Felles.Utility, Version=0.6.6008.19059, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\difi-felles-utility-dotnet.0.6.6008.19059\lib\net45\Difi.Felles.Utility.dll</HintPath>
<Reference Include="Difi.Felles.Utility, Version=0.8.0.27738, Culture=neutral, PublicKeyToken=683b8efceae684a6, processorArchitecture=MSIL">
<HintPath>..\packages\difi-felles-utility-dotnet.0.8.0.27738\lib\net45\Difi.Felles.Utility.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="KellermanSoftware.Compare-NET-Objects, Version=3.3.0.0, Culture=neutral, PublicKeyToken=d970ace04cc85217, processorArchitecture=MSIL">
<HintPath>..\packages\CompareNETObjects.3.03.0.0\lib\net45\KellermanSoftware.Compare-NET-Objects.dll</HintPath>
<Reference Include="KellermanSoftware.Compare-NET-Objects, Version=3.5.0.0, Culture=neutral, PublicKeyToken=d970ace04cc85217, processorArchitecture=MSIL">
<HintPath>..\packages\CompareNETObjects.3.05.0.0\lib\net45\KellermanSoftware.Compare-NET-Objects.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
Expand All @@ -77,12 +76,16 @@
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
<Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
Expand Down Expand Up @@ -121,6 +124,7 @@
<Compile Include="Entiteter\Kvitteringer\Transport\TransportOkKvitteringTests.cs" />
<Compile Include="Entiteter\Post\ForsendelseTester.cs" />
<Compile Include="Entiteter\Post\ForsendelseTests.cs" />
<Compile Include="Extensions\EnumExtensionsTests.cs" />
<Compile Include="Exceptions\XmlValidationExceptionTests.cs" />
<Compile Include="Fakes\FakeHttpClientHandler.cs" />
<Compile Include="Fakes\FakeHttpClientHandlerResponse.cs" />
Expand All @@ -132,6 +136,8 @@
<Compile Include="KvitteringFactoryTester.cs" />
<Compile Include="KvitteringsparserTester.cs" />
<Compile Include="LagreDokumentpakkeTilDiskProsessorTests.cs" />
<Compile Include="SmokeTests.cs" />
<Compile Include="SmokeTestsHelper.cs" />
<Compile Include="testdata\meldinger\KvitteringsRespons.cs" />
<Compile Include="testdata\meldinger\Kvitteringsforespørsel.cs" />
<Compile Include="testdata\meldinger\TransportKvittering.cs" />
Expand All @@ -147,7 +153,6 @@
<Compile Include="ManifestTester.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DokumentpakkeTests.cs" />
<Compile Include="SmokeTester.cs" />
<Compile Include="SertifikatTester.cs" />
<Compile Include="XmlValidering\ResponseValidatorTests.cs" />
<Compile Include="XmlValidering\MiljøTester.cs" />
Expand Down Expand Up @@ -240,12 +245,6 @@
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Linq;
using Difi.Felles.Utility;
using Xunit;
using Difi.SikkerDigitalPost.Klient.Domene.Extensions;

namespace Difi.SikkerDigitalPost.Klient.Tester.Extensions
{
public class EnumExtensionsTests
{
public class ToNorwegianStringMethod
{
[Fact]
public void Converts_all_enum_values()
{
var certificateValidationTypes = Enum.GetValues(typeof(CertificateValidationType)).Cast<CertificateValidationType>();

foreach (var certificateValidationType in certificateValidationTypes)
{
certificateValidationType.ToNorwegianString();
}
}
}

}
}
Loading

0 comments on commit 4974c7b

Please sign in to comment.