Example #1
0
 def test_rootURLAlternateSubdomain(self):
     """
     L{SiteConfiguration.rootURL} returns C{/} for a request made onto a
     subdomain known as an internal domain.
     """
     userbase.LoginMethod(store=self.store,
                          localpart=u'username',
                          domain=u'example.org',
                          internal=True,
                          protocol=u'*',
                          verified=True,
                          account=self.store)
     request = FakeRequest(headers={'host': 'example.org'})
     self.assertEqual(self.site.rootURL(request), URL('', ''))
Example #2
0
 def test_wwwSubdomain(self):
     """
     L{VirtualHostWrapper.subdomain} returns C{None} when passed a hostname
     which is the I{www} subdomain of a domain of the site.
     """
     site = Store()
     wrapper = VirtualHostWrapper(site, None, None)
     userbase.LoginMethod(store=site,
                          account=site,
                          protocol=u'*',
                          internal=True,
                          verified=True,
                          localpart=u'alice',
                          domain=u'example.com')
     self.assertIdentical(wrapper.subdomain("www.example.com"), None)
Example #3
0
 def test_subdomainWithPort(self):
     """
     L{VirtualHostWrapper.subdomain} handles hostnames with a port component
     as if they did not have a port component.
     """
     site = Store()
     wrapper = VirtualHostWrapper(site, None, None)
     userbase.LoginMethod(store=site,
                          account=site,
                          protocol=u'*',
                          internal=True,
                          verified=True,
                          localpart=u'alice',
                          domain=u'example.com')
     self.assertEqual(wrapper.subdomain("bob.example.com:8080"),
                      ("bob", "example.com"))
Example #4
0
 def test_subdomain(self):
     """
     L{VirtualHostWrapper.subdomain} returns a two-tuple of a username and a
     domain name when passed a hostname which is a subdomain of a known
     domain.
     """
     site = Store()
     wrapper = VirtualHostWrapper(site, None, None)
     userbase.LoginMethod(store=site,
                          account=site,
                          protocol=u'*',
                          internal=True,
                          verified=True,
                          localpart=u'alice',
                          domain=u'example.com')
     self.assertEqual(wrapper.subdomain("bob.example.com"),
                      ("bob", "example.com"))
Example #5
0
 def testDomainNames(self):
     s = Store()
     acc = s
     for localpart, domain, internal in [(u'local', u'example.com', True),
                                         (u'local', u'example.net', True),
                                         (u'remote', u'example.org', False),
                                         (u'another', u'example.com', True),
                                         (u'brokenguy', None, True)]:
         userbase.LoginMethod(store=s,
                              localpart=localpart,
                              domain=domain,
                              verified=True,
                              account=s,
                              protocol=u'test',
                              internal=internal)
     self.assertEquals(userbase.getDomainNames(s),
                       [u"example.com", u"example.net"])