From 6071a595eed59e79128e40dca9fb03ff87f9b1a8 Mon Sep 17 00:00:00 2001
From: Daira Hopwood <daira@jacaranda.org>
Date: Thu, 5 Sep 2013 17:58:19 +0100
Subject: [PATCH] Fri Apr  6 00:57:23 BST 2012  david-sarah@jacaranda.org   *
 Change capitalization of WUI and introducer welcome page headings; add test
 for introducer welcome page. Also fix a typo in a CSS class name. fixes #1708

---
 src/allmydata/test/test_web.py     | 54 +++++++++++++++++++++++++++++-
 src/allmydata/web/introducer.xhtml |  4 +--
 src/allmydata/web/welcome.xhtml    |  2 +-
 3 files changed, 56 insertions(+), 4 deletions(-)

diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py
index e3920ebf..0f0cd104 100644
--- a/src/allmydata/test/test_web.py
+++ b/src/allmydata/test/test_web.py
@@ -1,13 +1,18 @@
 import os.path, re, urllib, time
 import simplejson
 from StringIO import StringIO
+
 from twisted.application import service
 from twisted.trial import unittest
 from twisted.internet import defer, reactor
 from twisted.internet.task import Clock
 from twisted.web import client, error, http
 from twisted.python import failure, log
+
+from foolscap.api import fireEventually, flushEventualQueue
+
 from nevow import rend
+
 from allmydata import interfaces, uri, webish, dirnode
 from allmydata.storage.shares import get_share_file
 from allmydata.storage_client import StorageFarmBroker
@@ -32,6 +37,7 @@ from allmydata.test.no_network import GridTestMixin
 from allmydata.test.common_web import HTTPClientGETFactory, \
      HTTPClientHEADFactory
 from allmydata.client import Client, SecretHolder
+from allmydata.introducer import IntroducerNode
 
 # create a fake uploader/downloader, and a couple of fake dirnodes, then
 # create a webserver that works against them
@@ -514,7 +520,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
     def test_welcome(self):
         d = self.GET("/")
         def _check(res):
-            self.failUnlessIn('Welcome To Tahoe-LAFS', res)
+            self.failUnlessIn('Welcome to Tahoe-LAFS', res)
             self.failUnlessIn(FAVICON_MARKUP, res)
 
             self.s.basedir = 'web/test_welcome'
@@ -3910,6 +3916,52 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
         return d
 
 
+class IntroducerWeb(unittest.TestCase):
+    def setUp(self):
+        self.node = None
+
+    def tearDown(self):
+        d = defer.succeed(None)
+        if self.node:
+            d.addCallback(lambda ign: self.node.stopService())
+        d.addCallback(flushEventualQueue)
+        return d
+
+    def test_welcome(self):
+        basedir = "web.IntroducerWeb.test_welcome"
+        os.mkdir(basedir)
+        fileutil.write(os.path.join(basedir, "tahoe.cfg"), "[node]\nweb.port = tcp:0\n")
+        self.node = IntroducerNode(basedir)
+        self.ws = self.node.getServiceNamed("webish")
+
+        d = fireEventually(None)
+        d.addCallback(lambda ign: self.node.startService())
+        d.addCallback(lambda ign: self.node.when_tub_ready())
+
+        d.addCallback(lambda ign: self.GET("/"))
+        def _check(res):
+            self.failUnlessIn('Welcome to the Tahoe-LAFS Introducer', res)
+            self.failUnlessIn(FAVICON_MARKUP, res)
+        d.addCallback(_check)
+        return d
+
+    def GET(self, urlpath, followRedirect=False, return_response=False,
+            **kwargs):
+        # if return_response=True, this fires with (data, statuscode,
+        # respheaders) instead of just data.
+        assert not isinstance(urlpath, unicode)
+        url = self.ws.getURL().rstrip('/') + urlpath
+        factory = HTTPClientGETFactory(url, method="GET",
+                                       followRedirect=followRedirect, **kwargs)
+        reactor.connectTCP("localhost", self.ws.getPortnum(), factory)
+        d = factory.deferred
+        def _got_data(data):
+            return (data, factory.status, factory.response_headers)
+        if return_response:
+            d.addCallback(_got_data)
+        return factory.deferred
+
+
 class Util(ShouldFailMixin, testutil.ReallyEqualMixin, unittest.TestCase):
     def test_load_file(self):
         # This will raise an exception unless a well-formed XML file is found under that name.
diff --git a/src/allmydata/web/introducer.xhtml b/src/allmydata/web/introducer.xhtml
index 501f78da..81873ee7 100644
--- a/src/allmydata/web/introducer.xhtml
+++ b/src/allmydata/web/introducer.xhtml
@@ -5,13 +5,13 @@
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head><body>
 
-<h1>Welcome To The Tahoe-LAFS Introducer</h1>
+<h1>Welcome to the Tahoe-LAFS Introducer</h1>
 
 <div class="section" id="this-client">
   <h2>This Introducer</h2>
 
   <table class="node-info table-headings-left">
-    <tr><th>My nodeid:</th> <td class="nideid mine data-chars" n:render="string" n:data="my_nodeid" /></tr>
+    <tr><th>My nodeid:</th> <td class="nodeid mine data-chars" n:render="string" n:data="my_nodeid" /></tr>
     <tr><th>My versions:</th> <td n:render="string" n:data="version" /></tr>
     <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="string" n:data="import_path" /></tr>
   </table>
diff --git a/src/allmydata/web/welcome.xhtml b/src/allmydata/web/welcome.xhtml
index b5a191e4..8a5b9aa1 100644
--- a/src/allmydata/web/welcome.xhtml
+++ b/src/allmydata/web/welcome.xhtml
@@ -5,7 +5,7 @@
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 </head><body>
 
-<h1>Welcome To Tahoe-LAFS!</h1>
+<h1>Welcome to Tahoe-LAFS!</h1>
 
 <div class="section" id="this-client">
   <h2>This Client</h2>
-- 
2.45.2