Exemplo n.º 1
0
    def test_get_encoded_zip(self):
        with utils.tempdir() as tmpdir:
            self.flags(ca_path=tmpdir)
            crypto.ensure_ca_filesystem()

            ret = self.cloudpipe.get_encoded_zip(self.project)
            self.assertTrue(ret)
Exemplo n.º 2
0
    def test_get_encoded_zip(self):
        with utils.tempdir() as tmpdir:
            self.flags(ca_path=tmpdir)
            crypto.ensure_ca_filesystem()

            ret = self.cloudpipe.get_encoded_zip(self.project)
            self.assertTrue(ret)
Exemplo n.º 3
0
 def test_launch_vpn_instance(self):
     self.stubs.Set(self.cloudpipe.compute_api, "create", lambda *a, **kw:
                    (None, "r-fakeres"))
     with utils.tempdir() as tmpdir:
         self.flags(ca_path=tmpdir, keys_path=tmpdir)
         crypto.ensure_ca_filesystem()
         self.cloudpipe.launch_vpn_instance(self.context)
Exemplo n.º 4
0
 def test_launch_vpn_instance(self):
     self.stubs.Set(self.cloudpipe.compute_api,
                    "create",
                    lambda *a, **kw: (None, "r-fakeres"))
     with utils.tempdir() as tmpdir:
         self.flags(ca_path=tmpdir, keys_path=tmpdir)
         crypto.ensure_ca_filesystem()
         self.cloudpipe.launch_vpn_instance(self.context)
Exemplo n.º 5
0
 def test_encrypt_decrypt_x509(self):
     with utils.tempdir() as tmpdir:
         self.flags(ca_path=tmpdir)
         project_id = "fake"
         crypto.ensure_ca_filesystem()
         cert = crypto.fetch_ca(project_id)
         public_key = os.path.join(tmpdir, "public.pem")
         with open(public_key, "w") as keyfile:
             keyfile.write(cert)
         text = "some @#!%^* test text"
         enc, _err = utils.execute(
             "openssl", "rsautl", "-certin", "-encrypt", "-inkey", "%s" % public_key, process_input=text
         )
         dec = crypto.decrypt_text(project_id, enc)
         self.assertEqual(text, dec)
Exemplo n.º 6
0
    def test_can_generate_x509(self):
        with utils.tempdir() as tmpdir:
            self.flags(ca_path=tmpdir)
            crypto.ensure_ca_filesystem()
            _key, cert_str = crypto.generate_x509_cert("fake", "fake")

            project_cert = crypto.fetch_ca(project_id="fake")

            signed_cert_file = os.path.join(tmpdir, "signed")
            with open(signed_cert_file, "w") as keyfile:
                keyfile.write(cert_str)

            project_cert_file = os.path.join(tmpdir, "project")
            with open(project_cert_file, "w") as keyfile:
                keyfile.write(project_cert)

            enc, err = utils.execute("openssl", "verify", "-CAfile", project_cert_file, "-verbose", signed_cert_file)
            self.assertFalse(err)
Exemplo n.º 7
0
 def test_encrypt_decrypt_x509(self):
     with utils.tempdir() as tmpdir:
         self.flags(ca_path=tmpdir)
         project_id = "fake"
         crypto.ensure_ca_filesystem()
         cert = crypto.fetch_ca(project_id)
         public_key = os.path.join(tmpdir, "public.pem")
         with open(public_key, 'w') as keyfile:
             keyfile.write(cert)
         text = "some @#!%^* test text"
         enc, _err = utils.execute('openssl',
                                   'rsautl',
                                   '-certin',
                                   '-encrypt',
                                   '-inkey',
                                   '%s' % public_key,
                                   process_input=text)
         dec = crypto.decrypt_text(project_id, enc)
         self.assertEqual(text, dec)
Exemplo n.º 8
0
    def test_can_generate_x509(self):
        with utils.tempdir() as tmpdir:
            self.flags(ca_path=tmpdir)
            crypto.ensure_ca_filesystem()
            _key, cert_str = crypto.generate_x509_cert('fake', 'fake')

            project_cert = crypto.fetch_ca(project_id='fake')

            signed_cert_file = os.path.join(tmpdir, "signed")
            with open(signed_cert_file, 'w') as keyfile:
                keyfile.write(cert_str)

            project_cert_file = os.path.join(tmpdir, "project")
            with open(project_cert_file, 'w') as keyfile:
                keyfile.write(project_cert)

            enc, err = utils.execute('openssl', 'verify', '-CAfile',
                                     project_cert_file, '-verbose',
                                     signed_cert_file)
            self.assertFalse(err)
Exemplo n.º 9
0
 def init_host(self):
     crypto.ensure_ca_filesystem()
Exemplo n.º 10
0
 def init_host(self):
     crypto.ensure_ca_filesystem()