~divmod-dev/divmod.org/request-uri-2562

« back to all changes in this revision

Viewing changes to Mantissa/xmantissa/test/historic/stub_port1to2.py

  • Committer: exarkun
  • Date: 2008-03-26 14:19:40 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:15240
Merge better-site-upgrader-2533-3

Author: exarkun
Reviewer: pjd
Fixes #2533

Fix several problems with the WebSite upgrader:

  * Make sure the old object is uninstalled
  * Make sure an AnonymousSite is created
  * Make sure a LoginSystem is properly installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from OpenSSL.crypto import FILETYPE_PEM
 
3
 
 
4
from twisted.internet.ssl import PrivateCertificate, KeyPair
 
5
 
1
6
from axiom.item import Item
2
7
from axiom.attributes import text
 
8
from axiom.dependency import installOn
3
9
from axiom.test.historic.stubloader import saveStub
4
10
 
5
11
from xmantissa.port import TCPPort, SSLPort
6
12
from xmantissa.website import WebSite
7
13
 
8
 
 
9
 
 
10
 
def createDatabase(s):
 
14
# Unfortunately, the test module for this store binds ports.  So pick some
 
15
# improbably port numbers and hope they aren't bound.  If they are, the test
 
16
# will fail.  Hooray! -exarkun
 
17
TCP_PORT = 29415
 
18
SSL_PORT = 19224
 
19
 
 
20
def createDatabase(siteStore):
11
21
    """
12
22
    Populate the given Store with a TCPPort and SSLPort.
13
23
    """
14
 
    factory = WebSite(store=s)
15
 
    TCPPort(store=s, portNumber=80, factory=factory)
16
 
    SSLPort(store=s, portNumber=443,
17
 
            certificatePath=s.newFilePath('certificate'), factory=factory)
 
24
    factory = WebSite(store=siteStore)
 
25
    installOn(factory, siteStore)
 
26
    installOn(
 
27
        TCPPort(store=siteStore, portNumber=TCP_PORT, factory=factory),
 
28
        siteStore)
 
29
    certificatePath = siteStore.newFilePath('certificate')
 
30
 
 
31
    key = KeyPair.generate()
 
32
    cert = key.selfSignedCert(1)
 
33
    certificatePath.setContent(
 
34
        cert.dump(FILETYPE_PEM) +
 
35
        key.dump(FILETYPE_PEM))
 
36
 
 
37
    installOn(
 
38
        SSLPort(store=siteStore, portNumber=SSL_PORT,
 
39
                certificatePath=certificatePath,
 
40
                factory=factory),
 
41
        siteStore)
18
42
 
19
43
 
20
44