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

Delete unnecessary handler tests #795

Merged
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f6d7255
chore: remove challenges module unnecessary handler tests
daniel-almeida-konkconsulting Aug 6, 2024
45fb6e5
refactor: remove unnecessary unit tests for handlers
daniel-almeida-konkconsulting Aug 7, 2024
c8f62be
test: integration tests for missing test cases
daniel-almeida-konkconsulting Aug 7, 2024
6ed3002
refactor: remove redundant handler tests
daniel-almeida-konkconsulting Aug 7, 2024
a120e3e
chore: add comment for missing integration tests
daniel-almeida-konkconsulting Aug 7, 2024
28777ad
refactor: remove redundant handler tests
daniel-almeida-konkconsulting Aug 7, 2024
0eea397
chore: add comments for missing integration tests
daniel-almeida-konkconsulting Aug 7, 2024
9f12d94
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
daniel-almeida-konkconsulting Aug 7, 2024
6fe28b1
test: Add metric statuses update unit test
daniel-almeida-konkconsulting Aug 8, 2024
9a2bca0
test: add integration tests for missing scenarios
daniel-almeida-konkconsulting Aug 8, 2024
e6458b9
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 9, 2024
c710583
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 9, 2024
5fb41ff
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 9, 2024
7b868d3
fix: add missing byte array converter
daniel-almeida-konkconsulting Aug 12, 2024
4fd5851
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 13, 2024
5435758
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 13, 2024
0906ad7
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
daniel-almeida-konkconsulting Aug 13, 2024
471bf2d
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 13, 2024
fb139ff
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
daniel-almeida-konkconsulting Aug 14, 2024
b661ec9
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 16, 2024
e553547
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 18, 2024
1739460
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 22, 2024
5400161
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 23, 2024
84ec759
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 24, 2024
b4fa0c4
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 26, 2024
2aba923
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 26, 2024
415303f
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 26, 2024
2024a59
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 26, 2024
819ecb4
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 27, 2024
5e16646
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 27, 2024
6108e56
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 27, 2024
3911720
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 27, 2024
26dac62
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 27, 2024
4f39b51
fix: use valid identity address, albeit a non existent one, to avoid …
daniel-almeida-konkconsulting Aug 28, 2024
972bb22
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 29, 2024
b4a5d0f
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 29, 2024
12dbf57
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 30, 2024
81a471f
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 30, 2024
4f377e6
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 30, 2024
0fe9b04
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 30, 2024
cabb484
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Aug 30, 2024
540e273
refactor: minor changes after code review
daniel-almeida-konkconsulting Aug 30, 2024
85e8647
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Sep 2, 2024
699f407
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Sep 2, 2024
61f75f8
Merge branch 'main' into NMSHDB-183-delete-unnecessary-handler-tests
mergify[bot] Sep 2, 2024
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 @@ -23,7 +23,7 @@ Scenario: Changing the default tier of an existing Client with a non-existent ti
Then the response status code is 400 (Bad request)
And the response content contains an error with the error code "error.platform.validation.device.tierIdInvalidOrDoesNotExist"

Scenario: Changing the default tier of a non-existing Client
Scenario: Updating a non-existing Client
When a PUT request is sent to the /Clients/{c.clientId} endpoint with a non-existing clientId
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@Integration
Feature: GET Identities/{identityAddress}

User requests an Identity

Scenario: Requesting an Identity by address
Given an Identity i
When a GET request is sent to the /Identities/{i.address} endpoint
Then the response status code is 200 (OK)
And the response contains Identity i

Scenario: Requesting an Identity with non existent address
When a GET request is sent to the /Identities/{address} endpoint with an inexistent address
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Scenario: Deleting an inexistent Individual Quota
When a DELETE request is sent to the /Identities/{i.address}/Quotas/inexistentQuotaId endpoint
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"

Scenario: Deleting an Individual Quota for a non existent Identity
Given an Identity i with an IndividualQuota q
When a DELETE request is sent to the /Identities/{nonExistentAddress}/Quotas/{q.id} endpoint
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Scenario: Creating an Individual Quota for inexistent Identity
When a POST request is sent to the /Identity/{address}/Quotas endpoint with an inexistent identity address
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"

Scenario: Creating an Individual Quota for a non existent Metric Key
Given an Identity i
When a POST request is sent to the /Identity/{i.id}/Quotas endpoint with an invalid metric key
Then the response status code is 400 (Bad Request)
And the response content contains an error with the error code "error.platform.quotas.unsupportedMetricKey"
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Scenario: Deleting an inexistent Tier Quota
When a DELETE request is sent to the /Tiers/{t.id}/Quotas/{quotaId} endpoint with an inexistent quota id
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"

Scenario: Deleting a Tier Quota for a non existent Tier
Given a Tier t with a Quota q
When a DELETE request is sent to the /Tiers/{nonExistentTier}/Quotas/{q.id}
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Scenario: Creating a Tier Quota for inexistent Tier
When a POST request is sent to the /Tiers/{tierId}/Quotas endpoint with an inexistent tier id
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"

Scenario: Creating a Tier Quota for a non existent Metric Key
Given a Tier t
When a POST request is sent to the /Tiers/{t.id}/Quotas endpoint with an invalid metric key
Then the response status code is 400 (Bad Request)
And the response content contains an error with the error code "error.platform.quotas.unsupportedMetricKey"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@Integration
Feature: GET Tiers/{id}

User requests a Tier

Scenario: Requesting a Tier by id
Given a Tier t
When a GET request is sent to the /Tiers/{t.id} endpoint
Then the response status code is 200 (OK)
And the response contains Tier t

Scenario: Requesting a Tier with non existent address
When a GET request is sent to the /Tiers/{nonExistentTierId} endpoint
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Backbone.AdminApi.Tests.Integration.StepDefinitions;
[Binding]
[Scope(Feature = "GET Identities")]
[Scope(Feature = "POST Identities/{id}/DeletionProcess")]
[Scope(Feature = "GET Identities/{identityAddress}")]
[Scope(Feature = "GET Identities/{identityAddress}/DeletionProcesses/AuditLogs")]
internal class IdentitiesApiStepDefinitions : BaseStepDefinitions
{
Expand Down Expand Up @@ -123,7 +124,7 @@ public void ThenTheResponseContentIncludesAnErrorWithTheErrorCode(string errorCo
{
if (_identityResponse != null)
{
_identityResponse!.Result!.Should().NotBeNull();
_identityResponse!.Error!.Should().NotBeNull();
_identityResponse.Error!.Code.Should().Be(errorCode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ public async Task WhenADeleteRequestIsSentToTheDeleteIndividualQuotaEndpointWith
_deleteResponse = await _client.Identities.DeleteIndividualQuota(_identityAddress, "QUOInexistentIdxxxxx");
}

[When("a DELETE request is sent to the /Identities/{nonExistentAddress}/Quotas/{q.id} endpoint")]
public async Task WhenADeleteRequestIsSentToTheDeleteIndividualQuotaEndpointWithANonExistentIdentityAddress()
{
_deleteResponse = await _client.Identities.DeleteIndividualQuota("someNonExistentIdentityAddress", _quotaId);
}

[When("a POST request is sent to the /Identity/{i.id}/Quotas endpoint")]
public async Task WhenAPOSTRequestIsSentToTheCreateIndividualQuotaEndpoint()
{
Expand All @@ -80,6 +86,17 @@ public async Task WhenAPOSTRequestIsSentToTheCreateIndividualQuotaEndpointWithAn
});
}

[When("a POST request is sent to the /Identity/{i.id}/Quotas endpoint with an invalid metric key")]
public async Task WhenAPOSTRequestIsSentToTheCreateIndividualQuotaEndpointWithAnInvalidMetricKey()
{
_createQuotaResponse = await _client.Identities.CreateIndividualQuota(_identityAddress, new CreateQuotaForIdentityRequest
{
MetricKey = "someInvalidMetricKey",
Max = 2,
Period = "Week"
});
}

[Then(@"the response status code is (\d+) \(.+\)")]
public void ThenTheResponseStatusCodeIs(int expectedStatusCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ public async Task WhenAPOSTRequestIsSentToTheCreateTierQuotaEndpoint()
});
}

[When("a POST request is sent to the /Tiers/{t.id}/Quotas endpoint with an invalid metric key")]
public async Task WhenAPOSTRequestIsSentToTheCreateTierQuotaEndpointWithAnInvalidMetricKey()
{
_createTierQuotaResponse = await _client.Tiers.AddTierQuota(_tierId, new CreateQuotaForTierRequest
{
MetricKey = "SomeInvalidMetricKey",
Max = 2,
Period = "Week"
});
}

[When("a POST request is sent to the /Tiers/{tierId}/Quotas endpoint with an inexistent tier id")]
public async Task WhenAPOSTRequestIsSentToTheCreateTierQuotaEndpointForAnInexistentTier()
{
Expand All @@ -89,6 +100,12 @@ public async Task WhenADeleteRequestIsSentToTheDeleteTierQuotaEndpointForAnInexi
_deleteResponse = await _client.Tiers.DeleteTierQuota(_tierId, "inexistentQuotaId");
}

[When("a DELETE request is sent to the /Tiers/{nonExistentTier}/Quotas/{q.id}")]
public async Task WhenADeleteRequestIsSentToTheDeleteTierQuotaEndpointWithANonExistentTierId()
{
_deleteResponse = await _client.Tiers.DeleteTierQuota("nonExistentTierId", _tierQuotaDefinitionId);
}

[Then(@"the response status code is (\d+) \(.+\)")]
public void ThenTheResponseStatusCodeIs(int expectedStatusCode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ namespace Backbone.AdminApi.Tests.Integration.StepDefinitions;

[Binding]
[Scope(Feature = "GET Tiers")]
[Scope(Feature = "GET Tiers/{id}")]
[Scope(Feature = "POST Tier")]
[Scope(Feature = "DELETE Tier")]
internal class TiersStepDefinitions : BaseStepDefinitions
{
private ApiResponse<Tier>? _tierResponse;
private ApiResponse<TierDetails>? _getTierResponse;
private ApiResponse<EmptyResponse>? _deleteResponse;
private ApiResponse<ListTiersResponse>? _tiersResponse;
private string _existingTierName;
Expand Down Expand Up @@ -54,6 +56,18 @@ public async Task WhenAGETRequestIsSentToTheTiersEndpoint()
_tiersResponse = await _client.Tiers.ListTiers();
}

[When("a GET request is sent to the /Tiers/{t.id} endpoint")]
public async Task WhenAGETRequestIsSentToTheTiersByIdEndpoint()
{
_getTierResponse = await _client.Tiers.GetTier(_existingTierId);
}

[When("a GET request is sent to the /Tiers/{nonExistentTierId} endpoint")]
public async Task WhenAGETRequestIsSentToTheTiersByIdEndpointWithANonExistentId()
{
_getTierResponse = await _client.Tiers.GetTier("TIRNonExistentId1231");
}

[When("a POST request is sent to the /Tiers endpoint")]
public async Task WhenAPOSTRequestIsSentToTheTiersEndpoint()
{
Expand Down Expand Up @@ -94,6 +108,15 @@ public async Task ThenTheResponseContainsATier()
await _tierResponse.Should().ComplyWithSchema();
}

[Then("the response contains Tier t")]
public async Task ThenTheResponseContainsTierT()
{
_getTierResponse!.Should().BeASuccess();
_getTierResponse!.ContentType.Should().StartWith("application/json");
await _getTierResponse.Should().ComplyWithSchema();
_getTierResponse.Result!.Id.Should().Be(_existingTierId);
}

[Then(@"the response status code is (\d+) \(.+\)")]
public void ThenTheResponseStatusCodeIs(int expectedStatusCode)
{
Expand All @@ -105,12 +128,24 @@ public void ThenTheResponseStatusCodeIs(int expectedStatusCode)

if (_deleteResponse != null)
((int)_deleteResponse!.Status).Should().Be(expectedStatusCode);

if (_getTierResponse != null)
((int)_getTierResponse!.Status).Should().Be(expectedStatusCode);
}

[Then(@"the response content contains an error with the error code ""([^""]+)""")]
public void ThenTheResponseContentIncludesAnErrorWithTheErrorCode(string errorCode)
{
_tierResponse!.Error.Should().NotBeNull();
_tierResponse.Error!.Code.Should().Be(errorCode);
if (_tierResponse != null)
{
_tierResponse!.Error.Should().NotBeNull();
_tierResponse.Error!.Code.Should().Be(errorCode);
}

if (_getTierResponse != null)
{
_getTierResponse!.Error.Should().NotBeNull();
_getTierResponse.Error!.Code.Should().Be(errorCode);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@Integration
Feature: PUT Identities/Self/DeletionProcesses/{id}/Approve

User approves a deletion process

Scenario: Approve a non-existent deletion process
Given an Identity i
When a PUT request is sent to the /Identities/Self/DeletionProcesses/{d.id}/Approve endpoint with a non-existent deletionProcessId
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
Then the response status code is 404 (Not Found)
And the response content contains an error with the error code "error.platform.recordNotFound"
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ Scenario: Revoke Relationship to an Identity in status "ToBeDeleted"
When a POST request is sent to the /Relationships/{r.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"

#Scenario: Request Reactivation Of Relationship
#Scenario: Accept Reactivation Of Relationship
#Scenario: Reject Reactivation Of Relationship
#Scenario: Revoke Reactivation Of Relationship
#Scenario: Create a Relationship with a non-existent Relationship Template Id
#Scenario: Decompose Relationship
#Scenario: Terminate Relationship
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ namespace Backbone.ConsumerApi.Tests.Integration.StepDefinitions;

[Binding]
[Scope(Feature = "POST Identities/Self/DeletionProcess")]
[Scope(Feature = "PUT Identities/Self/DeletionProcesses/{id}/Approve")]
[Scope(Feature = "POST Identity")]
internal class IdentitiesApiStepDefinitions
{
private Client _sdk = null!;
private readonly ClientCredentials _clientCredentials;
private readonly HttpClient _httpClient;
private ApiResponse<StartDeletionProcessResponse>? _startDeletionProcessResponse;
private ApiResponse<ApproveDeletionProcessResponse>? _approveDeletionProcessResponse;
private ApiResponse<CreateIdentityResponse>? _identityResponse;
private ApiResponse<Challenge>? _challengeResponse;

Expand Down Expand Up @@ -64,6 +66,12 @@ public async Task WhenAPOSTRequestIsSentToTheIdentitiesSelfDeletionProcessEndpoi
_startDeletionProcessResponse = await _sdk.Identities.StartDeletionProcess();
}

[When("a PUT request is sent to the /Identities/Self/DeletionProcesses/{d.id}/Approve endpoint with a non-existent deletionProcessId")]
public async Task WhenAPutRequestIsSentToTheIdentitiesSelfDeletionProcessesIdApproveEndpointWithANonExistentDeletionProcessId()
{
_approveDeletionProcessResponse = await _sdk.Identities.ApproveDeletionProcess("IDPSomeNonExistentId");
}

[When("a POST request is sent to the /Identities endpoint with a valid signature on c")]
public async Task WhenAPOSTRequestIsSentToTheIdentitiesEndpoint()
{
Expand Down Expand Up @@ -94,8 +102,17 @@ public async Task WhenAPOSTRequestIsSentToTheIdentitiesEndpoint()
[Then(@"the response content contains an error with the error code ""([^""]*)""")]
public void ThenTheResponseContentIncludesAnErrorWithTheErrorCode(string errorCode)
{
_startDeletionProcessResponse!.Error.Should().NotBeNull();
_startDeletionProcessResponse.Error!.Code.Should().Be(errorCode);
if (_startDeletionProcessResponse != null)
{
_startDeletionProcessResponse!.Error.Should().NotBeNull();
_startDeletionProcessResponse.Error!.Code.Should().Be(errorCode);
}

if (_approveDeletionProcessResponse != null)
{
_approveDeletionProcessResponse!.Error.Should().NotBeNull();
_approveDeletionProcessResponse.Error!.Code.Should().Be(errorCode);
}
tnotheis marked this conversation as resolved.
Show resolved Hide resolved
}

[Then("the response contains a Deletion Process")]
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading