-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
146 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import pytest | ||
from thehive4py.client import TheHiveApi | ||
from thehive4py.errors import TheHiveError | ||
from thehive4py.types.custom_field import InputUpdateCustomField, OutputCustomField | ||
|
||
|
||
class TestTaskLogEndpoint: | ||
def test_create_and_list(self, thehive_admin: TheHiveApi): | ||
created_custom_field = thehive_admin.custom_field.create( | ||
custom_field={ | ||
"name": "my-field", | ||
"displayName": "My Field", | ||
"description": "...", | ||
"group": "default", | ||
"type": "string", | ||
"options": [], | ||
} | ||
) | ||
|
||
custom_fields = thehive_admin.custom_field.list() | ||
assert created_custom_field in custom_fields | ||
|
||
def test_delete( | ||
self, thehive_admin: TheHiveApi, test_custom_field: OutputCustomField | ||
): | ||
thehive_admin.custom_field.delete(custom_field_id=test_custom_field["_id"]) | ||
|
||
with pytest.raises(TheHiveError): | ||
thehive_admin.task_log.get(task_log_id=test_custom_field["_id"]) | ||
|
||
def test_update( | ||
self, thehive_admin: TheHiveApi, test_custom_field: OutputCustomField | ||
): | ||
|
||
custom_field_id = test_custom_field["_id"] | ||
update_fields: InputUpdateCustomField = { | ||
"displayName": "something else ...", | ||
"type": "float", | ||
} | ||
thehive_admin.custom_field.update( | ||
custom_field_id=custom_field_id, fields=update_fields | ||
) | ||
updated_custom_field = [ | ||
cf | ||
for cf in thehive_admin.custom_field.list() | ||
if cf["_id"] == custom_field_id | ||
][0] | ||
|
||
for key, value in update_fields.items(): | ||
assert updated_custom_field.get(key) == value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
__version__ = "2.0.0b1" | ||
__version__ = "2.0.0b2" | ||
|
||
from thehive4py.client import TheHiveApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from typing import List | ||
|
||
from thehive4py.endpoints._base import EndpointBase | ||
from thehive4py.types.custom_field import ( | ||
InputCustomField, | ||
InputUpdateCustomField, | ||
OutputCustomField, | ||
) | ||
|
||
|
||
class CustomFieldEndpoint(EndpointBase): | ||
def create(self, custom_field: InputCustomField) -> OutputCustomField: | ||
return self._session.make_request( | ||
"POST", path="/api/v1/customField", json=custom_field | ||
) | ||
|
||
def list(self) -> List[OutputCustomField]: | ||
return self._session.make_request("GET", path="/api/v1/customField") | ||
|
||
def delete(self, custom_field_id: str) -> None: | ||
return self._session.make_request( | ||
"DELETE", path=f"/api/v1/customField/{custom_field_id}" | ||
) | ||
|
||
def update(self, custom_field_id: str, fields: InputUpdateCustomField) -> None: | ||
return self._session.make_request( | ||
"PATCH", path=f"/api/v1/customField/{custom_field_id}", json=fields | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters