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
9 changes: 9 additions & 0 deletions xtest/abac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import enum
from typing import Literal

from pydantic import BaseModel, ConfigDict, Field, field_validator

Expand Down Expand Up @@ -163,6 +164,14 @@ class KasGrantValue(BaseModelIgnoreExtra):
key_access_server_id: str | None = None


kas_algorithm_type = Literal[
"rsa:2048",
"rsa:4096",
"ec:secp256r1",
"ec:secp384r1",
"ec:secp521r1",
]

KAS_PUBLIC_KEY_ALG_ENUM_RSA_2048 = 1
KAS_PUBLIC_KEY_ALG_ENUM_RSA_4096 = 2

Expand Down
22 changes: 11 additions & 11 deletions xtest/fixtures/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def attribute_single_kas_grant(
temporary_namespace: abac.Namespace,
):
"""Attribute with single KAS grant on value 'a'."""
pfs = tdfs.PlatformFeatureSet()
pfs = tdfs.get_platform_features()
anyof = otdfctl.attribute_create(
temporary_namespace, "letter", abac.AttributeRule.ANY_OF, ["a"]
)
Expand Down Expand Up @@ -90,7 +90,7 @@ def attribute_two_kas_grant_or(
assert sm.attribute_value.value == "alpha"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_value(kas_entry_alpha, alpha)
otdfctl.grant_assign_value(kas_entry_beta, beta)
else:
Expand Down Expand Up @@ -132,7 +132,7 @@ def attribute_two_kas_grant_and(
assert sm2.attribute_value.value == "bet"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_value(kas_entry_alpha, alef)
otdfctl.grant_assign_value(kas_entry_beta, bet)
else:
Expand Down Expand Up @@ -171,7 +171,7 @@ def one_attribute_attr_kas_grant(
assert sm.attribute_value.value == "alpha"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_attr(kas_entry_gamma, anyof)
else:
kas_key_alpha = otdfctl.kas_registry_create_public_key_only(
Expand Down Expand Up @@ -292,7 +292,7 @@ def attr_and_value_kas_grants_or(
assert sm.attribute_value.value == "alpha"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_attr(kas_entry_gamma, anyof)
otdfctl.grant_assign_value(kas_entry_alpha, beta)
else:
Expand Down Expand Up @@ -337,7 +337,7 @@ def attr_and_value_kas_grants_and(
assert sm2.attribute_value.value == "beta"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_attr(kas_entry_gamma, allof)
otdfctl.grant_assign_value(kas_entry_alpha, beta)
else:
Expand Down Expand Up @@ -375,7 +375,7 @@ def one_attribute_ns_kas_grant(
sm = otdfctl.scs_map(otdf_client_scs, alpha)
assert sm.attribute_value.value == "alpha"
# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_ns(kas_entry_delta, temporary_namespace)
else:
kas_key_ns = otdfctl.kas_registry_create_public_key_only(
Expand All @@ -395,7 +395,7 @@ def attribute_missing_value_key_mapping(
root_key: str,
) -> tuple[str, str]:
"""Attribute with attribute-level managed key mapping and a missing value FQN."""
pfs = tdfs.PlatformFeatureSet()
pfs = tdfs.get_platform_features()
if "key_management" not in pfs.features:
pytest.skip("Key management not supported by platform")

Expand Down Expand Up @@ -449,7 +449,7 @@ def ns_and_value_kas_grants_or(
assert sm.attribute_value.value == "alpha"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_value(kas_entry_alpha, beta)
otdfctl.grant_assign_ns(kas_entry_delta, temp_namespace)
else:
Expand Down Expand Up @@ -494,7 +494,7 @@ def ns_and_value_kas_grants_and(
assert sm2.attribute_value.value == "beta"

# Now assign it to the current KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_value(kas_entry_alpha, beta)
otdfctl.grant_assign_ns(kas_entry_delta, temp_namespace)
else:
Expand Down Expand Up @@ -538,7 +538,7 @@ def attribute_default_rsa(
assert sm.attribute_value.value == "wrapped"

# Assign RSA key on default KAS
if "key_management" not in tdfs.PlatformFeatureSet().features:
if "key_management" not in tdfs.get_platform_features().features:
otdfctl.grant_assign_value(kas_entry_default, wrapped)
else:
kas_key = otdfctl.kas_registry_create_public_key_only(
Expand Down
4 changes: 2 additions & 2 deletions xtest/fixtures/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def audit_log_config(request: pytest.FixtureRequest) -> AuditLogConfig:
KAS_ALPHA_LOG_FILE, KAS_BETA_LOG_FILE, etc: Paths to additional KAS log files
"""
# Import here to avoid circular dependency
from tdfs import PlatformFeatureSet
from tdfs import get_platform_features

# Check if platform version supports audit logging
pfs = PlatformFeatureSet()
pfs = get_platform_features()
platform_supports_audit = "audit_logging" in pfs.features

# Check if disabled via CLI or environment variable
Expand Down
Loading
Loading