|
| 1 | +name: E2E KV Store - Default Capabilities Propagation |
| 2 | +description: > |
| 3 | + Regression test for issue #2256 / PR #2261: when an admin overrides |
| 4 | + the namespace's `default_capabilities` *before* a new member joins, |
| 5 | + the new member must pick up the overridden value — not a hard-coded |
| 6 | + fallback the joiner side previously substituted in. |
| 7 | +
|
| 8 | + The pre-fix bug: `create_group` writes `default_capabilities = |
| 9 | + CAN_JOIN_OPEN_SUBGROUPS` to the creator's local store but never |
| 10 | + publishes the corresponding `DefaultCapabilitiesSet` governance op, |
| 11 | + so a joiner couldn't read the value out of the governance DAG. A |
| 12 | + joiner-side mirror substituted the same hard-coded constant — which |
| 13 | + silently overrode any admin change made via `set_default_capabilities`. |
| 14 | +
|
| 15 | + The fix: the namespace's current `default_capabilities` is carried |
| 16 | + in the join-bundle's `default_capabilities` field, so the joiner |
| 17 | + reflects whatever the responder currently believes — including any |
| 18 | + admin-issued override. This workflow asserts that contract. |
| 19 | +
|
| 20 | + Flow: |
| 21 | + 1. node-1 installs the app and creates a namespace. By construction |
| 22 | + of `create_group`, the local default is CAN_JOIN_OPEN_SUBGROUPS (4). |
| 23 | + 2. node-1 admin overrides the default to 0 (no capabilities) via |
| 24 | + `set_default_capabilities`. |
| 25 | + 3. node-1 invites node-2. |
| 26 | + 4. node-2 joins the namespace. |
| 27 | + 5. Assert node-2's individual capability is 0 (the admin's override), |
| 28 | + NOT 4 (the create-time hard-coded constant). If the assertion |
| 29 | + fails with `json_equal({{node2_caps}}, 4)` truthy, the fix has |
| 30 | + regressed. |
| 31 | + 6. As a downstream sanity-check that the inherited cap actually |
| 32 | + gates Open-subgroup access: node-1 creates an Open subgroup |
| 33 | + containing a context, and node-2 tries to join that context. |
| 34 | + With caps=0 (no CAN_JOIN_OPEN_SUBGROUPS), the parent-walk in |
| 35 | + `check_group_membership` should refuse — `join_context` must |
| 36 | + fail. (`join_context_expect_failure` is the merobox action for |
| 37 | + a deliberate-deny scenario; if the runner doesn't support it, |
| 38 | + this step can be commented out — the cap-value assertion above |
| 39 | + is sufficient regression coverage.) |
| 40 | +
|
| 41 | +force_pull_image: false |
| 42 | +near_devnet: false |
| 43 | + |
| 44 | +nodes: |
| 45 | + count: 2 |
| 46 | + image: ghcr.io/calimero-network/merod:edge |
| 47 | + prefix: e2e-node |
| 48 | + |
| 49 | +steps: |
| 50 | + # --- Setup --- |
| 51 | + |
| 52 | + - name: Install application on node-1 |
| 53 | + type: install_application |
| 54 | + node: e2e-node-1 |
| 55 | + path: res/e2e_kv_store.wasm |
| 56 | + dev: true |
| 57 | + outputs: |
| 58 | + app_id: applicationId |
| 59 | + |
| 60 | + - name: Assert application installed |
| 61 | + type: assert |
| 62 | + statements: |
| 63 | + - "is_set({{app_id}})" |
| 64 | + |
| 65 | + - name: Create namespace on node-1 |
| 66 | + type: create_namespace |
| 67 | + node: e2e-node-1 |
| 68 | + application_id: '{{app_id}}' |
| 69 | + outputs: |
| 70 | + namespace_id: namespaceId |
| 71 | + |
| 72 | + - name: Assert namespace created |
| 73 | + type: assert |
| 74 | + statements: |
| 75 | + - "is_set({{namespace_id}})" |
| 76 | + |
| 77 | + # --- Admin overrides the create-time default --- |
| 78 | + # `create_group` populated defaults locally with bit 2 |
| 79 | + # (CAN_JOIN_OPEN_SUBGROUPS = 4). The admin now restricts to 0. |
| 80 | + # Without the bundle-field fix, node-2 would still pick up the |
| 81 | + # hard-coded constant (4) instead of this override (0). |
| 82 | + |
| 83 | + - name: Admin overrides default capabilities to 0 |
| 84 | + type: set_default_capabilities |
| 85 | + node: e2e-node-1 |
| 86 | + group_id: '{{namespace_id}}' |
| 87 | + capabilities: 0 |
| 88 | + |
| 89 | + # --- node-2 joins after the override --- |
| 90 | + |
| 91 | + - name: Create namespace invitation for node-2 |
| 92 | + type: create_namespace_invitation |
| 93 | + node: e2e-node-1 |
| 94 | + namespace_id: '{{namespace_id}}' |
| 95 | + outputs: |
| 96 | + namespace_invitation: invitation |
| 97 | + |
| 98 | + - name: Node-2 joins namespace |
| 99 | + type: join_namespace |
| 100 | + node: e2e-node-2 |
| 101 | + namespace_id: '{{namespace_id}}' |
| 102 | + invitation: '{{namespace_invitation}}' |
| 103 | + outputs: |
| 104 | + member_identity_node2: memberIdentity |
| 105 | + |
| 106 | + # --- Core regression assertion --- |
| 107 | + # If the joiner-side fallback wins, node-2 has caps=4. If the bundle |
| 108 | + # field wins (correct behavior), node-2 has caps=0. |
| 109 | + |
| 110 | + - name: Get node-2 capabilities as seen by node-1 |
| 111 | + type: get_member_capabilities |
| 112 | + node: e2e-node-1 |
| 113 | + group_id: '{{namespace_id}}' |
| 114 | + member_id: '{{member_identity_node2}}' |
| 115 | + outputs: |
| 116 | + node2_caps_view_node1: capabilities |
| 117 | + |
| 118 | + - name: Assert node-2 picked up admin's override (caps=0) |
| 119 | + type: json_assert |
| 120 | + statements: |
| 121 | + - "json_equal({{node2_caps_view_node1}}, 0)" |
| 122 | + |
| 123 | + # --- Verify the same on node-2's own view (consistency across nodes) --- |
| 124 | + |
| 125 | + - name: Get node-2 capabilities as seen by node-2 itself |
| 126 | + type: get_member_capabilities |
| 127 | + node: e2e-node-2 |
| 128 | + group_id: '{{namespace_id}}' |
| 129 | + member_id: '{{member_identity_node2}}' |
| 130 | + outputs: |
| 131 | + node2_caps_view_node2: capabilities |
| 132 | + |
| 133 | + - name: Assert node-2 self-view is consistent (caps=0) |
| 134 | + type: json_assert |
| 135 | + statements: |
| 136 | + - "json_equal({{node2_caps_view_node2}}, 0)" |
| 137 | + |
| 138 | +stop_all_nodes: false |
0 commit comments