Skip to content

Commit

Permalink
Add file system endpoints (#134)
Browse files Browse the repository at this point in the history
* Run unittests for all PRs, not only the ones to main (#131)

* add fs endpoints

* fix bugs

* Fix small typos

* Add responses for ls

* Add responses for ls options

* Add tests for /head

* Small fixes and test files in tail

* Small fixes in tail and test file

* Small fixes in async client and checksum test file

* Add file test output

* Add test files for stat

* add more endpoints

* add responses

* Fix rm

* Add rm test

* Fix typo

* Fix simple upload and download

* Rename param

* Update _json_response

* Fix simple upload

---------

Co-authored-by: Eirini Koutsaniti <[email protected]>
Co-authored-by: Eirini Koutsaniti <[email protected]>
  • Loading branch information
3 people authored Nov 6, 2024
1 parent e4e0c15 commit a0e6fdf
Show file tree
Hide file tree
Showing 26 changed files with 758 additions and 10 deletions.
427 changes: 417 additions & 10 deletions firecrest/v2/AsyncClient.py

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions tests/v2/responses/checksum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"status_code": 200,
"response": {
"output": {
"message": "",
"algorithm": "SHA256",
"checksum": "67149111d45cf106eb92ab5be7ec08179bddea7426ddde7cfe0ae68a7cffce74"
}
}
}
14 changes: 14 additions & 0 deletions tests/v2/responses/chmod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status_code": 200,
"response": {
"output": {
"name": "/home/test1/xxx",
"type": "-",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxrwxrwx",
"lastModified": "2024-10-24T15:00:01",
"size": "0"
}
}
14 changes: 14 additions & 0 deletions tests/v2/responses/chown.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"status_code": 200,
"response": {
"output": {
"name": "/home/test1/xxx",
"type": "-",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxrwxrwx",
"lastModified": "2024-10-24T15:00:01",
"size": "0"
}
}
10 changes: 10 additions & 0 deletions tests/v2/responses/chown_not_permitted.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"status_code": 403,
"response": {
"errorType": "error",
"message": "chown: changing ownership of '/home/test1/xxx': Operation not permitted",
"data": null,
"user": "test1",
"authHeader": "Bearer"
}
}
4 changes: 4 additions & 0 deletions tests/v2/responses/delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"status_code": 204,
"response": null
}
6 changes: 6 additions & 0 deletions tests/v2/responses/file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"status_code": 200,
"response": {
"output": "ASCII text"
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/head.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n",
"contentType": "lines",
"startPosition": 0,
"endPosition": 10
}
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/head_bytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "1\n2\n3\n4",
"contentType": "bytes",
"startPosition": 0,
"endPosition": 7
}
}
}
9 changes: 9 additions & 0 deletions tests/v2/responses/head_bytes_exclude_trailing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"status_code": 200,
"response": {
"content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10",
"contentType": "bytes",
"startPosition": 0,
"endPosition": -7
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/head_lines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "1\n2\n3\n",
"contentType": "lines",
"startPosition": 0,
"endPosition": 3
}
}
}
9 changes: 9 additions & 0 deletions tests/v2/responses/head_lines_exclude_trailing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"status_code": 200,
"response": {
"content": "1\n2\n3\n4\n5\n6\n7\n8\n9\n",
"contentType": "lines",
"startPosition": 0,
"endPosition": -3
}
}
17 changes: 17 additions & 0 deletions tests/v2/responses/ls_home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"response": {
"output": [
{
"name": "bin",
"type": "d",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxr-xr-x",
"lastModified": "2022-03-15T11:33:15",
"size": "4096"
}
]
}
}
27 changes: 27 additions & 0 deletions tests/v2/responses/ls_home_dereference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"status_code": 200,
"response": {
"output": [
{
"name": "bin",
"type": "d",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxr-xr-x",
"lastModified": "2024-10-23T09:06:00",
"size": "4096"
},
{
"name": "link_to_file",
"type": "-",
"linkTarget": null,
"user": "root",
"group": "root",
"permissions": "rw-r--r--",
"lastModified": "2024-10-23T09:06:00",
"size": "0"
}
]
}
}
27 changes: 27 additions & 0 deletions tests/v2/responses/ls_home_hidden.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"status_code": 200,
"response": {
"output": [
{
"name": "bin",
"type": "d",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxr-xr-x",
"lastModified": "2022-03-15T11:33:15",
"size": "4096"
},
{
"name": ".bashrc",
"type": "-",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rw-r--r--",
"lastModified": "2022-05-07T15:11:50",
"size": "1177"
}
]
}
}
27 changes: 27 additions & 0 deletions tests/v2/responses/ls_home_recursive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"status_code": 200,
"response": {
"output": [
{
"name": "/home/test1//bin",
"type": "d",
"linkTarget": null,
"user": "test1",
"group": "users",
"permissions": "rwxr-xr-x",
"lastModified": "2024-10-23T09:06:00",
"size": "4096"
},
{
"name": "/home/test1/bin/file",
"type": "-",
"linkTarget": null,
"user": "root",
"group": "root",
"permissions": "rw-r--r--",
"lastModified": "2024-10-23T09:06:00",
"size": "0"
}
]
}
}
27 changes: 27 additions & 0 deletions tests/v2/responses/ls_home_uid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"status_code": 200,
"response": {
"output": [
{
"name": "bin",
"type": "d",
"linkTarget": null,
"user": "1000",
"group": "100",
"permissions": "rwxr-xr-x",
"lastModified": "2024-10-23T09:06:00",
"size": "4096"
},
{
"name": "link_to_file",
"type": "l",
"linkTarget": "bin/file",
"user": "0",
"group": "0",
"permissions": "rwxrwxrwx",
"lastModified": "2024-10-23T09:10:04",
"size": "8"
}
]
}
}
10 changes: 10 additions & 0 deletions tests/v2/responses/ls_invalid_path.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"status_code": 404,
"response": {
"errorType": "error",
"message": "ls: cannot access '/home/test23': No such file or directory",
"data": null,
"user": "test1",
"authHeader": "Bearer token"
}
}
17 changes: 17 additions & 0 deletions tests/v2/responses/stat.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"response": {
"output": {
"mode": 33188,
"ino": 2299756,
"dev": 76,
"nlink": 1,
"uid": 0,
"gid": 0,
"size": 27,
"atime": 1729771818,
"ctime": 1729676630,
"mtime": 1729676630
}
}
}
17 changes: 17 additions & 0 deletions tests/v2/responses/stat_dereference.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"status_code": 200,
"response": {
"output": {
"mode": 16877,
"ino": 2297286,
"dev": 76,
"nlink": 1,
"uid": 1000,
"gid": 100,
"size": 4096,
"atime": 1729674368,
"ctime": 1729674360,
"mtime": 1729674360
}
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/tail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n",
"contentType": "lines",
"startPosition": 10,
"endPosition": -1
}
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/tail_bytes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "\n11\n12\n",
"contentType": "bytes",
"startPosition": -7,
"endPosition": -1
}
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/tail_bytes_exclude_beginning.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "4\n5\n6\n7\n8\n9\n10\n11\n12\n",
"contentType": "bytes",
"startPosition": 7,
"endPosition": -1
}
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/tail_lines.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "10\n11\n12\n",
"contentType": "lines",
"startPosition": -3,
"endPosition": -1
}
}
}
11 changes: 11 additions & 0 deletions tests/v2/responses/tail_lines_exclude_beginning.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"status_code": 200,
"response": {
"output": {
"content": "3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n",
"contentType": "lines",
"startPosition": 3,
"endPosition": -1
}
}
}
8 changes: 8 additions & 0 deletions tests/v2/responses/view.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"status_code": 200,
"response": {
"output": {
"output": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n"
}
}
}

0 comments on commit a0e6fdf

Please sign in to comment.