Skip to content

Commit

Permalink
Fix compiler warnings related to nullability in Devices module (#495)
Browse files Browse the repository at this point in the history
* chore: fix nullability in IDbContext

* fix: get rid of infinite recursion

* chore: remove unused method

* refactor: fix nullability of PnsRegistrationsRepository.FindByDeviceId

* refactor: make properties required

* chore: add comment clarifying the usage of the empty ctor

* chore: remove unused directive

* chore: remove unused directive

* refactor: set properties as nullable since any of two options could be missing

* refactor: mark return type as nullable since it can indeed return null
refactor: remove nullable mark from the input param as it is never null

* refactor: mark return type as nullable since it can return null and the single call of the method suppresses null warnings

* refactor: make property required as it is the single property of the class

* refactor: put the nullability suffix back

* refactor: mark the parameter as nullable as it can clearly be null

* chore: remove unused directive

* refactor: add nullable suppression and '?' suffix

* chore: change parameter order to match the class

* refactor: remove '?' suffix as options is never null

* refactor: suppress null warnings as the object is instantiated as empty but the properties are then immediately set

* refactor: avoid possible multiple enumeration

* refactor: remove null suppression as AppId is never null

* refactor: suppress null warning as it presumably can never be null

* refactor: make the return type not nullable

* refactor: throw exception in case of bundle being null

* refactor: make the property nullable

* chore: revert change

* refactor: make the method signature match the one it is calling

* refactor: avoid possible multiple enumeration

* refactor: make the method signature match the one it is calling

* refactor: add '?' suffix where required

* refactor: remove meaningless '?' suffix

* refactor: remove unnecessary async keyword

* refactor: add '?' suffix where needed

* refactor: throw exception in case that public key cannot be deserialized

* refactor: throw exception in case that signature cannot be deserialized

* chore: fix formatting issues

* refactor: remove unnecessary null check

* refactor: suppress null warning as ToModel never returns null

* refactor: make input parameter nullable as it is checked for null value subsequently

* refactor: suppress nullable warning as the class is never instantiated manually

* refactor: suppress warning with 'null!' initializers as ClientDTO is only instantiated through mapper

* refactor: make properties required

* fix: remove required keyword as it seems to break some tests

* refactor: remove 'null!' initializers as they seem to break some tests

* fix: remove 'null!' initializers as they seem to break some tests

* fix: remove 'null!' initializers as they seem to break some tests

* fix: revert changes that seem to break some tests

* refactor: revert to changes previously suspected to crash the tests

* fix: wip

* Revert "fix: wip"

This reverts commit e6d96a7.

* Revert "refactor: revert to changes previously suspected to crash the tests"

This reverts commit e3d4a1a.

* chore: remove redundant nullable directive

* refactor: make properties required

* chore: comment out the tests which are to be ignored at the moment

* refactor: make property required

* refactor: check expression for null

* refactor: suppress null value as UserName is never null

* refactor: throw exceptions where appropriate

* refactor: suppress null value on instantiation

* refactor: throw exception if basic tier not found

* Revert "refactor: throw exception if basic tier not found"

This reverts commit 6de40a4.

* Revert "refactor: suppress null value on instantiation"

This reverts commit 466e29b.

* Revert "refactor: throw exceptions where appropriate"

This reverts commit 0069918.

* Revert "refactor: suppress null value as UserName is never null"

This reverts commit 8be174e.

* Revert "refactor: check expression for null"

This reverts commit 2851b0e.

* Revert "refactor: make property required"

This reverts commit 08333ea.

* refactor: make Provider property nullable

* refactor: check expression for null

* refactor: check expression for null

* refactor: suppress null value as UserName is never null

* chore: suppress null value for Read, ReadValue and ReadList

* refactor: suppress null value on instantiation

* refactor: throw exception if basic tier not found

* Helm Chart: Update Consumer API, Admin UI and Admin CLI (#501)

* feat: update adminui

* feat: update consumerapi

* Helm Chart: Update Consumer API, Admin UI and Admin CLI (#501)

* feat: update adminui

* feat: update consumerapi

* refactor: suppress null warning since basic tier always exists

* chore: fix formatting issues

* refactor: suppress null warnings as values can never be null

* refactor: suppress null warning since basic tier always exists

* refactor: suppress the null warning since default value of identity is null

* refactor: add '?' suffix to match the signature of base method

* refactor: cast ids to list

* refactor: remove unused field

* refactor: suppress null value as UserName is never null

* refactor: cast devices to list

* refactor: add null checks for nullable parameters

* chore: fix formatting issues

* refactor: suppress null value as UserName is never null

* chore: fix typo

* refactor: make property nullable to match the nullability of non-dto class and add null check

* refactor: fix formatting

* refactor: add null checks due to properties being nullable

* chore: fix formatting

* refactor: match nullability of the base class return type

* refactor: match nullability of the base class return type

* refactor: initialize properties of SendResult with null! (not possible to use required but the values are never null)

* refactor: make properties of ApnsMessageBuilder nullable

* refactor: disable 'property unused' warnings (reluctant to remove unused class properties)

* refactor: make property nullable

* refactor: suppress nullability warning (class is never instanced in code)

* refactor: remove null check as the value should never be null

* refactor: mark Property as nullable (insantiated manually once where Data is set)

* refactor: mark property as nullable

* refactor: mark properties as nullable

* refactor: mark properties as nullable

* refactor: mark properties as nullable (insantiated manually once where values are set)

* refactor: mark properties as nullable

* refactor: mark properties as nullable (insantiated manually once where values are set)

* refactor: make property nullable

* refactor: make properties nullable

* refactor: make properties nullable

* refactor: make properties nullable

* chore: remove unused directive

* refactor: make property nullable (instantiated manually with empty ctor)

* fix: return null check and disable the warning with comment

* refactor: suppress null warnings in case of all properties previously marked as nullable

* refactor: cast tiers to list

* refactor: suppress nullable warnings

* refactor: match signature of FindByAddress in IIdentitiesRepository to Task.FromResult
refactor: match signature of FindByAddress implementations to implemented interface

* refactor: suppress nullability warnings as JsonElement.Deserialize is presumed to work correctly

* refactor: suppress null warnings as the instanced objects cannot be null

* refactor: suppress null warnings in tests

* refactor: fix nullability of CreateClientCommand

* refactor: add invalid default values to ApplicationOptions to be able to make them not nullable

* refactor: mkae RegisterDeviceCommand properties required (recursively)

* refactor: fix nullability warnings in TiersRepository

* refactor: make DeleteDeviceCommand.Id required

* refactor: make ClientDTO.CreatedAt required

* refactor: make ChallengeDTO.Id required

* refactor: simplify IdentitySummaryDTO

* refactor: fix nullability issues in DynamicJsonConverter

* refactor: add some required modifiers

* chore: formatting

* refactor: make all properties except ClientId required - ClientId is nullable in Identity

* refactor: make Properties required

* refactor: make Property required

* refactor: mark property as nullable

* refactor: make property required to avoid compiler error

* refactor: rearrange properties to match domain class
refactor: pass in entire identity to ctor

* refactor: pass the entire identity to base ctor

* refactor: pass identity to ctor

* refactor: remove redundant null warning suppression

* refactor: remove redundant nullability suppression

* refactor: remove redundant nullability suppression

* refactor: make properties of DatawalletModifiedIntegrationEvent required

* refactor: remove null warning suppression for usage of DatawalletModifiedIntegrationEvent

* chore: fix formatting

* refactor: make property of ExternalEventCreatedIntegrationEvent required and remove null warning suppression

* refactor: remove null warning suppression

* refactor: revert changes as they are to be done later

* chore: remove pointless line breaks

* chore: enhance formatting

* chore: enhance formatting

* chore: remove pointless line break

* refactor: make properties of CreateIdentityResponse and CreateIdentityResponseDevice required

* refactor: remove the '?' suffix as it makes no sense, though the class is never instanced in code and I cannot be 100% sure

* refactor: make properties of NotificationTextAttribute required instead of nullable

* chore: disable meaningless warnings with comments

* refactor: use collection expression to initialize list

* refactor: make properties of CustomOpenIddictEntityFrameworkCoreApplication required and remove redundant null warning suppression

* refactor: initialize field with null in EF Core required ctor

* refactor: initialize DbSets with 'null!' as discussed

* refactor: remove redundant null warning suppression

* refactor: mark return type as nullable

* refactor: remove redundant null warning suppression

* refactor: update return type

* refactor: update return type and remove redundant null warning suppression

* refactor: update return type

* refactor: update return type and remove redundant null warning suppression

* refactor: remove redundant null warning suppression

* chore: add line break

* refactor: revert changes as they are to be done later

* refactor: remove redundant null warning suppression

* refactor: remove redundant null warning suppression

* refactor: match return type of the interface

* refactor: add null warning suppression as _identity is not null

* refactor: match return type of the interface

* refactor: remove redundant null warning suppression

* chore: fix formatting

* refactor: remove redundant nullability suffix

* Revert "refactor: remove redundant nullability suffix"

This reverts commit 166c3f3.

* refactor: revert changes to match the possible state of same property in ApplicationUser

* refactor: replace null warning suppression with an exception throw

* refactor: revert changes as they are to be done later

* refactor: replace null warning suppression with an exception throw

* refactor: revert changes to match the possible state of same property in ApplicationUser

* refactor: make return type nullable

* refactor: throw exception if OAuthClient not found

* refactor: remove redundant null warning suppression

* fix: make return type nullable instead of throwing an exception

* refactor: update default values

* refactor: change to FirstAsync call as basic tier always exists since it's seeded to the db

* refactor: make return type not nullable

* fix: revert to previous state

* fix: revert changes done earlier

* ci: trigger pipelines

* refactor: make return type nullable and possibly return null

* refactor: remove null warning suppression and return nullable type

* refactor: change to FirstAsync call as basic tier always exists since it's seeded to the db and make return type non nullable

* refactor: make return type nullable

* refactor: change FirstAsync into FirstOrDefaultAsync

* Revert "refactor: change FirstAsync into FirstOrDefaultAsync"

This reverts commit 68c9ed6.

* refactor: change FirstAsync into FirstOrDefaultAsync

* chore: disable warning temporarily

* refactor: remove null check

* chore: formatting

* chore: remove null suppression operator

* chore: remove default values from PaginationOptions properties

* feat: fix nullability in SendResult

* chore: resolve nullability problems

* chore: extract variable

* chore: fix nullability issues for entity constructors

* chore: remove redundant using directives

* chore: add words to resharper dictionary

* chore: remove unused setters from Identity

* chore: fix some compiler warnings

* chore: remove redundant assignment of null

* refactor: rename GetBasicTierAsync to FindBasicTier to match naming convention

* chore: fix some nullability issues

* chore: formatting

* test: fix DeletedAt comparison

* fix: add CreatedAt and PublicKey to IdentityEntityTypeConfiguration

* chore: formatting

---------

Co-authored-by: Timo Notheisen <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Timo Notheisen <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Feb 19, 2024
1 parent 1fe64aa commit c05730c
Show file tree
Hide file tree
Showing 112 changed files with 633 additions and 541 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public static IServiceCollection AddDevices(this IServiceCollection services,

services.AddDatabase(options =>
{
options.ConnectionString = configuration.Infrastructure.SqlDatabase.ConnectionString;
options.Provider = configuration.Infrastructure.SqlDatabase.Provider;
options.ConnectionString = configuration.Infrastructure.SqlDatabase.ConnectionString;
});

services.AddSingleton<ISignatureHelper, SignatureHelper>(_ => SignatureHelper.CreateEd25519WithRawKeyFormat());
Expand Down
4 changes: 3 additions & 1 deletion Backbone.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=firebase/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Iddict/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=inexistent/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=jwts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mediat/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Onboarded/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Postgre/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unexhausted/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unexhausted/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unonboarded/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Task RunInTransaction(Func<Task> action, List<int> errorNumbersToRetry,

Task RunInTransaction(Func<Task> action, IsolationLevel isolationLevel);

Task<T?> RunInTransaction<T>(Func<Task<T?>> action, List<int> errorNumbersToRetry,
Task<T> RunInTransaction<T>(Func<Task<T>> action, List<int>? errorNumbersToRetry,
IsolationLevel isolationLevel = IsolationLevel.ReadCommitted);

Task<T?> RunInTransaction<T>(Func<Task<T?>> func, IsolationLevel isolationLevel);
Task<T> RunInTransaction<T>(Func<Task<T>> func, IsolationLevel isolationLevel);
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ public async Task RunInTransaction(Func<Task> action, IsolationLevel isolationLe
await RunInTransaction(action, null, isolationLevel);
}

public async Task<T?> RunInTransaction<T>(Func<Task<T?>> action, List<int>? errorNumbersToRetry,
public async Task<T> RunInTransaction<T>(Func<Task<T>> action, List<int>? errorNumbersToRetry,
IsolationLevel isolationLevel = IsolationLevel.ReadCommitted)
{
var response = default(T);
// the '!' is safe here because the default value is only returned after the action is executed, which is setting the response
var response = default(T)!;

await RunInTransaction(async () => response = await action(), errorNumbersToRetry, isolationLevel);
await RunInTransaction(async () => { response = await action(); }, errorNumbersToRetry, isolationLevel);

return response;
}

public async Task<T?> RunInTransaction<T>(Func<Task<T?>> func, IsolationLevel isolationLevel)
public async Task<T> RunInTransaction<T>(Func<Task<T>> func, IsolationLevel isolationLevel)
{
return await RunInTransaction(func, null, isolationLevel);
}
Expand All @@ -95,24 +96,4 @@ protected override void ConfigureConventions(ModelConfigurationBuilder configura
configurationBuilder.Properties<DateTime>().HaveConversion<DateTimeValueConverter>();
configurationBuilder.Properties<DateTime?>().HaveConversion<NullableDateTimeValueConverter>();
}

protected void RollBack()
{
var changedEntries = ChangeTracker.Entries().Where(x => x.State != EntityState.Unchanged).ToList();

foreach (var entry in changedEntries)
switch (entry.State)
{
case EntityState.Modified:
entry.CurrentValues.SetValues(entry.OriginalValues);
entry.State = EntityState.Unchanged;
break;
case EntityState.Added:
entry.State = EntityState.Detached;
break;
case EntityState.Deleted:
entry.State = EntityState.Unchanged;
break;
}
}
}
42 changes: 21 additions & 21 deletions ConsumerApi.Tests.Integration/Features/Challenges/POST.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ Scenario: Creating a Challenge as an authenticated user
And the response contains a Challenge
And the Challenge contains information about the creator

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Challenge with a JSON sent in the request content
When a POST request is sent to the Challenges endpoint with
| Key | Value |
| Content | {"this": "is some arbitrary json"} |
Then the response status code is 415 (Unsupported Media Type)

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Challenge with an invalid JSON sent in the request content
When a POST request is sent to the Challenges endpoint with
| Key | Value |
| Content | { "thisJSON": "has an extra }" }} |
Then the response status code is 415 (Unsupported Media Type)

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Challenge with an unsupported Content-Type header
When a POST request is sent to the Challenges endpoint with
| Key | Value |
| ContentType | application/xml |
| Content | <this>is some arbitrary xml</this> |
Then the response status code is 415 (Unsupported Media Type)
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Challenge with a JSON sent in the request content
# When a POST request is sent to the Challenges endpoint with
# | Key | Value |
# | Content | {"this": "is some arbitrary json"} |
# Then the response status code is 415 (Unsupported Media Type)
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Challenge with an invalid JSON sent in the request content
# When a POST request is sent to the Challenges endpoint with
# | Key | Value |
# | Content | { "thisJSON": "has an extra }" }} |
# Then the response status code is 415 (Unsupported Media Type)
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Challenge with an unsupported Content-Type header
# When a POST request is sent to the Challenges endpoint with
# | Key | Value |
# | ContentType | application/xml |
# | Content | <this>is some arbitrary xml</this> |
# Then the response status code is 415 (Unsupported Media Type)
40 changes: 20 additions & 20 deletions ConsumerApi.Tests.Integration/Features/Challenges/{id}/GET.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ Scenario: Requesting a nonexistent Challenge as an authenticated user
When a GET request is sent to the Challenges/{id} endpoint with "CHLthisisnonexisting"
Then the response status code is 404 (Not Found)

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Requesting a Challenge with an unsupported Accept Header as an authenticated user
Given the user is authenticated
And the Accept header is 'application/xml'
When a GET request is sent to the Challenges/{id} endpoint with a valid Id
Then the response status code is 406 (Not Acceptable)

@ignore("skipping_due_to_required_backbone_changes")
Scenario Outline: Requesting a Challenge with an invalid id as an authenticated user
Given the user is authenticated
When a GET request is sent to the Challenges/{id} endpoint with <id>
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.invalidId"
Examples:
| id | description |
| CHLthishastoomanycharacters | More than 20 characters |
| CHLnotenoughchars | Less than 20 characters |
| !CHLdfhuwnjdfnjnjfnd | Contains invalid characters |
| CHL_frfssd_fdfdsed#_ | Contains invalid characters |
| PHLfdjfdjflndjkfndjk | Does not have CHL prefix |
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Requesting a Challenge with an unsupported Accept Header as an authenticated user
# Given the user is authenticated
# And the Accept header is 'application/xml'
# When a GET request is sent to the Challenges/{id} endpoint with a valid Id
# Then the response status code is 406 (Not Acceptable)
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario Outline: Requesting a Challenge with an invalid id as an authenticated user
# Given the user is authenticated
# When a GET request is sent to the Challenges/{id} endpoint with <id>
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.invalidId"
#Examples:
# | id | description |
# | CHLthishastoomanycharacters | More than 20 characters |
# | CHLnotenoughchars | Less than 20 characters |
# | !CHLdfhuwnjdfnjnjfnd | Contains invalid characters |
# | CHL_frfssd_fdfdsed#_ | Contains invalid characters |
# | PHLfdjfdjflndjkfndjk | Does not have CHL prefix |
184 changes: 92 additions & 92 deletions ConsumerApi.Tests.Integration/Features/Tokens/POST.feature
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
@Integration
Feature: POST Token

User creates a Token

Scenario: Creating a Token as an authenticated user
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| ContentType | application/json |
| Content | {"content": "QQ==","expiresAt": "<tomorrow>"} |
Then the response status code is 201 (Created)
And the response contains a CreateTokenResponse

Scenario: Creating a Token as an anonymous user
Given the user is unauthenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| ContentType | application/json |
| Content | {"content": "QQ==","expiresAt": "<tomorrow>"} |
Then the response status code is 401 (Unauthorized)

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Token without the "Content" request content property
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| Content | {"expiresAt": "<tomorrow>"} |
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Token with an empty "Content" request content property
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| Content | {"content": "","expiresAt": "<tomorrow>"} |
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Token with an invalid base64 in the "Content" property
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| Content | {"content": "<invalid base64>","expiresAt": "<tomorrow>"} |
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Token without the "expiresAt" request content property
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| Content | {"content": "QQ=="} |
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Token with a date in the past in the "expiresAt" request content property
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| Content | {"content": "QQ==","expiresAt": "<yesterday>"} |
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"

@ignore("skipping_due_to_required_backbone_changes")
Scenario: Creating a Token without a request content
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with no request content
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.inputCannotBeParsed"

Scenario: Creating a Token with an unsupported Content-Type
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| ContentType | application/xml |
| Content | <this>is some arbitrary xml</this> |
Then the response status code is 415 (Unsupported Media Type)

@ignore("skipping_due_to_required_backbone_changes")
Scenario Outline: Creating a Token with an invalid DateTime format in the "expiresAt" request content property
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with '<Content>', '<ExpiresAt>'
Then the response status code is 400 (Bad Request)
And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
Examples:
| Content | ExpiresAt |
| QQ== | 31/12/9999 |
| QQ== | 13-2-9999 |
@Integration
Feature: POST Token

User creates a Token

Scenario: Creating a Token as an authenticated user
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| ContentType | application/json |
| Content | {"content": "QQ==","expiresAt": "<tomorrow>"} |
Then the response status code is 201 (Created)
And the response contains a CreateTokenResponse

Scenario: Creating a Token as an anonymous user
Given the user is unauthenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| ContentType | application/json |
| Content | {"content": "QQ==","expiresAt": "<tomorrow>"} |
Then the response status code is 401 (Unauthorized)

#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Token without the "Content" request content property
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with
# | Key | Value |
# | Content | {"expiresAt": "<tomorrow>"} |
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Token with an empty "Content" request content property
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with
# | Key | Value |
# | Content | {"content": "","expiresAt": "<tomorrow>"} |
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Token with an invalid base64 in the "Content" property
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with
# | Key | Value |
# | Content | {"content": "<invalid base64>","expiresAt": "<tomorrow>"} |
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Token without the "expiresAt" request content property
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with
# | Key | Value |
# | Content | {"content": "QQ=="} |
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Token with a date in the past in the "expiresAt" request content property
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with
# | Key | Value |
# | Content | {"content": "QQ==","expiresAt": "<yesterday>"} |
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
#
#@ignore("skipping_due_to_required_backbone_changes")
#Scenario: Creating a Token without a request content
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with no request content
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.inputCannotBeParsed"

Scenario: Creating a Token with an unsupported Content-Type
Given the user is authenticated
When a POST request is sent to the Tokens endpoint with
| Key | Value |
| ContentType | application/xml |
| Content | <this>is some arbitrary xml</this> |
Then the response status code is 415 (Unsupported Media Type)

#@ignore("skipping_due_to_required_backbone_changes")
#Scenario Outline: Creating a Token with an invalid DateTime format in the "expiresAt" request content property
# Given the user is authenticated
# When a POST request is sent to the Tokens endpoint with '<Content>', '<ExpiresAt>'
# Then the response status code is 400 (Bad Request)
# And the response content includes an error with the error code "error.platform.validation.invalidPropertyValue"
#Examples:
# | Content | ExpiresAt |
# | QQ== | 31/12/9999 |
# | QQ== | 13-2-9999 |
Loading

0 comments on commit c05730c

Please sign in to comment.