Skip to content

Commit 64d1a1b

Browse files
jessevzRick van der ZwetrixvetJesse van Zutphen (DBS)
authored
Apiv2 (#1128)
* Add compression support JSON:API responses can be potentially be quite large, especially since no minification to the JSON output is performed. Adding deflate compression with reduce transfer sizes. * WIP: Add extra development tooling * WIP: Start conversion of hashtopolis to new JSON:API standard * WIP: Start of GET of JSON:API implementation Focus on working on Users, GlobalPermissionGroups and AccessGroups * Fix ensure consistent composer packages get installed. This file was never commited and missed, due to the wildcard *.lock pattern set in .gitigore https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control * Fix expansion parameter not working. Rename to reflect new naming (include) * Cosmetic: Rename variables to match new meaning It is confusing to mix expand with include. Thus rename all variables in python test code from expand to include. * Add interactive debugging of pytest unit files The hashtopolis.py cannot be debugged with default Interactive debugging of VScode debugging of pytests. Thus make a small workaround based of the idea: https://stackoverflow.com/questions/62419998/how-can-i-get-pytest-to-not-catch-exceptions/62563106#62563106 * WIP: Start working on delete and creation actions * Fix 500 returned when page is not found Should be 404, how-ever this trow was not captured, due to incorrect ordering. * WIP: Innitial support for PATCH/CREATE operations * WIP: All unit tests complete. GET mostly implemented - PATCH/DELETE requires mapping to new format. - Helpers need some thinking on request/response. - Relation updates needs to be implemented. * WIP: Need ER relations for CREATE When creating an object the ER relations are sent via JSON:API how-ever without an formal definition, there is no way of knowing whether something is considered an relation. * WIP: Example model for CREATE in client Add PoC conversion using Django tooling for reference purposes. This could be used as base for creating objects within the python libary (also to do some client-side checking as well). * Updated PHP dependencies * Refactor pagination to adhere to JSON:API standards - Updated pagination parameters from 'page[after]' and 'page[size]' to 'page[offset] and 'page[limit'] - This change aligns with the JSON:API specification for pagination (https://jsonapi.org/format/#fetching-pagination) * Refactored links object to adhere to JSON:API standard -changed 'page[after]' and 'page[size] to 'page[offset]' and 'page[limit]' in the link objects * feat: Add support for limit queries in ORM * Made pagination and sorting working by fixing some logic bugs * Added more input filtering for the Limit filter * Fixed the location header to comply to the JSON API standard in case of an POST request * WIP: Made start to link first and last attribute in json response to GET requests for pagination * Added page size exceeded error handling and started implementing link next and previous for pagination * FEAT: Implemented first and last in paginated json response * FEAT: Implemented previous and next within JSON pagination response * FEAT: Made PATCH request compliant to JSON API 1.1 * FEAT made patch To-One relationship compliant to JSON API standard * FEAT made get request to relationship working also throught intermediate tables * FEAT made pagination in to many relationships work * FEAT implemented patching to many relationships * FEAT added to many relationship from cracker to task in API * FEAT added to many relationship from crackerType to task in API * FEAT implemented delete to many relationship link and fixed bug in patch to many relationship link * FEAT fixed bug in PATCH to many relation and implemented POST to many relation * FEAT made patchOne compliant to JSON API 1.1 standard * FEAT fix a bug withing pagination and ordering and made Post one compliant to JSON API 1.1 * FEAT updated the tests to adhere to JSON API spec * FEAT added tests for pagination * clean up pagination test * Added range validation to validating data * Added a json response moduel for the responses * Added function to validate if its allowed to mutate DBA fields * Fixed inconsitency in color len in task feautures * Added test that will verify database size constraint * FEAT: made helper API endpoints compliant to json API standard, by putting no resource record responses in the metadata --------- Co-authored-by: Rick van der Zwet <[email protected]> Co-authored-by: Rick van der Zwet <[email protected]> Co-authored-by: Jesse van Zutphen (DBS) <[email protected]>
1 parent 28edceb commit 64d1a1b

File tree

73 files changed

+7955
-2021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+7955
-2021
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"xdebug.php-debug",
1414
"bmewburn.vscode-intelephense-client",
1515
"editorconfig.editorconfig",
16+
"eamodio.gitlens",
1617
"github.vscode-pull-request-github",
1718
"ms-python.python",
1819
"ms-python.flake8",

.editorconfig

Lines changed: 900 additions & 900 deletions
Large diffs are not rendered by default.

.vscode/launch.json

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,38 @@
6363
}
6464
},
6565
{
66-
"name": "Python: File",
67-
"type": "python",
68-
"request": "launch",
69-
"program": "${file}",
70-
"justMyCode": true
66+
"name": "Python: htcli (list Users with Include)",
67+
"type": "python",
68+
"request": "launch",
69+
"program": "./ci/apiv2/htcli.py",
70+
"args": ["list", "Users", "-v", "DEBUG", "--include", "globalPermissionGroup"],
71+
"justMyCode": true
72+
},
73+
{
74+
"name": "Python: htcli run delete-test-data",
75+
"type": "python",
76+
"request": "launch",
77+
"program": "./ci/apiv2/htcli.py",
78+
"args": ["run", "delete-test-data", "--commit"],
79+
"justMyCode": true
80+
},
81+
{
82+
"name": "Python: Debug pytest file",
83+
"type": "python",
84+
"request": "launch",
85+
"module": "pytest",
86+
"args": ["${file}", "--exitfirst"],
87+
"justMyCode": true,
88+
"env": {
89+
"_PYTEST_RAISE": "1"
90+
},
91+
},
92+
{
93+
"name": "Python: File",
94+
"type": "python",
95+
"request": "launch",
96+
"program": "${file}",
97+
"justMyCode": true
7198
}
7299
],
73100
"inputs": [

ci/apiv2/HACKING.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ TOKEN=$(curl -X POST --user admin:hashtopolis http://localhost:8080/api/v2/auth/
99

1010
Fetch object:
1111
```
12-
curl --header "Content-Type: application/json" -X GET --header "Authorization: Bearer $TOKEN" 'http://localhost:8080/api/v2/ui/hashlists/1?expand=hashes' -d '{}'
12+
curl --compressed --header "Authorization: Bearer $TOKEN" -g 'http://localhost:8080/api/v2/ui/hashtypes?page[size]=5'
1313
```
1414

1515
Access database:
@@ -23,6 +23,12 @@ docker exec $(docker ps -aqf "ancestor=mysql:8.0") mysql -u root -phashtopolis -
2323
docker exec $(docker ps -aqf "ancestor=mysql:8.0") tail -f /tmp/mysql_all.log
2424
```
2525

26+
Shortcut for testing within development setup:
27+
```
28+
cd ~/src/hashtopolis/server/ci/apiv2
29+
pytest --exitfirst --last-failed
30+
```
31+
2632
### paper flipchart scribbles
2733

2834
#### v2 beta

ci/apiv2/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import os
2+
import pytest
3+
4+
if os.getenv('_PYTEST_RAISE', "0") != "0":
5+
6+
@pytest.hookimpl(tryfirst=True)
7+
def pytest_exception_interact(call):
8+
raise call.excinfo.value
9+
10+
@pytest.hookimpl(tryfirst=True)
11+
def pytest_internalerror(excinfo):
12+
raise excinfo.value
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"typeName": "generic",
2+
"typeName": "generic2",
33
"isChunkingAvailable": true
44
}

ci/apiv2/dummy.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
components:
2+
schemas:
3+
Hash:
4+
type: object
5+
properties:
6+
id:
7+
type: integer
8+
minimum: 1
9+
readOnly: true
10+
userMembers:
11+
type: array
12+
items:
13+
$ref: #/components/schemas/User
14+
uniqueItems: true

0 commit comments

Comments
 (0)