Skip to content

Commit

Permalink
kbs: fix the configuration file read test
Browse files Browse the repository at this point in the history
This commit fixes the unit test items for kbs configuration item reading
to ensure strict compliance between the content configured in the
original configuration file and the code. Configuration items that are
not given are assigned default values in the expected object of the unit
test.

Signed-off-by: Xynnn007 <[email protected]>
  • Loading branch information
Xynnn007 committed Nov 28, 2024
1 parent ac59112 commit 066f2dd
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 3 deletions.
1 change: 0 additions & 1 deletion kbs/config/kubernetes/base/kbs-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ auth_public_key = "/kbs/kbs.pem"
name = "resource"
type = "LocalFs"
dir_path = "/opt/confidential-containers/kbs/repository"

1 change: 1 addition & 0 deletions kbs/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ mod tests {
}),
attestation_token_broker: AttestationTokenConfig::Simple(simple::Configuration {
duration_min: 5,
policy_dir: "/opt/confidential-containers/attestation-service/simple-policies".into(),
..Default::default()
}),
}
Expand Down
16 changes: 14 additions & 2 deletions kbs/test_data/configs/coco-as-builtin-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
type = "coco_as_builtin"
work_dir = "/opt/coco/attestation-service"
policy_engine = "opa"
timeout = 5

[attestation_service.attestation_token_broker]
type = "Simple"
[attestation_service.attestation_token_broker]
type = "Simple"
issuer_name = "CoCo-Attestation-Service"

[attestation_service.rvps_config]
type = "GrpcRemote"
address = "http://127.0.0.1:50003"

[http_server]
sockets = ["127.0.0.1:8080"]
insecure_http = false

[admin]
insecure_api = false

[policy_engine]
policy_path = "/opt/confidential-containers/kbs/policy.rego"
2 changes: 2 additions & 0 deletions kbs/test_data/configs/coco-as-builtin-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ insecure_http = true
type = "coco_as_builtin"
work_dir = "/opt/confidential-containers/attestation-service"
policy_engine = "opa"
timeout = 5

[attestation_service.attestation_token_broker]
type = "Simple"
Expand All @@ -21,3 +22,4 @@ store_type = "LocalFs"

[admin]
auth_public_key = "/kbs/kbs.pem"
insecure_api = false
3 changes: 3 additions & 0 deletions kbs/test_data/configs/coco-as-builtin-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
insecure_http = true

[attestation_token]
insecure_key = false

[attestation_service]
type = "coco_as_builtin"
work_dir = "/opt/confidential-containers/attestation-service"
policy_engine = "opa"
timeout = 5

[attestation_service.attestation_token_broker]
type = "Simple"
duration_min = 5
policy_dir = "/opt/confidential-containers/attestation-service/simple-policies"

[attestation_service.rvps_config]
type = "BuiltIn"
Expand Down
1 change: 1 addition & 0 deletions kbs/test_data/configs/coco-as-grpc-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ insecure_http = true
[attestation_service]
type = "coco_as_grpc"
as_addr = "http://as:50004"
timeout = 5

[admin]
auth_public_key = "/opt/confidential-containers/kbs/user-keys/public.pub"
1 change: 1 addition & 0 deletions kbs/test_data/configs/coco-as-grpc-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ insecure_http = true
type = "coco_as_grpc"
as_addr = "http://127.0.0.1:50004"
pool_size = 100
timeout = 5

[admin]
insecure_api = true
1 change: 1 addition & 0 deletions kbs/test_data/configs/intel-ta-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ base_url = "example.io"
api_key = "this-is-a-key"
certs_file = "file:///etc/ita-cert.pem"
allow_unmatched_policy = true
timeout = 5

[http_server]
sockets = ["0.0.0.0:8080"]
Expand Down
2 changes: 2 additions & 0 deletions kbs/test_data/configs/intel-ta-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type = "intel_ta"
base_url = "https://api.trustauthority.intel.com"
api_key = "tBfd5kKX2x9ahbodKV1..."
certs_file = "https://portal.trustauthority.intel.com"
timeout = 5

[admin]
auth_public_key = "/kbs/kbs.pem"
insecure_api = false
1 change: 1 addition & 0 deletions kbs/test_data/configs/intel-ta-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ type = "intel_ta"
base_url = "https://api.trustauthority.intel.com"
api_key = "tBfd5kKX2x9ahbodKV1..."
certs_file = "https://portal.trustauthority.intel.com"
timeout = 5

0 comments on commit 066f2dd

Please sign in to comment.