From f14602cb34762f02ff483698b73ef963bdcb1da0 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sun, 14 Apr 2013 14:32:13 -0700 Subject: [PATCH] welcome page: display new nodeid (ed25519-based) instead of old tubid The old tubid is displayed in a tooltip. Also cleaned up the regexps in the relevant tests. --- src/allmydata/client.py | 10 +++++++++- src/allmydata/test/test_system.py | 9 +++++---- src/allmydata/test/test_web.py | 5 +++++ src/allmydata/web/root.py | 7 ++++--- src/allmydata/web/welcome.xhtml | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/allmydata/client.py b/src/allmydata/client.py index 0fd15733..4f4745cc 100644 --- a/src/allmydata/client.py +++ b/src/allmydata/client.py @@ -14,7 +14,7 @@ from allmydata.immutable.upload import Uploader from allmydata.immutable.offloaded import Helper from allmydata.control import ControlServer from allmydata.introducer.client import IntroducerClient -from allmydata.util import hashutil, base32, pollmixin, log, keyutil +from allmydata.util import hashutil, base32, pollmixin, log, keyutil, idlib from allmydata.util.encodingutil import get_filesystem_encoding from allmydata.util.abbreviate import parse_abbreviated_size from allmydata.util.time_format import parse_duration, parse_date @@ -220,6 +220,14 @@ class Client(node.Node, pollmixin.PollMixin): self.write_config("node.pubkey", vk_vs+"\n") self._node_key = sk + def get_long_nodeid(self): + # this matches what IServer.get_longname() says about us elsewhere + vk_bytes = self._node_key.get_verifying_key_bytes() + return "v0-"+base32.b2a(vk_bytes) + + def get_long_tubid(self): + return idlib.nodeid_b2a(self.nodeid) + def _init_permutation_seed(self, ss): seed = self.get_config_from_file("permutation-seed") if not seed: diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 472f106d..56abc24e 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1,5 +1,4 @@ -from base64 import b32encode import os, re, sys, time, simplejson from cStringIO import StringIO @@ -1099,10 +1098,12 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): d = getPage(base) def _got_welcome(page): html = page.replace('\n', ' ') - connected_re = "Connected to %d[ ]*of %d known storage servers" % (self.numclients, self.numclients) + connected_re = r'Connected to %d\s*of %d known storage servers' % (self.numclients, self.numclients) self.failUnless(re.search(connected_re, html), "I didn't see the right '%s' message in:\n%s" % (connected_re, page)) - nodeid_re = "Node ID:[ ]*%s" % (re.escape(b32encode(self.clients[0].nodeid).lower()),) + # nodeids/tubids don't have any regexp-special characters + nodeid_re = r'Node ID:\s*%s' % ( + self.clients[0].get_long_tubid(), self.clients[0].get_long_nodeid()) self.failUnless(re.search(nodeid_re, html), "I didn't see the right '%s' message in:\n%s" % (nodeid_re, page)) self.failUnless("Helper: 0 active uploads" in page) @@ -1113,7 +1114,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): d.addCallback(lambda res: getPage(self.helper_webish_url)) def _got_welcome_helper(page): html = page.replace('\n', ' ') - self.failUnless(re.search('
[ ]*
Helper
', html), page) + self.failUnless(re.search(r'
\s*
Helper
', html), page) self.failUnlessIn("Not running helper", page) d.addCallback(_got_welcome_helper) diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 00d05097..3b12549c 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -254,6 +254,11 @@ class FakeClient(Client): self.mutable_file_default = SDMF_VERSION self.addService(FakeStorageServer(self.nodeid, self.nickname)) + def get_long_nodeid(self): + return "v0-nodeid" + def get_long_tubid(self): + return "tubid" + def startService(self): return service.MultiService.startService(self) def stopService(self): diff --git a/src/allmydata/web/root.py b/src/allmydata/web/root.py index 1895d067..b4b7a85c 100644 --- a/src/allmydata/web/root.py +++ b/src/allmydata/web/root.py @@ -9,7 +9,7 @@ from nevow.util import resource_filename import allmydata # to display import path from allmydata import get_package_versions_string -from allmydata.util import idlib, log +from allmydata.util import log from allmydata.interfaces import IFileNode from allmydata.web import filenode, directory, unlinked, status, operations from allmydata.web import storage @@ -168,8 +168,9 @@ class Root(rend.Page): return get_package_versions_string() def data_import_path(self, ctx, data): return str(allmydata) - def data_my_nodeid(self, ctx, data): - return idlib.nodeid_b2a(self.client.nodeid) + def render_my_nodeid(self, ctx, data): + tubid_s = "TubID: "+self.client.get_long_tubid() + return T.td(title=tubid_s)[self.client.get_long_nodeid()] def data_my_nickname(self, ctx, data): return self.client.nickname diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml index 1c794e44..9e1228e7 100644 --- a/src/allmydata/web/welcome.xhtml +++ b/src/allmydata/web/welcome.xhtml @@ -28,7 +28,7 @@ Node ID: - + -- 2.45.2