Skip to content

Commit 892fbd0

Browse files
committed
refactor(behat): rewrite signature_text_policy.feature using standard OCS steps
Replace custom Behat steps with standard OCS API steps following the pattern used in policies.feature, collect_metadata_policy.feature, and identification_documents_policy.feature. Changes: - Use 'sending :verb to ocs :url' for all policy operations - Use 'the response should be a JSON array with the following mandatory values' - Test system, group, and user-level policies - Test effective policy resolution for different scopes - Remove dependency on non-existent custom steps - Remove scenarios with implementation-only assertions - Use valid policy values (graphic, text, default for render_mode) All scenarios now use only the standard Nextcloud Behat steps available in NextcloudApiContext, making the tests maintainable and following the established pattern in the test suite. Test Results: - 4 scenarios (4 passed) - 43 steps (43 passed) Signed-off-by: Vitor Mattos <[email protected]>
1 parent d29623e commit 892fbd0

1 file changed

Lines changed: 102 additions & 59 deletions

File tree

Lines changed: 102 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,102 @@
1-
Feature: Signature text policy layer
2-
Background:
3-
Given the app "libresign" is installed
4-
And user "admin" exists with default attributes
5-
6-
Scenario: Admin can set system-level signature text template via policy
7-
When I am logged in as admin
8-
And I set the policy "signature_text_template" with system value "Welcome {{SignerCommonName}}" via policy service
9-
Then the system policy "signature_text_template" should be "Welcome {{SignerCommonName}}"
10-
And the effective policy "signature_text_template" should be "Welcome {{SignerCommonName}}"
11-
12-
Scenario: Admin can set signature render mode via policy
13-
When I am logged in as admin
14-
And I set the policy "signature_render_mode" with system value "DESCRIPTION_ONLY" via policy service
15-
Then the system policy "signature_render_mode" should be "DESCRIPTION_ONLY"
16-
17-
Scenario: Admin can set signature dimensions via policy
18-
When I am logged in as admin
19-
And I set the policy "signature_width" with system value "100" via policy service
20-
And I set the policy "signature_height" with system value "60" via policy service
21-
Then the system policy "signature_width" should be "100"
22-
And the system policy "signature_height" should be "60"
23-
24-
Scenario: Admin can set signature font sizes via policy
25-
When I am logged in as admin
26-
And I set the policy "template_font_size" with system value "8.5" via policy service
27-
And I set the policy "signature_font_size" with system value "18" via policy service
28-
Then the system policy "template_font_size" should be "8.5"
29-
And the system policy "signature_font_size" should be "18"
30-
31-
Scenario: Policy fallback to appconfig during migration
32-
When I am logged in as admin
33-
And appConfig key "signature_text_template" is set to "Legacy template {{SignerCommonName}}"
34-
And the policy service is unavailable
35-
Then the effective policy "signature_text_template" should return "Legacy template {{SignerCommonName}}" from appConfig fallback
36-
37-
Scenario: User-level policy override for signature text
38-
Given user "signer" exists with default attributes
39-
When I am logged in as admin
40-
And I set the policy "signature_text_template" with user "signer" value "User-specific: {{SignerCommonName}}" via policy service
41-
Then the user "signer" effective policy "signature_text_template" should be "User-specific: {{SignerCommonName}}"
42-
43-
Scenario: Group-level policy for signature text
44-
Given user "signer" exists with default attributes
45-
And group "signers" exists
46-
And user "signer" is member of group "signers"
47-
When I am logged in as admin
48-
And I set the policy "signature_render_mode" with group "signers" value "GRAPHIC_ONLY" via policy service
49-
Then the user "signer" effective policy "signature_render_mode" should be "GRAPHIC_ONLY"
50-
51-
Scenario: Policy value normalization
52-
When I am logged in as admin
53-
And I set the policy "signature_width" with system value "350.75" via policy service
54-
Then the system policy "signature_width" should be normalized to float "350.75"
55-
56-
Scenario: Invalid policy value rejection
57-
When I am logged in as admin
58-
And I try to set the policy "signature_render_mode" with system value "INVALID_MODE" via policy service
59-
Then the invalid policy value should be normalized to default "default"
1+
Feature: admin/signature_text_policy
2+
Scenario: Manage signature_text policy layers through API
3+
Given as user "admin"
4+
And user "signer1" exists
5+
And sending "delete" to ocs "/apps/libresign/api/v1/policies/user/signer1/signature_text_template"
6+
And the response should have a status code 200
7+
8+
When sending "post" to ocs "/apps/libresign/api/v1/policies/system/signature_text_template"
9+
| value | Welcome {{SignerCommonName}} |
10+
| allowChildOverride | true |
11+
Then the response should have a status code 200
12+
And the response should be a JSON array with the following mandatory values
13+
| key | value |
14+
| (jq).ocs.data.policy.policyKey | signature_text_template |
15+
| (jq).ocs.data.policy.effectiveValue| Welcome {{SignerCommonName}} |
16+
17+
When sending "put" to ocs "/apps/libresign/api/v1/policies/group/admin/signature_text_template"
18+
| value | Admin template {{SignerCommonName}} |
19+
| allowChildOverride | true |
20+
Then the response should have a status code 200
21+
And the response should be a JSON array with the following mandatory values
22+
| key | value |
23+
| (jq).ocs.data.policy.policyKey | signature_text_template |
24+
| (jq).ocs.data.policy.scope | group |
25+
| (jq).ocs.data.policy.targetId | admin |
26+
27+
When sending "get" to ocs "/apps/libresign/api/v1/policies/effective"
28+
Then the response should have a status code 200
29+
And the response should be a JSON array with the following mandatory values
30+
| key | value |
31+
| (jq).ocs.data.policies.signature_text_template.effectiveValue| Admin template {{SignerCommonName}} |
32+
33+
Given as user "signer1"
34+
When sending "get" to ocs "/apps/libresign/api/v1/policies/effective"
35+
Then the response should have a status code 200
36+
And the response should be a JSON array with the following mandatory values
37+
| key | value |
38+
| (jq).ocs.data.policies.signature_text_template.effectiveValue| Welcome {{SignerCommonName}} |
39+
40+
Given as user "admin"
41+
When sending "put" to ocs "/apps/libresign/api/v1/policies/user/signer1/signature_text_template"
42+
| value | User-specific: {{SignerCommonName}} |
43+
Then the response should have a status code 200
44+
And the response should be a JSON array with the following mandatory values
45+
| key | value |
46+
| (jq).ocs.data.policy.policyKey | signature_text_template |
47+
| (jq).ocs.data.policy.scope | user_policy |
48+
| (jq).ocs.data.policy.targetId | signer1 |
49+
50+
Given as user "signer1"
51+
When sending "get" to ocs "/apps/libresign/api/v1/policies/effective"
52+
Then the response should have a status code 200
53+
And the response should be a JSON array with the following mandatory values
54+
| key | value |
55+
| (jq).ocs.data.policies.signature_text_template.effectiveValue| User-specific: {{SignerCommonName}} |
56+
| (jq).ocs.data.policies.signature_text_template.sourceScope | user_policy |
57+
58+
Scenario: Manage signature render mode policy layers through API
59+
Given as user "admin"
60+
And sending "post" to ocs "/apps/libresign/api/v1/policies/system/signature_render_mode"
61+
| value | graphic |
62+
Then the response should have a status code 200
63+
And the response should be a JSON array with the following mandatory values
64+
| key | value |
65+
| (jq).ocs.data.policy.policyKey | signature_render_mode |
66+
| (jq).ocs.data.policy.effectiveValue| graphic |
67+
68+
Scenario: Manage signature dimensions policy layers through API
69+
Given as user "admin"
70+
And sending "post" to ocs "/apps/libresign/api/v1/policies/system/signature_width"
71+
| value | 100 |
72+
Then the response should have a status code 200
73+
And the response should be a JSON array with the following mandatory values
74+
| key | value |
75+
| (jq).ocs.data.policy.policyKey | signature_width |
76+
| (jq).ocs.data.policy.effectiveValue| 100 |
77+
78+
And sending "post" to ocs "/apps/libresign/api/v1/policies/system/signature_height"
79+
| value | 60 |
80+
And the response should have a status code 200
81+
And the response should be a JSON array with the following mandatory values
82+
| key | value |
83+
| (jq).ocs.data.policy.policyKey | signature_height |
84+
| (jq).ocs.data.policy.effectiveValue| 60 |
85+
86+
Scenario: Manage signature font sizes policy layers through API
87+
Given as user "admin"
88+
And sending "post" to ocs "/apps/libresign/api/v1/policies/system/template_font_size"
89+
| value | 8.5 |
90+
Then the response should have a status code 200
91+
And the response should be a JSON array with the following mandatory values
92+
| key | value |
93+
| (jq).ocs.data.policy.policyKey | template_font_size |
94+
| (jq).ocs.data.policy.effectiveValue| 8.5 |
95+
96+
And sending "post" to ocs "/apps/libresign/api/v1/policies/system/signature_font_size"
97+
| value | 18 |
98+
And the response should have a status code 200
99+
And the response should be a JSON array with the following mandatory values
100+
| key | value |
101+
| (jq).ocs.data.policy.policyKey | signature_font_size |
102+
| (jq).ocs.data.policy.effectiveValue| 18 |

0 commit comments

Comments
 (0)