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: Execute lock statement on the variable updated in the critical area #551

Closed

Conversation

NikolaVetnic
Copy link
Contributor

Readiness checklist

  • I added/updated unit tests.
  • I added/updated integration tests.
  • I ensured that the PR title is good enough for the changelog.
  • I labeled the PR.

Description

As stated in the example given in the official documentation, the lock used to protect the variable cannot be the variable itself, instead it has to be a dedicated object defined on class level.

HunorTotBagi and others added 4 commits March 5, 2024 13:44
* wip

* fear: CancelDeletionProcessDuringGracePeriod

* feature: add new domain error

* feat: add method to check if device that starts deletion process actually belongs to identity

* refactor: adapt tests to newly implement feature (check if device belongs to identity)

* test: add new test start deletion process as owner from another device

* feat: wip handler

* test: add handler tests for cancellation of a deletion process during grace period handler

* feat: add handler for cancellation of a deletion process during grace period

* chore: fix formatting issues

* fear: add migration for CancelledAt & CancelledByDevice

* chore: fix formatting issues

* chore: move command creation into arrange section

* chore: rename property

* chore: remove unused directives

* refactor: get device id from _userContext

* chore: rename files, folders, methods & classes so they do not contain "DuringGracePeriod"

* feat: add properties to CancelDeletionProcessResponse

* refactor: fix test

* refactor: fix test

* chore: no action could lead to 400BadRequest

* chore: fix formatting issues

* refactor: change logic

* chore: rename id to deletionProcessId

* chore: remove redundant using

* fix: handler didn't have IRequestHandler<> and now properly returns response

* fix: CancelDeletionProcess return IdentityDeletionProcess

* chore: typo

* refactor: change to hardcoded datetime

* chore: change to hardcoded datetime

* refactor: change domain error

* fix: set TieridBeforeDeletion to null

* chore: rename tests

* refactor: get deletionProcess from StartDeletionProcessAsOwner

* refactor: fix tests

* refactor: change logic

* refactor: fix handler

* refactor: add assertion on database

* refactor: modify test

* fix: add check for ensure identity owns device

* refactor: rename & create optimized CreateHandler method

* refactor: change status check

* chore: remove unused error

* chore: fix nullable issue

* refactor: fix naming & optinal parameter

* chore: rename

* refactor: fix wrong method usage

* refactor: remove private Cancel method

* feat: add new error
chore: remove unused error

* refactor: change error message

* refactor: rely on the deletionProcess.Cancel method

* test: add new test when deletion process is in wrong status

* refactor: extract method & add more assertions

* test: add auditLog assertions

* refactor: set optional parameter

* fix: remove unused assertion

* chore: remove unused using

* refactor: assert DeletionProcessStatus

* refactor: add assertion

* chore: fix formatting issues

* chore: remove unused domain error

* refactor

* refactor: add missing assertions

* refactor: move CreateIdentity methods into TestDataGenerator

* chore: remove unused using

* refactor: acting only once

---------

Co-authored-by: Timo Notheisen <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Timo Notheisen <[email protected]>
* ci: test

* test: let test fail

* ci: add missing quote

* ci: correct path

* chore: install logger in all test projects

* chore: set default formatter for xml

* ci: use logger in all dotnet test calls

* ci: remove test pipeline

* test: install logger in remaining projects

* test: install logger in remaining projects

* test: remove duplicated references to GitHubActionsTestLogger

* ci: convert test script to sh

* ci: convert checkFormatting script to sh

* ci: fix checkFormatting script name

* test: remove intentionally failing test

* ci: try to not use logger for postgres integration tests

* ci: try to not include passed and skipped tests for sql server integration tests

* ci: make scripts executable

* chore: try to remove everything regarding SpecflowCucumberExporter

* chore: remove redundant backtick

* Revert "ci: try to not include passed and skipped tests for sql server integration tests"

This reverts commit 85dadf7.

* Revert "ci: try to not use logger for postgres integration tests"

This reverts commit 5b350c5.

* ci: set DOTNET_CONSOLE_ANSI_COLOR for all dotnet test actions

* ci: use github action to run transport tests

* chore: add "--no-build" flag to `dotnet publish` command in AdminCli's Dockerfile

* chore: remove "/property:WarningLevel=0" from all commands

* ci: let test fail

* chore: remove publish stage from Admin CLI Dockerfile

* chore: remove dotnet build from Admin CLI Dockerfile

* chore: fix compiler warnings

* Revert "ci: let test fail"

This reverts commit b25a129.

* Revert "ci: use github action to run transport tests"

This reverts commit fae8312.

* chore: remove unnecessary using directive
* feat: implement rejection of deletion process before approval

* chore: fix a typo

* feat: add reject identity deletion endpoint

* feat: add RejectedAt and RejectedByDevice properties

* chore: fix formatting

* chore: remove IdentityAddress from RejectDeletionProcessResponse

* chore: remove unused directives

* chore: line endings

* chore: remove unused directives

* refactor: use SystemTime.UtcNow

* refactor: use SystemTime

* refactor: extract into separate method

* chore: rename variable

* chore: rename variable

* refactor: remove ctor input parameter

* chore: remove redundant status update

* chore: rename input parameter

* chore: change the method order in code

* feat: add EnsureIdentityOwnsDevice method

* test: check CreatedAt value

* chore: reorganize lines

* test: update condition

* chore: reorganize lines

* refactor: remove redundant date variable

* chore: renamed mock repository variable to fake

* test: use identity's own device in test

* chore: rename class to plural

* test: add reject deletion process test case when device is not owned by identity

* test: use own device in test

* test: update acting to start deletion process with own device

* test: simplify method call

* refactor: use hardcoded date

* chore: rename variable

* refactor: attempt to start deletion process with own device

* test: change assertion

* refactor: remove redundant handler tests as they are covered by the domain ones

* chore: remove unused directives

* refactor: reorganize class so that ctors are on top and private methods below their public ones

* refactor: remove redundant assertion

* feat: ensure deletion process is approved by device owned by identity

* chore: move private Approve method beneath its first use

* refactor: use device owned by identity and make code uniform in similar tests

* refactor: use own device to approve deletion process

* test: update assertions

* test: add test when process is started by "not owned" device

* refactor: remove handler tests covered by domain tests

* feat: use RejectedAt instead of CreatedAt in dto

* refactor: rename method and update exception thrown

* test: update tests

* chore: remove redundant call

* test: add additional assertion

* test: update tests with additional assertions

* test: update assertions

* refactor: extract method

* test: update assertions

* fix: fix missing usings

* test: avoid having two acting statements

* chore: change error code, method name and error message

* feat: bring back RejectedAt and RejectedBy properties

* refactor: remove two actings

* Merge branch 'main' into nmshdb-44-rejection-of-deletion-process

* test: fix broken test

* chore: formatting

* test: fix tests

* test: fix tests

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@NikolaVetnic NikolaVetnic added the bug Something isn't working label Mar 7, 2024
@NikolaVetnic NikolaVetnic self-assigned this Mar 7, 2024
Copy link

coderabbitai bot commented Mar 7, 2024

Important

Auto Review Skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@NikolaVetnic
Copy link
Contributor Author

Pull request created by mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants