|
| 1 | +Feature: Public access |
| 2 | + User story: |
| 3 | + * As a user of a plugin |
| 4 | + * I want to publish a node, or a whole space, to everyone |
| 5 | + * So that visitors without a login can read it, its files and its author |
| 6 | + |
| 7 | + Acceptance criteria: |
| 8 | + * A grant to the everyone pseudo-user shows the resource to clients without a login, and to every logged-in client |
| 9 | + * Visitors see the published node's documents, contents, concepts and files, and nothing unpublished |
| 10 | + * An author visible only through a public grant shows as "anonymous #<id>", not by name or owner |
| 11 | + * A public grant gives no write access, and only an editor of the space can delete it |
| 12 | + * The everyone pseudo-user can never be an editor of a space |
| 13 | + |
| 14 | + Background: |
| 15 | + Given the database is blank |
| 16 | + And the user user1 opens the Roam plugin in space s1 |
| 17 | + And the user user2 opens the Roam plugin in space s2 |
| 18 | + And Document are added to the database: |
| 19 | + | $id | _space_id | _author_id | source_local_id | created | last_modified | |
| 20 | + | d1 | s1 | user1 | ln1 | 2025/01/01 | 2025/01/01 | |
| 21 | + | d2 | s1 | user1 | ln2 | 2025/01/01 | 2025/01/01 | |
| 22 | + And Content are added to the database: |
| 23 | + | $id | _document_id | _space_id | _author_id | source_local_id | variant | scale | text | created | last_modified | |
| 24 | + | c1 | d1 | s1 | user1 | ln1 | direct | document | claim 1 | 2025/01/01 | 2025/01/01 | |
| 25 | + | c1f | d1 | s1 | user1 | ln1 | full | document | claim 1 | 2025/01/01 | 2025/01/01 | |
| 26 | + | c2 | d2 | s1 | user1 | ln2 | direct | document | claim 2 | 2025/01/01 | 2025/01/01 | |
| 27 | + | c2f | d2 | s1 | user1 | ln2 | full | document | claim 2 | 2025/01/01 | 2025/01/01 | |
| 28 | + And Concept are added to the database: |
| 29 | + | $id | name | _space_id | _author_id | source_local_id | created | last_modified | @is_schema | _schema_id | @literal_content | @reference_content | |
| 30 | + | k1 | Claim | s1 | user1 | lk1 | 2025/01/01 | 2025/01/01 | true | | {} | {} | |
| 31 | + And Concept are added to the database: |
| 32 | + | $id | name | _space_id | _author_id | source_local_id | created | last_modified | @is_schema | _schema_id | @literal_content | @reference_content | |
| 33 | + | n1 | claim 1 | s1 | user1 | ln1 | 2025/01/01 | 2025/01/01 | false | k1 | {} | {} | |
| 34 | + | n2 | claim 2 | s1 | user1 | ln2 | 2025/01/01 | 2025/01/01 | false | k1 | {} | {} | |
| 35 | + And FileReference are added to the database: |
| 36 | + | _space_id | source_local_id | filepath | filehash | created | last_modified | |
| 37 | + | s1 | ln1 | one.png | h1 | 2025/01/01 | 2025/01/01 | |
| 38 | + | s1 | ln2 | two.png | h2 | 2025/01/01 | 2025/01/01 | |
| 39 | + |
| 40 | + Scenario: Without a public grant, a visitor sees nothing |
| 41 | + Then an anonymous client should see these content view rows in space s1: |
| 42 | + | view | row | |
| 43 | + And an anonymous client should see these concepts in space s1: |
| 44 | + | concept | |
| 45 | + And an anonymous client should see these account names: |
| 46 | + | account | name | |
| 47 | + | user1 | hidden | |
| 48 | + |
| 49 | + Scenario: A visitor reads a published node, its files and its author |
| 50 | + When SpaceAccess are added to the database: |
| 51 | + | _account_uid | _space_id | permissions | |
| 52 | + | everyone | s1 | partial | |
| 53 | + And ResourceAccess are added to the database: |
| 54 | + | _account_uid | _space_id | source_local_id | |
| 55 | + | everyone | s1 | ln1 | |
| 56 | + Then an anonymous client should see these content view rows in space s1: |
| 57 | + | view | row | |
| 58 | + | my_documents | d1 | |
| 59 | + | my_contents | c1 | |
| 60 | + | my_contents | c1f | |
| 61 | + | my_file_references | one.png | |
| 62 | + And an anonymous client should see these table rows in space s1: |
| 63 | + | table | row | |
| 64 | + | Document | d1 | |
| 65 | + | Content | c1 | |
| 66 | + | Content | c1f | |
| 67 | + | Concept | n1 | |
| 68 | + | FileReference | one.png | |
| 69 | + And an anonymous client should see these concepts in space s1: |
| 70 | + | concept | |
| 71 | + | n1 | |
| 72 | + And an anonymous client should get these accessible resources: |
| 73 | + | space | source_local_id | |
| 74 | + | s1 | ln1 | |
| 75 | + And an anonymous client should get these file access results: |
| 76 | + | filehash | access | |
| 77 | + | h1 | true | |
| 78 | + | h2 | false | |
| 79 | + And an anonymous client should get these file downloads: |
| 80 | + | filehash | access | |
| 81 | + | h1 | true | |
| 82 | + | h2 | false | |
| 83 | + And an anonymous client should see these account names: |
| 84 | + | account | name | |
| 85 | + | user1 | anonymous | |
| 86 | + And an anonymous client can read author_of_concept through my_concepts |
| 87 | + And an anonymous client can read author_of_content through my_contents |
| 88 | + |
| 89 | + Scenario: A public grant does not count as sharing a space |
| 90 | + When SpaceAccess are added to the database: |
| 91 | + | _account_uid | _space_id | permissions | |
| 92 | + | everyone | s1 | partial | |
| 93 | + And ResourceAccess are added to the database: |
| 94 | + | _account_uid | _space_id | source_local_id | |
| 95 | + | everyone | s1 | ln1 | |
| 96 | + And the account of space s2 is called anon2 |
| 97 | + Then a user logged in space s2 should see these content view rows in space s1: |
| 98 | + | view | row | |
| 99 | + | my_documents | d1 | |
| 100 | + | my_contents | c1 | |
| 101 | + | my_contents | c1f | |
| 102 | + | my_file_references | one.png | |
| 103 | + And a user logged in space s2 should see these account names: |
| 104 | + | account | name | |
| 105 | + | user1 | anonymous | |
| 106 | + | user2 | real | |
| 107 | + And a user logged in space s2 should see these account table rows: |
| 108 | + | table | rows | |
| 109 | + | PlatformAccount | anon2, user2 | |
| 110 | + And a user logged in space s1 should see these account names: |
| 111 | + | account | name | |
| 112 | + | user1 | real | |
| 113 | + | user2 | hidden | |
| 114 | + |
| 115 | + Scenario: A space shared through its own grant shows real names |
| 116 | + When user of space s1 creates group g1 |
| 117 | + And user of space s1 adds space s2 to group g1 |
| 118 | + And SpaceAccess are added to the database: |
| 119 | + | _account_uid | _space_id | permissions | |
| 120 | + | everyone | s1 | partial | |
| 121 | + | g1 | s1 | partial | |
| 122 | + Then a user logged in space s2 should see these account names: |
| 123 | + | account | name | |
| 124 | + | user1 | real | |
| 125 | + |
| 126 | + Scenario: A whole space published to everyone is readable, not writable |
| 127 | + When SpaceAccess are added to the database: |
| 128 | + | _account_uid | _space_id | permissions | |
| 129 | + | everyone | s1 | reader | |
| 130 | + And ResourceAccess are added to the database: |
| 131 | + | _account_uid | _space_id | source_local_id | |
| 132 | + | everyone | s1 | ln1 | |
| 133 | + Then an anonymous client should see these content view rows in space s1: |
| 134 | + | view | row | |
| 135 | + | my_documents | d1 | |
| 136 | + | my_documents | d2 | |
| 137 | + | my_contents | c1 | |
| 138 | + | my_contents | c1f | |
| 139 | + | my_contents | c2 | |
| 140 | + | my_contents | c2f | |
| 141 | + | my_file_references | one.png | |
| 142 | + | my_file_references | two.png | |
| 143 | + And an anonymous client should see these concepts in space s1: |
| 144 | + | concept | |
| 145 | + | k1 | |
| 146 | + | n1 | |
| 147 | + | n2 | |
| 148 | + And an anonymous client should get these file access results: |
| 149 | + | filehash | access | |
| 150 | + | h1 | true | |
| 151 | + | h2 | true | |
| 152 | + And an anonymous client is refused the insert privilege on Content with '{"space_id": 1, "source_local_id": "x", "text": "x"}' |
| 153 | + And a user logged in space s2 should get these write results in space s1: |
| 154 | + | table | insert | update | delete | |
| 155 | + | FileReference | denied | denied | denied | |
| 156 | + | Content | denied | denied | denied | |
| 157 | + | Document | denied | denied | denied | |
| 158 | + | Concept | denied | denied | denied | |
| 159 | + | ResourceAccess | denied | denied | denied | |
| 160 | + And a user logged in space s1 should get these write results in space s1: |
| 161 | + | table | insert | update | delete | |
| 162 | + | ResourceAccess | allowed | allowed | allowed | |
| 163 | + |
| 164 | + Scenario: The everyone pseudo-user cannot edit a space |
| 165 | + Then SpaceAccess rows like these violate a check constraint: |
| 166 | + | _account_uid | _space_id | permissions | |
| 167 | + | everyone | s1 | editor | |
0 commit comments