mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-18 18:56:28 +00:00
static servers: tolerate missing nickname/versions
A minimally-defined static server only specifies server_id, anonymous-storage-FURL, and permutation-seed-base32. But the WUI Welcome page wouldn't render (it raised an exception) without also defining nickname and version. This allows those values to be missing.
This commit is contained in:
parent
859ce66a03
commit
663e39593b
@ -348,7 +348,7 @@ class NativeStorageServer(service.MultiService):
|
||||
return self._tubid
|
||||
|
||||
def get_nickname(self):
|
||||
return self.announcement["nickname"]
|
||||
return self.announcement.get("nickname", "")
|
||||
def get_announcement(self):
|
||||
return self.announcement
|
||||
def get_remote_host(self):
|
||||
|
@ -35,6 +35,12 @@ class TestNativeStorageServer(unittest.TestCase):
|
||||
})
|
||||
self.failUnlessEqual(nss.get_available_space(), 111)
|
||||
|
||||
def test_missing_nickname(self):
|
||||
ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x",
|
||||
"permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3",
|
||||
}
|
||||
nss = NativeStorageServer("server_id", ann)
|
||||
self.assertEqual(nss.get_nickname(), "")
|
||||
|
||||
class TestStorageFarmBroker(unittest.TestCase):
|
||||
|
||||
|
35
src/allmydata/test/web/test_root.py
Normal file
35
src/allmydata/test/web/test_root.py
Normal file
@ -0,0 +1,35 @@
|
||||
from twisted.trial import unittest
|
||||
|
||||
from ...storage_client import NativeStorageServer
|
||||
from ...web.root import Root
|
||||
|
||||
class FakeRoot(Root):
|
||||
def __init__(self):
|
||||
pass
|
||||
def now_fn(self):
|
||||
return 0
|
||||
|
||||
class FakeContext:
|
||||
def __init__(self):
|
||||
self.slots = {}
|
||||
self.tag = self
|
||||
def fillSlots(self, slotname, contents):
|
||||
self.slots[slotname] = contents
|
||||
|
||||
class RenderServiceRow(unittest.TestCase):
|
||||
def test_missing(self):
|
||||
# minimally-defined static servers just need anonymous-storage-FURL
|
||||
# and permutation-seed-base32. The WUI used to have problems
|
||||
# rendering servers that lacked nickname and version. This tests that
|
||||
# we can render such minimal servers.
|
||||
ann = {"anonymous-storage-FURL": "pb://w2hqnbaa25yw4qgcvghl5psa3srpfgw3@tcp:127.0.0.1:51309/vucto2z4fxment3vfxbqecblbf6zyp6x",
|
||||
"permutation-seed-base32": "w2hqnbaa25yw4qgcvghl5psa3srpfgw3",
|
||||
}
|
||||
s = NativeStorageServer("server_id", ann)
|
||||
|
||||
r = FakeRoot()
|
||||
ctx = FakeContext()
|
||||
res = r.render_service_row(ctx, s)
|
||||
self.assertIdentical(res, ctx)
|
||||
self.assertEqual(ctx.slots["version"], "")
|
||||
self.assertEqual(ctx.slots["nickname"], "")
|
@ -329,7 +329,7 @@ class Root(rend.Page):
|
||||
last_received_data_abs_time = render_time_attr(last_received_data_time)
|
||||
|
||||
announcement = server.get_announcement()
|
||||
version = announcement["my-version"]
|
||||
version = announcement.get("my-version", "")
|
||||
available_space = server.get_available_space()
|
||||
if available_space is None:
|
||||
available_space = "N/A"
|
||||
|
Loading…
Reference in New Issue
Block a user