Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions archivist/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

from .asset import Asset
from .constants import (
ASSET_BEHAVIOURS,
ASSETS_SUBPATH,
ASSETS_LABEL,
CONFIRMATION_STATUS,
Expand All @@ -39,13 +40,6 @@
from .errors import ArchivistBadFieldError, ArchivistNotFoundError
from .utils import selector_signature

# These are now hardcoded and not user-selectable. Eventually they will be removed from
# the backend API and removed from this package.
BEHAVIOURS = [
"Attachments",
"RecordEvidence",
]

LOGGER = getLogger(__name__)


Expand Down Expand Up @@ -140,7 +134,7 @@ def create(
LOGGER.debug("Create Asset %s", attrs)
# default behaviours are added first - any set in user-specified fixtures or
# in the method args will overide...
newprops = _deepmerge({"behaviours": BEHAVIOURS}, props)
newprops = _deepmerge({"behaviours": ASSET_BEHAVIOURS}, props)
data = self.__params(newprops, attrs)
return self.create_from_data(data, confirm=confirm)

Expand Down
7 changes: 7 additions & 0 deletions archivist/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
SEP = "/"
VERBSEP = ":"

# These are now hardcoded and not user-selectable. Eventually they will be removed from
# the backend API and removed from this package.
ASSET_BEHAVIOURS = [
"Attachments",
"RecordEvidence",
]

# define in MIME canonical form
HEADERS_REQUEST_TOTAL_COUNT = "X-Request-Total-Count"
HEADERS_TOTAL_COUNT = "X-Total-Count"
Expand Down
3 changes: 2 additions & 1 deletion examples/access_policy_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from os import getenv

from archivist.archivist import Archivist
from archivist.constants import ASSET_BEHAVIOURS


def main():
Expand Down Expand Up @@ -64,7 +65,7 @@ def main():
{
"asset_attributes_read": ["toner_colour", "toner_type"],
"asset_attributes_write": ["toner_colour"],
"behaviours": ["Attachments", "RecordEvidence"],
"behaviours": ASSET_BEHAVIOURS,
"event_arc_display_type_read": ["toner_type", "toner_colour"],
"event_arc_display_type_write": ["toner_replacement"],
"include_attributes": [
Expand Down
5 changes: 2 additions & 3 deletions examples/sbom_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from warnings import filterwarnings

from archivist.archivist import Archivist
from archivist.assets import BEHAVIOURS
from archivist.constants import SBOM_PACKAGE, SBOM_RELEASE
from archivist.constants import ASSET_BEHAVIOURS, SBOM_PACKAGE, SBOM_RELEASE
from archivist.proof_mechanism import ProofMechanism
from archivist.utils import get_auth

Expand Down Expand Up @@ -43,7 +42,7 @@ def sbom_release(arch, release, sbom_filename):
],
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand Down
4 changes: 2 additions & 2 deletions examples/scan_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from warnings import filterwarnings

from archivist.archivist import Archivist
from archivist.assets import BEHAVIOURS
from archivist.constants import ASSET_BEHAVIOURS
from archivist.proof_mechanism import ProofMechanism
from archivist.utils import get_auth

Expand Down Expand Up @@ -49,7 +49,7 @@ def scan_test(arch, datestring, scanned_expected=False):
],
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": asset_name,
Expand Down
3 changes: 2 additions & 1 deletion functests/execaccess_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from uuid import uuid4

from archivist.archivist import Archivist
from archivist.constants import ASSET_BEHAVIOURS
from archivist.utils import get_auth

# pylint: disable=fixme
Expand Down Expand Up @@ -44,7 +45,7 @@
ACCESS_PERMISSIONS = [
{
"subjects": [],
"behaviours": ["Attachments", "RecordEvidence"],
"behaviours": ASSET_BEHAVIOURS,
"include_attributes": [
"arc_display_name",
"arc_display_type",
Expand Down
4 changes: 2 additions & 2 deletions functests/execassets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from uuid import uuid4

from archivist.archivist import Archivist
from archivist.assets import BEHAVIOURS
from archivist.constants import ASSET_BEHAVIOURS
from archivist.logger import set_logger
from archivist.proof_mechanism import ProofMechanism
from archivist.utils import get_auth
Expand Down Expand Up @@ -39,7 +39,7 @@
]
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand Down
4 changes: 2 additions & 2 deletions functests/execpublicassets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from unittest import TestCase

from archivist.archivist import Archivist
from archivist.assets import BEHAVIOURS
from archivist.constants import ASSET_BEHAVIOURS
from archivist.logger import set_logger
from archivist.proof_mechanism import ProofMechanism
from archivist.timestamp import now_timestamp
Expand Down Expand Up @@ -40,7 +40,7 @@
]
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand Down
3 changes: 2 additions & 1 deletion unittests/testaccess_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from archivist.archivist import Archivist
from archivist.constants import (
ASSET_BEHAVIOURS,
ROOT,
HEADERS_REQUEST_TOTAL_COUNT,
HEADERS_TOTAL_COUNT,
Expand Down Expand Up @@ -54,7 +55,7 @@
"subjects/6a951b62-0a26-4c22-a886-1082297b063b",
"subjects/a24306e5-dc06-41ba-a7d6-2b6b3e1df48d",
],
"behaviours": ["Attachments", "RecordEvidence"],
"behaviours": ASSET_BEHAVIOURS,
"include_attributes": [
"arc_display_name",
"arc_display_type",
Expand Down
40 changes: 20 additions & 20 deletions unittests/testassetsconstants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from unittest import TestCase

from archivist.archivist import Archivist
from archivist.assets import BEHAVIOURS
from archivist.constants import (
ASSET_BEHAVIOURS,
ASSETS_LABEL,
ASSETS_SUBPATH,
ATTACHMENTS_LABEL,
Expand Down Expand Up @@ -91,7 +91,7 @@
],
}
REQUEST = {
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_firmware_version": "1.0",
Expand All @@ -109,7 +109,7 @@
}
REQUEST_KWARGS = {
"json": {
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_firmware_version": "1.0",
Expand All @@ -132,7 +132,7 @@
}
RESPONSE = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": {
"arc_firmware_version": "1.0",
"arc_serial_number": "vtl-x4-07",
Expand All @@ -159,7 +159,7 @@
]
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand All @@ -173,7 +173,7 @@
}
REQUEST_EXISTS_KWARGS = {
"json": {
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand All @@ -192,7 +192,7 @@
}
RESPONSE_EXISTS = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": {
"arc_display_name": ASSET_NAME,
"arc_namespace": "namespace",
Expand All @@ -216,7 +216,7 @@
]
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand All @@ -236,7 +236,7 @@
}
REQUEST_EXISTS_KWARGS_ATTACHMENTS = {
"json": {
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand Down Expand Up @@ -272,7 +272,7 @@
}
RESPONSE_EXISTS_ATTACHMENTS = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": {
"arc_namespace": "namespace",
"arc_firmware_version": "1.0",
Expand Down Expand Up @@ -307,7 +307,7 @@
]
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand Down Expand Up @@ -342,7 +342,7 @@
}
REQUEST_EXISTS_KWARGS_LOCATION = {
"json": {
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand All @@ -362,7 +362,7 @@
}
RESPONSE_EXISTS_LOCATION = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": {
"arc_display_name": ASSET_NAME,
"arc_namespace": "namespace",
Expand Down Expand Up @@ -400,7 +400,7 @@
]
},
],
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": {
"arc_display_name": ASSET_NAME,
Expand All @@ -419,7 +419,7 @@
# ---------------

REQUEST_FIXTURES = {
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"proof_mechanism": ProofMechanism.SIMPLE_HASH.name,
"attributes": ATTRS_FIXTURES,
}
Expand All @@ -433,30 +433,30 @@

RESPONSE_FIXTURES = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": ATTRS_FIXTURES,
"confirmation_status": "CONFIRMED",
}
RESPONSE_NO_ATTACHMENTS = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": ATTRS_NO_ATTACHMENTS,
"confirmation_status": "CONFIRMED",
}
RESPONSE_NO_CONFIRMATION = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": ATTRS,
}
RESPONSE_PENDING = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": ATTRS,
"confirmation_status": "PENDING",
}
RESPONSE_FAILED = {
"identity": IDENTITY,
"behaviours": BEHAVIOURS,
"behaviours": ASSET_BEHAVIOURS,
"attributes": ATTRS,
"confirmation_status": "FAILED",
}
Expand Down
5 changes: 3 additions & 2 deletions unittests/testrunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from archivist.archivist import Archivist
from archivist.assets import Asset
from archivist.constants import ASSET_BEHAVIOURS
from archivist.logger import set_logger
from archivist.runner import tree

Expand All @@ -30,7 +31,7 @@
"radiation_level": 0,
"weight": 0,
},
"behaviours": ["Attachments", "RecordEvidence"],
"behaviours": ASSET_BEHAVIOURS,
"confirmation_status": "CONFIRMED",
"identity": ASSET_ID,
}
Expand All @@ -41,7 +42,7 @@
"radiation_level": 0,
"weight": 0,
},
"behaviours": ["Attachments", "RecordEvidence"],
"behaviours": ASSET_BEHAVIOURS,
"confirmation_status": "CONFIRMED",
"identity": ASSET_ID,
}
Expand Down
Loading