Skip to content

Commit

Permalink
[#6] Update ACL Documentation based on review
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonsen-92 committed Dec 16, 2020
1 parent c4089c7 commit 927e0b8
Showing 1 changed file with 158 additions and 7 deletions.
165 changes: 158 additions & 7 deletions doc/acl.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | [email protected]


### Request Payloads
Expand Down Expand Up @@ -67,7 +66,7 @@ HTTP Code | Status | Description
```

### Logic
using <a href="https://book.cakephp.org/4/en/orm/behaviors/tree.html" rel="notfollow">cakephp tree</a> behavior to get lft and rght from parent_id
using [cakephp tree](https://book.cakephp.org/4/en/orm/behaviors/tree.html) behavior to get lft and rght from parent_id

#### Validation
- parent_id: required and not empty
Expand Down Expand Up @@ -382,7 +381,6 @@ Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | [email protected]

### Response Payloads
HTTP Code | Status | Description
Expand Down Expand Up @@ -500,7 +498,6 @@ Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | [email protected]

### Request Payloads
Name | Type | Example Value
Expand Down Expand Up @@ -543,7 +540,7 @@ HTTP Code | Status | Description
```

### Logic
using <a href="https://book.cakephp.org/4/en/orm/behaviors/tree.html" rel="notfollow">cakephp tree</a> behavior to get lft and rght from parent_id
using [cakephp tree](https://book.cakephp.org/4/en/orm/behaviors/tree.html) behavior to get lft and rght from parent_id

#### Validation
- parent_id: required and not empty
Expand Down Expand Up @@ -724,20 +721,20 @@ Key | Value
--- | ---
Content-Type |*
Accept | application/json
Email | [email protected]

### Response Payloads
HTTP Code | Status | Description
--- | --- | ---
403 | Forbidden | Can not be deleted
404 | Not Found | User not found in database
500 | Internal Server Error | some un-handle error in server
200 | OK | OK
204 | No Content | No Content

### Logic
- root can not be deleted.
- root alias is 'controllers'.
- root parent_id is null.
- if the node has children, it should not be deleted

### Scenario Test

Expand All @@ -756,7 +753,161 @@ Response HTTP Status Code : 204
### Endpoint
POST /access/grant/:id

### Headers
Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | [email protected]

### Response Payloads
HTTP Code | Status | Description
--- | --- | ---
400 | Bad Request | Bad request payload
404 | Not Found | User not found in database
500 | Internal Server Error | some un-handle error in server
200 | OK | OK

```
{
"status_code": "CDC-400",
"status_message": "Bad Request",
"data": null
}
```

```
{
"status_code": "CDC-200",
"status_message": "OK",
"data": {
"id":1,
"aco_id": 1,
"aro_id": 1,
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
}
```

### Logic
- aro_id grab from header email.

### Scenario Test

#### Case : Negative Case 1

Response HTTP Status Code : 404

Response Payload :
```
{
"status_code": "cdc-404",
"status_message": "id not found in acos table",
"data": null
}
```

#### Case : Negative Case 2

Response HTTP Status Code : 400

Response Payload :
```
{
"status_code": "cdc-404",
"status_message": "access already exist for this user",
"data": null
}
```
#### Case : Positive Case

Response HTTP Status Code : 200

Response Payload :
```
{
"status_code": "CDC-200",
"status_message": "OK",
"data": {
"id":1,
"aco_id": 1,
"aro_id": 1,
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
}
```

## <a name="revoke"></a>REVOKE

### Endpoint
POST /access/revoke/:id

### Headers
Key | Value
--- | ---
Content-Type | application/json
Accept | application/json
Email | [email protected]

### Response Payloads
HTTP Code | Status | Description
--- | --- | ---
400 | Bad Request | Bad request payload
404 | Not Found | User not found in database
500 | Internal Server Error | some un-handle error in server
200 | OK | OK

```
{
"status_code": "CDC-400",
"status_message": "Bad Request",
"data": null
}
```

```
{
"status_code": "CDC-200",
"status_message": "OK",
"data": {
"id":1,
"aco_id": 1,
"aro_id": 1,
"created": "2020-10-28T08:58:13+00:00",
"modified": "2020-10-28T08:58:13+00:00"
}
}
```

### Logic
- aro_id grab from header email.

### Scenario Test

#### Case : Negative Case

Response HTTP Status Code : 404

Response Payload :
```
{
"status_code": "cdc-404",
"status_message": "access not found for this user",
"data": null
}
```
#### Case : Positive Case

Response HTTP Status Code : 200

Response Payload :
```
{
"status_code": "CDC-200",
"status_message": "Access Revoked",
"data": null
}
```

0 comments on commit 927e0b8

Please sign in to comment.