-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consumer API: Prevent creation and updates to relationships where pee…
…r is in status "ToBeDeleted" (#695) * feat: prevent relationship commands with identities to be deleted * test: add relationship integration tests * fix: formatting * refactor: rename test scenarios * refactor: add mediatr query to retrieve relationship peer address * test: adjust step definitions * refactor: rename validation method * refactor: use GetPeerOfActiveIdentityInRelationshipResponse type and adjust integration tests --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
292fa08
commit 42846a7
Showing
13 changed files
with
418 additions
and
58 deletions.
There are no files selected for viewing
This file contains 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
104 changes: 52 additions & 52 deletions
104
ConsumerApi.Tests.Integration/ConsumerApi.Tests.Integration.csproj
This file contains 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,58 +1,58 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.6" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" /> | ||
<PackageReference Include="Newtonsoft.Json.Schema" Version="4.0.1" /> | ||
<PackageReference Include="NJsonSchema.NewtonsoftJson" Version="11.0.1" /> | ||
<PackageReference Include="ReHackt.Extensions.Options.Validation" Version="8.0.2" /> | ||
<PackageReference Include="SolidToken.SpecFlow.DependencyInjection" Version="3.9.3" /> | ||
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" /> | ||
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" /> | ||
<PackageReference Include="nunit" Version="4.1.0" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" /> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.6"/> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/> | ||
<PackageReference Include="Newtonsoft.Json.Schema" Version="4.0.1"/> | ||
<PackageReference Include="NJsonSchema.NewtonsoftJson" Version="11.0.1" /> | ||
<PackageReference Include="ReHackt.Extensions.Options.Validation" Version="8.0.2" /> | ||
<PackageReference Include="SolidToken.SpecFlow.DependencyInjection" Version="3.9.3" /> | ||
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" /> | ||
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" /> | ||
<PackageReference Include="nunit" Version="4.1.0" /> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" /> | ||
<PackageReference Include="FluentAssertions" Version="6.12.0" /> | ||
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\BuildingBlocks\src\Crypto\Crypto.csproj" /> | ||
<ProjectReference Include="..\ConsumerApi.Sdk\ConsumerApi.Sdk.csproj" /> | ||
<ProjectReference Include="..\ConsumerApi\ConsumerApi.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BuildingBlocks\src\Crypto\Crypto.csproj" /> | ||
<ProjectReference Include="..\ConsumerApi.Sdk\ConsumerApi.Sdk.csproj" /> | ||
<ProjectReference Include="..\ConsumerApi\ConsumerApi.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Update="api.appsettings.local.override.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="specflow.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Update="api.appsettings.local.override.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="appsettings.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Update="specflow.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<SpecFlowFeatureFiles Update="Features\Challenges\POST.feature"> | ||
<Visible>$(UsingMicrosoftNETSdk)</Visible> | ||
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile> | ||
</SpecFlowFeatureFiles> | ||
<SpecFlowFeatureFiles Update="Features\Challenges\{id}\GET.feature"> | ||
<Visible>$(UsingMicrosoftNETSdk)</Visible> | ||
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile> | ||
</SpecFlowFeatureFiles> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<SpecFlowFeatureFiles Update="Features\Challenges\POST.feature"> | ||
<Visible>$(UsingMicrosoftNETSdk)</Visible> | ||
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile> | ||
</SpecFlowFeatureFiles> | ||
<SpecFlowFeatureFiles Update="Features\Challenges\{id}\GET.feature"> | ||
<Visible>$(UsingMicrosoftNETSdk)</Visible> | ||
<CodeBehindFile>%(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension)</CodeBehindFile> | ||
</SpecFlowFeatureFiles> | ||
</ItemGroup> | ||
</Project> |
64 changes: 64 additions & 0 deletions
64
ConsumerApi.Tests.Integration/Features/Relationships/POST.feature
This file contains 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,64 @@ | ||
@Integration | ||
Feature: POST Relationship | ||
|
||
User creates a Relationship | ||
|
||
Scenario: Creating a Relationship | ||
Given Identities i1 and i2 | ||
And a Relationship Template rt created by i2 | ||
When a POST request is sent to the /Relationships endpoint by i1 with rt.id | ||
Then the response status code is 201 (Created) | ||
And the response contains a Relationship | ||
|
||
Scenario: Creating a Relationship to an Identity in status "ToBeDeleted" | ||
Given Identities i1 and i2 | ||
And a Relationship Template rt created by i2 | ||
And i2 is in status "ToBeDeleted" | ||
When a POST request is sent to the /Relationships endpoint by i1 with rt.id | ||
Then the response status code is 400 (Bad Request) | ||
And the response content contains an error with the error code "error.platform.validation.relationship.peerIsToBeDeleted" | ||
|
||
Scenario: Accept Relationship Change | ||
Given Identities i1 and i2 | ||
And a pending Relationship between i1 and i2 created by i2 | ||
When a POST request is sent to the /Relationships/{r.Id}/Changes/{r.Changes.Id}/Accept endpoint by i1 | ||
Then the response status code is 200 (OK) | ||
And the response contains an AcceptRelationshipChangeResponse | ||
|
||
Scenario: Accept Relationship Change to an Identity in status "ToBeDeleted" | ||
Given Identities i1 and i2 | ||
And a pending Relationship between i1 and i2 created by i2 | ||
And i2 is in status "ToBeDeleted" | ||
When a POST request is sent to the /Relationships/{r.Id}/Changes/{r.Changes.Id}/Accept endpoint by i1 | ||
Then the response status code is 400 (Bad Request) | ||
And the response content contains an error with the error code "error.platform.validation.relationship.peerIsToBeDeleted" | ||
|
||
Scenario: Reject Relationship Change | ||
Given Identities i1 and i2 | ||
And a pending Relationship between i1 and i2 created by i2 | ||
When a POST request is sent to the /Relationships/{r.Id}/Changes/{r.Changes.Id}/Reject endpoint by i1 | ||
Then the response status code is 200 (OK) | ||
And the response contains an RejectRelationshipChangeResponse | ||
|
||
Scenario: Reject Relationship Change to an Identity in status "ToBeDeleted" | ||
Given Identities i1 and i2 | ||
And a pending Relationship between i1 and i2 created by i2 | ||
And i2 is in status "ToBeDeleted" | ||
When a POST request is sent to the /Relationships/{r.Id}/Changes/{r.Changes.Id}/Reject endpoint by i1 | ||
Then the response status code is 400 (Bad Request) | ||
And the response content contains an error with the error code "error.platform.validation.relationship.peerIsToBeDeleted" | ||
|
||
Scenario: Revoke Relationship Change | ||
Given Identities i1 and i2 | ||
And a pending Relationship between i1 and i2 created by i1 | ||
When a POST request is sent to the /Relationships/{r.Id}/Changes/{r.Changes.Id}/Revoke endpoint by i1 | ||
Then the response status code is 200 (OK) | ||
And the response contains an RevokeRelationshipChangeResponse | ||
|
||
Scenario: Revoke Relationship Change to an Identity in status "ToBeDeleted" | ||
Given Identities i1 and i2 | ||
And a pending Relationship between i1 and i2 created by i1 | ||
And i2 is in status "ToBeDeleted" | ||
When a POST request is sent to the /Relationships/{r.Id}/Changes/{r.Changes.Id}/Revoke endpoint by i1 | ||
Then the response status code is 400 (Bad Request) | ||
And the response content contains an error with the error code "error.platform.validation.relationship.peerIsToBeDeleted" |
This file contains 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
Oops, something went wrong.