-
Notifications
You must be signed in to change notification settings - Fork 1
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
Uniqueness of key
for RelationshipAttributes
#319
Uniqueness of key
for RelationshipAttributes
#319
Conversation
Codecov ReportAttention: Patch coverage is
|
…not in deletion in any way
I wanted to avoid too much redundancy, but will add a few more tests. :) |
Hahah sure, I wanted to at least subtly differentiate whether a Request is messed up and therefore cannot be accepted regardless of the user input (this is where the concept of unacceptable Requests comes into play), or whether the user has provided inappropriate input and can accept (or create) the Request by correcting their input. With messed up Requests I throw an error, with inappropriate user input I return a negative ValidationResult. |
…f github.com:nmshd/runtime into feature/uniqueness-of-key-for-relationshipattributes
…ifferent value type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll continue tomorrow. :)
...src/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.ts
Outdated
Show resolved
Hide resolved
...n/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts
Outdated
Show resolved
Hide resolved
...src/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.ts
Outdated
Show resolved
Hide resolved
…f github.com:nmshd/runtime into feature/uniqueness-of-key-for-relationshipattributes
...ages/consumption/src/modules/requests/utility/validateRelationshipAttributesWithinRequest.ts
Outdated
Show resolved
Hide resolved
...ages/consumption/src/modules/requests/utility/validateRelationshipAttributesWithinRequest.ts
Outdated
Show resolved
Hide resolved
packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts
Show resolved
Hide resolved
...odules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts
Show resolved
Hide resolved
…gardless of value of mustBeAccepted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blind Approval for @Milena-Czierlinski
* refactor: preapare CreateAttributeRequestItemProcessor to add more validation * feat: add validation for CreateAttributeRequestItemProcessor * test: CreateAttributeRequestItemProcessor key validation * fix: uniqueness for key only instead of pair of owner and key * fix: failing test * test: ensure key uniqueness in attributes.test * test: ensure key uniqueness in CreateRelationshipAttributeRequestItemDVO.test * feat: use database language every database understands * test: ensure key uniqueness only for constant ownership * fix: too late clean up of Attributes * feat: ensure key uniqueness only for RelationshipAttributes that are not in deletion in any way * refactor: extract function call as auxiliary function * refactor: put afterEach block inside describe block * feat: ensure key uniqueness for Recipient within CreateAttributeRequestItemProcessor * refactor: auxiliary function can be applied to queries as well * feat: ensure key uniqueness for Sender within ReadAttributeRequestItemProcessor * feat: ensure key uniqueness only for constant value type * fix: failing tests with async canCreateOutgoingRequestItem method * feat: key uniqueness for Recipient within ReadAttributeRequestItemProcessor * feat: ensure key uniquess for empty owner as placeholder as well * refactor: simplify error message * refactor: move validation to canAccept method * refactor: standardize error messages * test: ensure key uniqueness with empty owner * test: move tests to canAccept block * fix: call accept instead of canAccept * test: refactor canAccept test with SuccessfulValidationResult * test: make tests independent of each other * feat: ensure key uniqueness for empty owner queried with ReadAttributeRequestItem * feat: ensure key uniqueness on Sender site of ProposeAttributeRequestItemProcessor * feat: ensure key uniqueness on Recipient site of ProposeAttributeRequestItemProcessor * refactor: standardize error messages * feat: prohibit Requests that create more than one RelationshipAttribute with same key * fix: title type * test: key uniqueness of incomingRequestsController * test: key uniqueness of OutgoingRequestsController * refactor: remove recursion of IncomingRequestsController * refactor: keep RequestItemGroup in mind * refactor: use auxiliary method for clearness * feat: handle empty owner in IncomingRequestsController and OutgoingRequestsController * test: ensure key uniqueness for empty owner * refactor: move validation from canDecide to canAccept * fix: failing IncomingRequestsController test * test: ensure key uniqueness with RequestItemGroups * fix: wrong DecideRequestParameters for RequestItemGroups * feat: use already known separation sequence * feat: give better validation function name * refactor: do not break existing code blocks anymore * fix: error due to incorrect merging * test: ensure key uniqueness with ProposeAttributeRequestItem * chore: descriptive values should not start with capital letter * refactor: rename error code * feat: distinguish between user mistake and deformed Request * feat: throwing instead of returning error if Request is deformed * feat: reuse key uniqueness error * feat: distinguish between deformed Requests and wrong accept parameters * test: RequestItem cannot be accepted due to incorrect params of User * fix: failing test due to void return * feat: self-explanatory variable names * refactor: more renaming of variables * refactor: unify renaming * feat: simplify error message for unknown recipient of Request * feat: incorporate some review comments * fix: failing test due to wrong error format * feat: incorporate review comment * refactor: prepare reusability of code * fix: error due to merge * feat: use JSON.stringify() instead of own method for extracting identifiers * refactor: reduce redundancy by move auxiliary functions to different file * feat: inform user what key would be redundantly in use * feat: incorporate some review comments * feat: incoporate review comments * refactor: change order of thrown errors * test: can propose and query RelationshipAttribute with same key but different value type * feat: incorporate review comments * refactor: simplify extraction of fragments of mustBeAcceptedItems * refactor: further simplification of extraction of fragments of mustBeAcceptedItems * refactor: simplify extraction of fragments of accepte items * fix: returned instead of continued * test: RequestItem cannot be accepted if key uniqueness is violated regardless of value of mustBeAccepted --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Milena Czierlinski <milena.czierlinski@js-soft.com>
… that has passed (#369) * chore: respect expireation date of request when creating request and sending message * chore: white space * Update packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts Co-authored-by: Julian König <33655937+jkoenig134@users.noreply.github.com> * Update packages/consumption/src/consumption/ConsumptionCoreErrors.ts Co-authored-by: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> * chore: fix test misstake * chore: fix tests * chore: PR comments * chore: revert Date changes * chore: pr comments * chore: test * chore: fix flaky test * Update packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts Co-authored-by: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> * Update packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts Co-authored-by: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> * chore: improve test performance * chore: improve test performance * chore: PR comments * refactor: add empty lines * Uniqueness of `key` for RelationshipAttributes (#319) * refactor: preapare CreateAttributeRequestItemProcessor to add more validation * feat: add validation for CreateAttributeRequestItemProcessor * test: CreateAttributeRequestItemProcessor key validation * fix: uniqueness for key only instead of pair of owner and key * fix: failing test * test: ensure key uniqueness in attributes.test * test: ensure key uniqueness in CreateRelationshipAttributeRequestItemDVO.test * feat: use database language every database understands * test: ensure key uniqueness only for constant ownership * fix: too late clean up of Attributes * feat: ensure key uniqueness only for RelationshipAttributes that are not in deletion in any way * refactor: extract function call as auxiliary function * refactor: put afterEach block inside describe block * feat: ensure key uniqueness for Recipient within CreateAttributeRequestItemProcessor * refactor: auxiliary function can be applied to queries as well * feat: ensure key uniqueness for Sender within ReadAttributeRequestItemProcessor * feat: ensure key uniqueness only for constant value type * fix: failing tests with async canCreateOutgoingRequestItem method * feat: key uniqueness for Recipient within ReadAttributeRequestItemProcessor * feat: ensure key uniquess for empty owner as placeholder as well * refactor: simplify error message * refactor: move validation to canAccept method * refactor: standardize error messages * test: ensure key uniqueness with empty owner * test: move tests to canAccept block * fix: call accept instead of canAccept * test: refactor canAccept test with SuccessfulValidationResult * test: make tests independent of each other * feat: ensure key uniqueness for empty owner queried with ReadAttributeRequestItem * feat: ensure key uniqueness on Sender site of ProposeAttributeRequestItemProcessor * feat: ensure key uniqueness on Recipient site of ProposeAttributeRequestItemProcessor * refactor: standardize error messages * feat: prohibit Requests that create more than one RelationshipAttribute with same key * fix: title type * test: key uniqueness of incomingRequestsController * test: key uniqueness of OutgoingRequestsController * refactor: remove recursion of IncomingRequestsController * refactor: keep RequestItemGroup in mind * refactor: use auxiliary method for clearness * feat: handle empty owner in IncomingRequestsController and OutgoingRequestsController * test: ensure key uniqueness for empty owner * refactor: move validation from canDecide to canAccept * fix: failing IncomingRequestsController test * test: ensure key uniqueness with RequestItemGroups * fix: wrong DecideRequestParameters for RequestItemGroups * feat: use already known separation sequence * feat: give better validation function name * refactor: do not break existing code blocks anymore * fix: error due to incorrect merging * test: ensure key uniqueness with ProposeAttributeRequestItem * chore: descriptive values should not start with capital letter * refactor: rename error code * feat: distinguish between user mistake and deformed Request * feat: throwing instead of returning error if Request is deformed * feat: reuse key uniqueness error * feat: distinguish between deformed Requests and wrong accept parameters * test: RequestItem cannot be accepted due to incorrect params of User * fix: failing test due to void return * feat: self-explanatory variable names * refactor: more renaming of variables * refactor: unify renaming * feat: simplify error message for unknown recipient of Request * feat: incorporate some review comments * fix: failing test due to wrong error format * feat: incorporate review comment * refactor: prepare reusability of code * fix: error due to merge * feat: use JSON.stringify() instead of own method for extracting identifiers * refactor: reduce redundancy by move auxiliary functions to different file * feat: inform user what key would be redundantly in use * feat: incorporate some review comments * feat: incoporate review comments * refactor: change order of thrown errors * test: can propose and query RelationshipAttribute with same key but different value type * feat: incorporate review comments * refactor: simplify extraction of fragments of mustBeAcceptedItems * refactor: further simplification of extraction of fragments of mustBeAcceptedItems * refactor: simplify extraction of fragments of accepte items * fix: returned instead of continued * test: RequestItem cannot be accepted if key uniqueness is violated regardless of value of mustBeAccepted --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Milena Czierlinski <milena.czierlinski@js-soft.com> * chore: prettier * chore: pr comments --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Julian König <33655937+jkoenig134@users.noreply.github.com> Co-authored-by: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> Co-authored-by: Milena Czierlinski <milena.czierlinski@js-soft.com> Co-authored-by: Britta Stallknecht <146106656+britsta@users.noreply.github.com>
Readiness checklist
Description
In each Relationship, there should only be at most one RelationshipAttribute for each Relationship context for a given trio of
value.@type
,owner
andkey
.Validation To Be Added
It is probably only necessary to ensure the uniqueness of the
key
in those cases in which new RelationshipAttributes (ThirdPartyRelationshipAttributes explicitly excluded) are created. This means, validation needs to be added for the following cases:query
.query
.attribute
to be created.To be sure, the validation is added on both sides when the Request is created and when the Request is received. Also note the following details:
key
, the creation of such a Request is prevented by early iteration through the RequestItems. Additionally, an error would be thrown on the side of the Recipient of the Request in the unlikely event that it has received such a Request.Validation Not To Be Added
When it comes to existing RelationshipAttributes that are shared and lead to the creation of ThirdPartyRelationshipAttributes, no further validation needs to be added. There are three reasons for this:
key
is already ensured when the initial RelationshipAttributes are created.key
again, as it can happen during the succession of RelationshipAttributes that there is another existing RelationshipAttribute with the samekey
that is to be read.Open Questions
key
and both accept it before they have received the response from their counterpart by synchronization. This can possibly be solved by forcing an early synchronization.key
. This can perhaps be solved by adding a new ResponseItem.Further Notes
applyIncomingResponseItem
method of the various RequestItemProcessors that prevent the creation of a RelationshipAttribute with an already existingkey
, as this would lead to inconsistent data sets between the two Identities of the Relationship.