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

Consumer API: Use Consumer API SDK for integration tests #659

Merged
Merged
Show file tree
Hide file tree
Changes from 69 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
a67f84a
fix: consumer SDK generating paths witl backslashes
Dannyps Apr 3, 2024
eea55b9
chore: merge main
Dannyps Apr 3, 2024
d47bd0d
feat: add password helper
Dannyps Apr 11, 2024
799da7e
chore: add basic AccountController
Dannyps Apr 11, 2024
c3531d1
Merge remote-tracking branch 'origin/main' into NMSHDB-83-create-iden…
Dannyps Apr 16, 2024
6f504ba
feat: identity creation using consumer sdk
Dannyps Apr 17, 2024
b87e907
refactor: format and extract classes
Dannyps Apr 17, 2024
8827699
feat: complete example for challenges integration tests
Dannyps Apr 19, 2024
0e18aaa
chore: refactor
Dannyps Apr 19, 2024
3387412
fix: not using DI Factory
Dannyps Apr 19, 2024
855ec0f
fix: cannot parse body when there is no body to parse
Dannyps Apr 19, 2024
abdbd1d
Merge remote-tracking branch 'origin/main' into NMSHDB-83-create-iden…
Dannyps Apr 19, 2024
93a3e9c
chore: remove unused method
Dannyps Apr 23, 2024
eb66eff
Merge remote-tracking branch 'origin/main' into NMSHDB-83-create-iden…
Dannyps Apr 23, 2024
5b9c8f7
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 23, 2024
c80ac09
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 23, 2024
13a80f3
refactor: when string
Dannyps Apr 23, 2024
49770fb
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 24, 2024
fb941ba
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 25, 2024
4e487b2
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 26, 2024
897e341
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 26, 2024
a4adfde
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 26, 2024
edf0ccc
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 29, 2024
8a4e201
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 29, 2024
e72dbad
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 29, 2024
f3d0901
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 30, 2024
28cd78f
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 30, 2024
4f6f452
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 30, 2024
f5b488f
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] Apr 30, 2024
b870218
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 2, 2024
a6c2d77
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 2, 2024
089eca6
refactor: specify api version in each route
tnotheis May 2, 2024
9ed3346
feat: factory methods for consumer api Client
tnotheis May 2, 2024
028af08
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 3, 2024
0e0695f
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 3, 2024
1ec6b9d
Merge branch 'main' into improve-consumer-api-integration-tests
daniel-almeida-konkconsulting May 3, 2024
14007bb
feat: add challenges steps with SDK
daniel-almeida-konkconsulting May 3, 2024
57d16ef
Merge remote-tracking branch 'origin/main' into NMSHDB-83-create-iden…
Dannyps May 7, 2024
79d56c1
chore: fix merge
Dannyps May 7, 2024
a420e48
chore: code review fixes
Dannyps May 7, 2024
b1cb4bc
fix: missing using
Dannyps May 7, 2024
5c55a1a
chore: formatting
Dannyps May 7, 2024
e687915
chore: move PasswordHelper
Dannyps May 7, 2024
5ac0bcc
chore: remove accountController
Dannyps May 7, 2024
30f6692
chore: identityPublicKey should be passed as a Bas64 string
Dannyps May 7, 2024
8dbaf63
fix: using bad dsk method for challenge creation
Dannyps May 8, 2024
6df401b
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 8, 2024
012af04
chore: ensure empty payloads do not break the sdk
Dannyps May 8, 2024
400d102
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 13, 2024
e375383
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 13, 2024
e3fa9c1
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 13, 2024
a2f3e0c
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
Dannyps May 13, 2024
60c0268
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 13, 2024
6be9fca
Merge branch 'main' into NMSHDB-83-create-identities-via-sdk
mergify[bot] May 15, 2024
17ca4a6
chore: code review changes
Dannyps May 15, 2024
82fbcb8
Merge remote-tracking branch 'origin/main' into NMSHDB-83-create-iden…
Dannyps May 15, 2024
5ef12bb
refactor: use fluent assertion extensions and fix challenge creation …
daniel-almeida-konkconsulting May 15, 2024
e650a95
chore: remove unauthorized integration test
Dannyps May 16, 2024
24c2714
refactor: GivenTheUserIsAuthenticated
Dannyps May 16, 2024
819b26d
refactor: remove exception handling for response deserialization
daniel-almeida-konkconsulting May 16, 2024
7f7568d
chore: revert changes to test appsettings
Dannyps May 16, 2024
f65f6ce
chore: remove default _sdk variable for ChallengesApiStepDefinitions
Dannyps May 16, 2024
9b449ae
Merge branch 'NMSHDB-83-create-identities-via-sdk' of github.com:nmsh…
Dannyps May 16, 2024
7a4a54f
Merge branch 'main' into improve-consumer-api-integration-tests
daniel-almeida-konkconsulting May 16, 2024
15d3782
Merge branch 'NMSHDB-83-create-identities-via-sdk' into improve-consu…
daniel-almeida-konkconsulting May 16, 2024
b276421
test: add consumer api integration tests with SDK
daniel-almeida-konkconsulting May 17, 2024
1890efd
Merge branch 'main' into improve-consumer-api-integration-tests
daniel-almeida-konkconsulting May 17, 2024
0536df9
fix: post merge fixes
daniel-almeida-konkconsulting May 17, 2024
afd4d1c
Merge branch 'main' into improve-consumer-api-integration-tests
mergify[bot] May 21, 2024
6476a25
fix: add byte array converter to consumer api
daniel-almeida-konkconsulting May 21, 2024
6c60ebd
Merge branch 'improve-consumer-api-integration-tests' of https://gith…
daniel-almeida-konkconsulting May 21, 2024
bc9d2e2
refactor: use UrlSafeBase64ToByteArrayJsonConverter and shift registr…
daniel-almeida-konkconsulting May 21, 2024
8694544
refactor: use null suppression for sdk
daniel-almeida-konkconsulting May 21, 2024
84902bf
refactor: use hardcoded password value
daniel-almeida-konkconsulting May 21, 2024
3633a60
Merge branch 'main' into improve-consumer-api-integration-tests
mergify[bot] May 21, 2024
a0772a2
ci: change publish pipeline name
tnotheis May 22, 2024
2ab8118
refactor: rename token response field in case of unauthorized error
daniel-almeida-konkconsulting May 22, 2024
65250ce
refactor: remove unused parameter
daniel-almeida-konkconsulting May 22, 2024
f93ab78
fix: challenges test referencing non existent step definition
daniel-almeida-konkconsulting May 22, 2024
054562a
refactor: rename step definition
daniel-almeida-konkconsulting May 22, 2024
57a0e78
refactor: rename step definition for admin api integration tests
daniel-almeida-konkconsulting May 22, 2024
2635a72
refactor: reuse step definition with different regex to improve reada…
daniel-almeida-konkconsulting May 22, 2024
7206ec6
Merge branch 'improve-consumer-api-integration-tests' of https://gith…
daniel-almeida-konkconsulting May 22, 2024
f0390c2
refactor: use regex to avoid multiple attributes
daniel-almeida-konkconsulting May 22, 2024
f1203fb
refactor: introduce global constant for device password
daniel-almeida-konkconsulting May 22, 2024
3d1106b
refactor: remove unused step definition
daniel-almeida-konkconsulting May 22, 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
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Backbone.BuildingBlocks.SDK.Converters;

public class JsonToByteArrayConverter : JsonConverter<byte[]?>
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
{
// Converts base64 encoded string to byte[].
public override byte[]? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (!reader.TryGetBytesFromBase64(out var result))
{
throw new Exception("Add your fancy exception message here...");
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
}

return result;
}

// Converts byte[] to base64 encoded string.
public override void Write(Utf8JsonWriter writer, byte[]? value, JsonSerializerOptions options)
{
writer.WriteBase64StringValue(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

public abstract class Endpoint(EndpointClient client)
{
protected const string API_VERSION = "v1";

protected readonly EndpointClient _client = client;
}
5 changes: 5 additions & 0 deletions ConsumerApi.Sdk/Endpoints/Tokens/TokensEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public async Task<ApiResponse<CreateTokenResponse>> CreateToken(CreateTokenReque
return await _client.Post<CreateTokenResponse>($"api/{API_VERSION}/Tokens", request);
}

public async Task<ApiResponse<EmptyResponse>> CreateTokenUnauthenticated(CreateTokenRequest request)
{
return await _client.PostUnauthenticated<EmptyResponse>($"api/{API_VERSION}/Tokens", request);
}

public async Task<ApiResponse<ListTokensResponse>> ListTokens(PaginationFilter? pagination = null)
{
return await _client.Get<ListTokensResponse>($"api/{API_VERSION}/Tokens", null, pagination);
Expand Down
2 changes: 2 additions & 0 deletions ConsumerApi.Sdk/Endpoints/Tokens/Types/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ public class Token
public required string CreatedByDevice { get; set; }
public required DateTime CreatedAt { get; set; }
public required DateTime ExpiresAt { get; set; }

//[JsonConverter(typeof(ByteArrayConverter))]
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
public required byte[] Content { get; set; }
}
150 changes: 0 additions & 150 deletions ConsumerApi.Tests.Integration/API/BaseApi.cs

This file was deleted.

13 changes: 0 additions & 13 deletions ConsumerApi.Tests.Integration/API/ChallengesApi.cs

This file was deleted.

23 changes: 0 additions & 23 deletions ConsumerApi.Tests.Integration/API/DevicesApi.cs

This file was deleted.

18 changes: 0 additions & 18 deletions ConsumerApi.Tests.Integration/API/IdentitiesApi.cs

This file was deleted.

13 changes: 0 additions & 13 deletions ConsumerApi.Tests.Integration/API/PushNotificationsApi.cs

This file was deleted.

27 changes: 0 additions & 27 deletions ConsumerApi.Tests.Integration/API/TokensApi.cs

This file was deleted.

3 changes: 0 additions & 3 deletions ConsumerApi.Tests.Integration/Configuration/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ namespace Backbone.ConsumerApi.Tests.Integration.Configuration;

public class HttpConfiguration
{
[Required]
public string BaseUrl { get; set; } = string.Empty;

[Required]
public ClientCredentialsConfiguration ClientCredentials { get; set; } = new();
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ User creates a Challenge

Scenario: Creating a Challenge as an anonymous user
Given the user is unauthenticated
When a POST request is sent to the Challenges endpoint
When a POST request is sent to the Challenges endpoint without authentication
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
Then the response status code is 201 (Created)
And the response contains a Challenge
And the Challenge does not contain information about the creator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@ User deletes an un-onboarded Device

Scenario: Deleting an un-onboarded Device
Given an Identity i with a device d1
And the current user uses d1
And an un-onboarded device d2
When a DELETE request is sent to the Devices/{id} endpoint with d2.Id
Then the response status code is 204 (Ok)
And d2 is deleted

Scenario: Deleting an onboarded Device is not possible
Given an Identity i with a device d
And the current user uses d
When a DELETE request is sent to the Devices/{id} endpoint with d.Id
Given an Identity i with a device d1
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
When a DELETE request is sent to the Devices/{id} endpoint with d1.Id
Then the response status code is 400 (Bad Request)
And the error code is "error.platform.validation.device.deviceCannotBeDeleted"
And the response content includes an error with the error code "error.platform.validation.device.deviceCannotBeDeleted"
daniel-almeida-konkconsulting marked this conversation as resolved.
Show resolved Hide resolved
And d is not deleted

Scenario: Deleting a non existent Device
Given an Identity i with a device d1
And the current user uses d1
When a DELETE request is sent to the Devices/{id} endpoint with a non existent id
Then the response status code is 404 (Not Found)
And the error code is "error.platform.recordNotFound"
And the response content includes an error with the error code "error.platform.recordNotFound"
And d1 is not deleted

# baseApi is not capable to handle multiple identities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ Feature: POST Identities/Self/DeletionProcess

User starts a deletion process

// Scenario: Starting a deletion process
// Given no active deletion process for the identity exists
// When a POST request is sent to the /Identities/Self/DeletionProcesses endpoint
// Then the response status code is 201 (Created)
// And the response contains a Deletion Process
Scenario: Starting a deletion process
Given an Identity i
And no active deletion process for the identity exists
When a POST request is sent to the /Identities/Self/DeletionProcesses endpoint
Then the response status code is 201 (Created)
And the response contains a Deletion Process

// Scenario: There can only be one active deletion process
// Given an active deletion process for the identity exists
// When a POST request is sent to the /Identities/Self/DeletionProcesses endpoint
// Then the response status code is 400 (Bad Request)
// And the response content includes an error with the error code "error.platform.validation.device.onlyOneActiveDeletionProcessAllowed"
Scenario: There can only be one active deletion process
Given an Identity i
And an active deletion process for the identity exists
When a POST request is sent to the /Identities/Self/DeletionProcesses endpoint
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.device.onlyOneActiveDeletionProcessAllowed"
Loading
Loading