diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index 3217b5618..1853a5596 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -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): diff --git a/src/allmydata/test/test_storage_client.py b/src/allmydata/test/test_storage_client.py index e1c59a8f3..2e7f63635 100644 --- a/src/allmydata/test/test_storage_client.py +++ b/src/allmydata/test/test_storage_client.py @@ -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): diff --git a/src/allmydata/test/web/test_root.py b/src/allmydata/test/web/test_root.py new file mode 100644 index 000000000..c9e5784c1 --- /dev/null +++ b/src/allmydata/test/web/test_root.py @@ -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"], "") diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 8b5f196a3..205d3dcac 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -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"