Skip to content

Commit

Permalink
Consumer Api: Deletion of Files, Tokens and Relationship Templates (#934
Browse files Browse the repository at this point in the history
)

* feat: Add file deletion command, handler, repository and controller

* feat: Add file deletion command to Consumer Api SDK

* feat: Add file deletion command to bruno

* feat: Add command, handler and repository method for delete token endpoint

* feat: Add delete token endpoint to bruno and consumer api sdk

* feat: Migrate DB to make relationship template nullable in relationship

* feat: Make Relationship Template nullable in Relationship

* feat: Add controller, command, handler, validator, sdk method and bruno file for relationship template deletion

* chore: Add user b to bruno variables and update passwords

* chore: Add/update bruno files for multiple relationship endpoints

* chore: Make relationship template nullable in sdk types

* test: Add integration test for relationship template deletion

* chore: Add tests for deletion, rewrite existing ones, refactor backing code

* chore: Switch order for file deletion

* chore: Move owner checks to domain classes and rewrite domain exceptions

* chore: Add unit tests for deletion check functions

* chore: Change function and variable names to comply with convention

* chore: Simplify used test functions

* chore: Simplify test function

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
MH321Productions and mergify[bot] authored Nov 11, 2024
1 parent 5ddcd95 commit 5bf1ab0
Show file tree
Hide file tree
Showing 76 changed files with 1,601 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
meta {
name: Get OAuth Token (B)
type: http
seq: 2
}

post {
url: {{auth.url}}
body: formUrlEncoded
auth: none
}

body:form-urlencoded {
grant_type: password
username: {{auth.username_b}}
password: {{auth.password_b}}
client_id: {{auth.client_id}}
client_secret: {{auth.client_secret}}
}

vars:post-response {
jwt.token: res.body.access_token
jwt.expires_in: res.body.expires_in
}
15 changes: 15 additions & 0 deletions Applications/ConsumerApi/src/http/Files/Delete File.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: /Files/{id}
type: http
seq: 5
}

delete {
url: {{baseUrl}}/Files/{{id}}
body: none
auth: inherit
}

vars:pre-request {
id: FILF5vUtJstbmLAr8A0z
}
2 changes: 1 addition & 1 deletion Applications/ConsumerApi/src/http/Files/Upload File.bru
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ post {
body:multipart-form {
content: @file(C:\Users\mherrman\Documents\Scrum Workshop.md)
cipherHash: AAAA
owner: id1CsU6VwBMgBA4TLc61nj895ZD1mPjbddNW
owner: did:e:localhost:dids:0f3e40164b6c495c28674f
expiresAt: 2024-12-07
encryptedProperties: AAAA
ownerSignature: AAAA
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: /RelationshipTemplates/{id}
type: http
seq: 4
}

delete {
url: {{baseUrl}}/RelationshipTemplates/{{id}}
body: none
auth: inherit
}

vars:pre-request {
id: RLTpUznhYQsBse545qLZ
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ meta {
}

get {
url: {{baseUrl}}/RelationshipTemplates?Ids=RLTEb4Zmk5CZwoKYgLVT
url: {{baseUrl}}/RelationshipTemplates?Ids=RLTpUznhYQsBse545qLZ
body: none
auth: inherit
}

query {
Ids: RLTEb4Zmk5CZwoKYgLVT
params:query {
Ids: RLTpUznhYQsBse545qLZ
~PageNumber: 1
~PageSize: 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Accept
type: http
seq: 1
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Accept
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: RELquh4tVcr3zOTQGti7
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Decompose
type: http
seq: 5
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Decompose
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Reject
type: http
seq: 2
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Reject
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Revoke
type: http
seq: 3
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Revoke
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Terminate
type: http
seq: 4
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Terminate
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ post {

body:json {
{
"relationshipTemplateId": "",
"relationshipTemplateId": "RLTpUznhYQsBse545qLZ",
"content": ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ get {
}

vars:pre-request {
RelationshipId: RELUY2h3HVSFfYkdli0P
RelationshipId: RELquh4tVcr3zOTQGti7
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ meta {
}

get {
url: {{baseUrl}}/Relationships?Ids=REL6mRNeRz42f4R2OTKn
url: {{baseUrl}}/Relationships?Ids=RELquh4tVcr3zOTQGti7
body: none
auth: inherit
}

query {
Ids: REL6mRNeRz42f4R2OTKn
params:query {
Ids: RELquh4tVcr3zOTQGti7
~PageNumber: 1
~PageSize: 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Reactivate/Accept
type: http
seq: 2
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Reactivate/Accept
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Reactivate
type: http
seq: 1
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Reactivate
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Reactivate/Reject
type: http
seq: 3
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Reactivate/Reject
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta {
name: /Relationships/{id}/Reactivate/Revoke
type: http
seq: 4
}

put {
url: {{baseUrl}}/Relationships/{{id}}/Reactivate/Revoke
body: json
auth: inherit
}

body:json {
{
"creationResponseContent": ""
}
}

vars:pre-request {
id: REL8DyBnfWYiXCzxkMiv
}
15 changes: 15 additions & 0 deletions Applications/ConsumerApi/src/http/Tokens/Delete Token.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
meta {
name: /Tokens/{id}
type: http
seq: 4
}

delete {
url: {{baseUrl}}/Tokens/{{id}}
body: none
auth: inherit
}

vars:pre-request {
id: TOKsjPynl0FHYJzHnkIo
}
3 changes: 2 additions & 1 deletion Applications/ConsumerApi/src/http/Tokens/List Tokens.bru
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ get {
auth: inherit
}

query {
params:query {
~ids: TOKsjPynl0FHYJzHnkIo
~PageNumber: 1
~PageSize: 1
}
4 changes: 3 additions & 1 deletion Applications/ConsumerApi/src/http/environments/Local.bru
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ vars {
baseUrl: http://localhost:8081/api/v1
auth.url: http://localhost:8081/connect/token
auth.username: USRa
auth.password: a
auth.password: Aaaaaaaa1!
auth.username_b: USRb
auth.password_b: Bbbbbbbb1!
auth.client_id: test
auth.client_secret: test
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Backbone.ConsumerApi.Sdk.Endpoints.Files.Types;

namespace Backbone.ConsumerApi.Tests.Integration.Contexts;

public class FilesContext
{
public readonly Dictionary<string, FileMetadata> Files = [];
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using Backbone.ConsumerApi.Sdk.Endpoints.Relationships.Types;
using Backbone.ConsumerApi.Sdk.Endpoints.RelationshipTemplates.Types.Responses;

namespace Backbone.ConsumerApi.Tests.Integration.Contexts;

public class RelationshipsContext
{
public readonly Dictionary<string, Relationship> Relationships = new();
public readonly Dictionary<string, CreateRelationshipTemplateResponse> CreateRelationshipTemplateResponses = new();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@Integration
Feature: DELETE /Files/{id}

User deletes a File

Scenario: Deleting a File actually removes it
Given Identity i
And File f created by i
When i sends a DELETE request to the /Files/f.Id endpoint
And i sends a GET request to the /Files/f.Id endpoint
Then the response status code is 404 (Not Found)
Loading

0 comments on commit 5bf1ab0

Please sign in to comment.