Commit 2c3b7f2f authored by Łukasz Nowak's avatar Łukasz Nowak

Prove that keys are passed to libnetworkcache.

parent c380b1ea
......@@ -693,6 +693,97 @@ Of course eggs are also supported by networkcache:
Uploading http://localhost/demoneeded-1.2c1.zip into network cache.
Got demoneeded 1.2c1.
It is possible to pass SSL certificates and key to be used by authentication.
In order to do it NetworkcacheClient.upload method have to be patched to show
that proper keys are used.
>>> mkdir(sample_buildout, 'ncpatch')
>>> write(sample_buildout, 'ncpatch', 'ncpatch.py',
... """
... def patched(self, *args, **kwargs):
... print 'shacache_cert_file', self.shacache_cert_file
... print 'shacache_key_file', self.shacache_key_file
... print 'shadir_cert_file', self.shadir_cert_file
... print 'shadir_key_file', self.shadir_key_file
... return False
...
... def ext(buildout):
... print 'Patching slapos.libnetworkcache'
... import slapos.libnetworkcache
... slapos.libnetworkcache.NetworkcacheClient.upload = patched
... """)
>>> write(sample_buildout, 'ncpatch', 'setup.py',
... """
... from setuptools import setup
...
... setup(
... name = "ncpatch",
... entry_points = {'zc.buildout.extension': ['ncpatch = ncpatch:ext']},
... )
... """)
>>> write(sample_buildout, 'ncpatch', 'README.txt', " ")
Lets activiate this extension:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = ncpatch
... parts =
... """)
>>> print system(buildout)
Develop: '/sample-buildout/ncpatch'
Uninstalling eggs.
Lets clean networkcache:
>>> rmdir(nc_data)
>>> mkdir(nc_data)
And see what happens:
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
...
... networkcache-section = networkcache
... find-links = %(link_server)s
... develop = ncpatch download
... extensions = ncpatch
... parts = download
...
... [download]
... recipe = download
... url = %(remote_server_url)shello.txt
...
... [networkcache]
... download-cache-url = %(nc_url)sshacache
... download-dir-url = %(nc_url)sshadir
... upload-cache-url = %(nc_url)sshacache
... upload-dir-url = %(nc_url)sshadir
... shacache-cert-file = /path/to/shacache/cert/file
... shacache-key-file = /path/to/shacache/key/file
... shadir-cert-file = /path/to/shadir/cert/file
... shadir-key-file = /path/to/shadir/key/file
... ''' % globals())
>>> print system(buildout)
Networkcache enabled.
Networkcache download cache: 'http://localhost/shacache', directory 'http://localhost/shadir'
Networkcache upload cache: 'http://localhost/shacache', directory 'http://localhost/shadir'
Patching slapos.libnetworkcache
Develop: '/sample-buildout/ncpatch'
Develop: '/sample-buildout/download'
Installing download.
Downloading http://localhost/hello.txt
Downloading hello.txt from network cache.
Failed to download from network cache hello.txt:...404...
Uploading http://localhost/hello.txt into network cache.
shacache_cert_file /path/to/shacache/cert/file
shacache_key_file /path/to/shacache/key/file
shadir_cert_file /path/to/shadir/cert/file
shadir_key_file /path/to/shadir/key/file
download: Downloaded http://localhost/hello.txt
Lets clean networkcache:
>>> rmdir(nc_data)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment