mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 11:29:17 +02:00
Fix #706: Added a 'fix_federation_ids' management command to deal with protocol/domain issues in federation
IDs after deployments
This commit is contained in:
parent
f780fa24c1
commit
00846ca3e9
7 changed files with 238 additions and 0 deletions
|
@ -8,3 +8,37 @@ def test_chunk_queryset(factories):
|
|||
|
||||
assert list(chunks[0]) == actors[0:2]
|
||||
assert list(chunks[1]) == actors[2:4]
|
||||
|
||||
|
||||
def test_update_prefix(factories):
|
||||
actors = []
|
||||
fid = "http://hello.world/actor/{}/"
|
||||
for i in range(3):
|
||||
actors.append(factories["federation.Actor"](fid=fid.format(i)))
|
||||
noop = [
|
||||
factories["federation.Actor"](fid="https://hello.world/actor/witness/"),
|
||||
factories["federation.Actor"](fid="http://another.world/actor/witness/"),
|
||||
factories["federation.Actor"](fid="http://foo.bar/actor/witness/"),
|
||||
]
|
||||
|
||||
qs = actors[0].__class__.objects.filter(fid__startswith="http://hello.world")
|
||||
assert qs.count() == 3
|
||||
|
||||
result = utils.replace_prefix(
|
||||
actors[0].__class__.objects.all(),
|
||||
"fid",
|
||||
"http://hello.world",
|
||||
"https://hello.world",
|
||||
)
|
||||
|
||||
assert result == 3
|
||||
|
||||
for n in noop:
|
||||
old = n.fid
|
||||
n.refresh_from_db()
|
||||
assert old == n.fid
|
||||
|
||||
for n in actors:
|
||||
old = n.fid
|
||||
n.refresh_from_db()
|
||||
assert n.fid == old.replace("http://", "https://")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue