|
| 1 | +## ADDED Requirements |
| 2 | + |
| 3 | +### Requirement: Resource supports full ModifySecurityPolicy API parameters |
| 4 | + |
| 5 | +The `tencentcloud_teo_security_policy_config` resource SHALL support the following parameters mapped to the `ModifySecurityPolicy` cloud API: |
| 6 | +- `zone_id` (Required, ForceNew, String): Maps to `request.ZoneId`. The site ID. |
| 7 | +- `entity` (Optional, ForceNew, String): Maps to `request.Entity`. Security policy type, valid values: `ZoneDefaultPolicy`, `Template`, `Host`. |
| 8 | +- `host` (Optional, ForceNew, String): Maps to `request.Host`. Domain name, used when entity is `Host`. |
| 9 | +- `template_id` (Optional, ForceNew, String): Maps to `request.TemplateId`. Template ID, used when entity is `Template`. |
| 10 | +- `security_config` (Optional, Computed, List): Maps to `request.SecurityConfig`. Legacy security configuration. |
| 11 | +- `security_policy` (Optional, List): Maps to `request.SecurityPolicy`. Expression-based security policy configuration. |
| 12 | + |
| 13 | +#### Scenario: Create security policy with ZoneDefaultPolicy entity |
| 14 | +- **WHEN** user specifies `zone_id` and `entity = "ZoneDefaultPolicy"` with `security_policy` configuration |
| 15 | +- **THEN** the resource SHALL call `ModifySecurityPolicy` with the provided parameters and set the resource ID to `{zone_id}#ZoneDefaultPolicy` |
| 16 | + |
| 17 | +#### Scenario: Create security policy with Host entity |
| 18 | +- **WHEN** user specifies `zone_id`, `entity = "Host"`, and `host = "www.example.com"` with `security_policy` configuration |
| 19 | +- **THEN** the resource SHALL call `ModifySecurityPolicy` with the provided parameters and set the resource ID to `{zone_id}#Host#{host}` |
| 20 | + |
| 21 | +#### Scenario: Create security policy with Template entity |
| 22 | +- **WHEN** user specifies `zone_id`, `entity = "Template"`, and `template_id = "temp-xxx"` with `security_policy` configuration |
| 23 | +- **THEN** the resource SHALL call `ModifySecurityPolicy` with the provided parameters and set the resource ID to `{zone_id}#Template#{template_id}` |
| 24 | + |
| 25 | +### Requirement: Resource supports DescribeSecurityPolicy API for reading state |
| 26 | + |
| 27 | +The resource SHALL use the `DescribeSecurityPolicy` API to read back the current state, passing `zone_id`, `entity`, `host`, and `template_id` as request parameters, and mapping `response.Response.SecurityPolicy` to the `security_policy` attribute. |
| 28 | + |
| 29 | +#### Scenario: Read security policy state |
| 30 | +- **WHEN** the resource performs a Read operation |
| 31 | +- **THEN** the resource SHALL call `DescribeSecurityPolicy` with `zone_id`, `entity`, `host`, and `template_id` extracted from the resource ID, and populate the `security_policy` attribute from the response |
| 32 | + |
| 33 | +#### Scenario: Resource not found during read |
| 34 | +- **WHEN** the `DescribeSecurityPolicy` API returns nil for `SecurityPolicy` |
| 35 | +- **THEN** the resource SHALL remove itself from state by calling `d.SetId("")` |
| 36 | + |
| 37 | +### Requirement: Resource supports import via composite ID |
| 38 | + |
| 39 | +The resource SHALL support import using the composite ID format based on entity type. |
| 40 | + |
| 41 | +#### Scenario: Import ZoneDefaultPolicy |
| 42 | +- **WHEN** user imports with ID `{zone_id}#ZoneDefaultPolicy` |
| 43 | +- **THEN** the resource SHALL parse the ID and read the zone-level security policy |
| 44 | + |
| 45 | +#### Scenario: Import Host policy |
| 46 | +- **WHEN** user imports with ID `{zone_id}#Host#{host}` |
| 47 | +- **THEN** the resource SHALL parse the ID and read the domain-level security policy |
| 48 | + |
| 49 | +#### Scenario: Import Template policy |
| 50 | +- **WHEN** user imports with ID `{zone_id}#Template#{template_id}` |
| 51 | +- **THEN** the resource SHALL parse the ID and read the template-level security policy |
0 commit comments