Skip to content
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

CanCreate returns true even though peer is in status ToBeDeleted #871

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ Feature: GET /Relationships/CanCreate
When i1 sends a GET request to the /Relationships/CanCreate?peer={id} endpoint with id=i2.id
Then the response status code is 200 (OK)
And a Relationship can be established

Scenario: Cannot create Relationship if peer is to be deleted
Given Identities i1 and i2
And i2 is in status "ToBeDeleted"
When i1 sends a GET request to the /Relationships/CanCreate?peer={id} endpoint with id=i2.id
Then the response status code is 200 (OK)
And a Relationship can not be established
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,14 @@ public async Task<IActionResult> DecomposeRelationship([FromRoute] string id, Ca
[HttpGet("CanCreate")]
[ProducesResponseType(typeof(HttpResponseEnvelopeResult<CanEstablishRelationshipResponse>), StatusCodes.Status200OK)]
[ProducesError(StatusCodes.Status400BadRequest)]
public async Task<IActionResult> CanEstablishRelationship([FromQuery] string peer, CancellationToken cancellationToken)
public async Task<IActionResult> CanEstablishRelationship([FromQuery(Name = "peer")] string peerAddress, CancellationToken cancellationToken)
{
var response = await _mediator.Send(new CanEstablishRelationshipQuery { PeerAddress = peer }, cancellationToken);
var peerIdentity = await _mediator.Send(new GetIdentityQuery(peerAddress), cancellationToken);

var response = peerIdentity.Status is IdentityStatus.ToBeDeleted
? new CanEstablishRelationshipResponse { CanCreate = false }
: await _mediator.Send(new CanEstablishRelationshipQuery { PeerAddress = peerAddress }, cancellationToken);

return Ok(response);
}

Expand Down
Loading