mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-25 08:30:25 -04:00
Prevent expired events from being filtered out when retention is disabled (#12611)
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
This commit is contained in:
parent
a608ac847b
commit
4cc4229cd7
7 changed files with 71 additions and 32 deletions
|
@ -11,6 +11,7 @@
|
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from typing import Any, Dict
|
||||
from unittest.mock import Mock
|
||||
|
||||
from twisted.test.proto_helpers import MemoryReactor
|
||||
|
@ -252,16 +253,24 @@ class RetentionNoDefaultPolicyTestCase(unittest.HomeserverTestCase):
|
|||
room.register_servlets,
|
||||
]
|
||||
|
||||
def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
|
||||
config = self.default_config()
|
||||
config["retention"] = {
|
||||
def default_config(self) -> Dict[str, Any]:
|
||||
config = super().default_config()
|
||||
|
||||
retention_config = {
|
||||
"enabled": True,
|
||||
}
|
||||
|
||||
# Update this config with what's in the default config so that
|
||||
# override_config works as expected.
|
||||
retention_config.update(config.get("retention", {}))
|
||||
config["retention"] = retention_config
|
||||
|
||||
return config
|
||||
|
||||
def make_homeserver(self, reactor: MemoryReactor, clock: Clock) -> HomeServer:
|
||||
mock_federation_client = Mock(spec=["backfill"])
|
||||
|
||||
self.hs = self.setup_test_homeserver(
|
||||
config=config,
|
||||
federation_client=mock_federation_client,
|
||||
)
|
||||
return self.hs
|
||||
|
@ -295,6 +304,24 @@ class RetentionNoDefaultPolicyTestCase(unittest.HomeserverTestCase):
|
|||
|
||||
self._test_retention(room_id, expected_code_for_first_event=404)
|
||||
|
||||
@unittest.override_config({"retention": {"enabled": False}})
|
||||
def test_visibility_when_disabled(self) -> None:
|
||||
"""Retention policies should be ignored when the retention feature is disabled."""
|
||||
room_id = self.helper.create_room_as(self.user_id, tok=self.token)
|
||||
|
||||
self.helper.send_state(
|
||||
room_id=room_id,
|
||||
event_type=EventTypes.Retention,
|
||||
body={"max_lifetime": one_day_ms},
|
||||
tok=self.token,
|
||||
)
|
||||
|
||||
resp = self.helper.send(room_id=room_id, body="test", tok=self.token)
|
||||
|
||||
self.reactor.advance(one_day_ms * 2 / 1000)
|
||||
|
||||
self.get_event(room_id, resp["event_id"])
|
||||
|
||||
def _test_retention(
|
||||
self, room_id: str, expected_code_for_first_event: int = 200
|
||||
) -> None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue