Add nova-cert service to integrated_helpers

This allows us to do integration tests that need to use nova-cert.
Note that creating a certs for every test seems a bit excessive,
so this adds a fake_crypto module to return fake values.

Change-Id: Ia92c1dde8b122aef096004e9aad0a14ee587bbf0
This commit is contained in:
Vishvananda Ishaya 2012-10-02 14:52:17 -07:00
parent 6bc8c20be7
commit 82e5e16662
2 changed files with 114 additions and 0 deletions

111
nova/tests/fake_crypto.py Normal file
View File

@ -0,0 +1,111 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Nebula, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
def ensure_ca_filesystem():
pass
def fetch_ca(project_id=None):
rootca = """-----BEGIN CERTIFICATE-----
MIICyzCCAjSgAwIBAgIJAIJ/UoFWKoOUMA0GCSqGSIb3DQEBBAUAME4xEjAQBgNV
BAoTCU5PVkEgUk9PVDEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzETMBEGA1UECBMK
Q2FsaWZvcm5pYTELMAkGA1UEBhMCVVMwHhcNMTIxMDAyMTg1NzQ1WhcNMTMxMDAy
MTg1NzQ1WjBOMRIwEAYDVQQKEwlOT1ZBIFJPT1QxFjAUBgNVBAcTDU1vdW50YWlu
IFZpZXcxEzARBgNVBAgTCkNhbGlmb3JuaWExCzAJBgNVBAYTAlVTMIGfMA0GCSqG
SIb3DQEBAQUAA4GNADCBiQKBgQCg0Bn8WSqbJF3QNTZUxo1TzmFBxuqvhjZLKbnQ
IiShdVIWUK7RC8frq8FJI7dgJNmvkIBn9njABWDoZmurQRCzD65yCSbUc4R2ea5H
IK4wQIui0CJykvMBNjAe3bzztVVs8/ccDTsjtqq3F/KeQkKzQVfSWBrJSmYtG5tO
G+dOSwIDAQABo4GwMIGtMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFCljRfaNOsA/
9mHuq0io7Lt83FtaMH4GA1UdIwR3MHWAFCljRfaNOsA/9mHuq0io7Lt83FtaoVKk
UDBOMRIwEAYDVQQKEwlOT1ZBIFJPT1QxFjAUBgNVBAcTDU1vdW50YWluIFZpZXcx
EzARBgNVBAgTCkNhbGlmb3JuaWExCzAJBgNVBAYTAlVTggkAgn9SgVYqg5QwDQYJ
KoZIhvcNAQEEBQADgYEAEbpJOOlpKCh5omwfAwAfFg1ml4h/FJiCH3PETmOCc+3l
CtWTBd4MG8AoH7A3PU2JKAGVQ5XWo6+ihpW1RgfQpCnloI6vIeGcws+rSLnlzULt
IvfCJpRg7iQdR3jZGt3295behtP1GsCqipJEulOkOaEIs8iLlXgSOG94Mkwlb4Q=
-----END CERTIFICATE-----
"""
return rootca
def generate_x509_cert(user_id, project_id, bits=1024):
pk = """-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC4h2d63ijt9l0fIBRY37D3Yj2FYajCMUlftSoHNA4lEw0uTXnH
Jjbd0j7HNlSADWeAMuaoSDNp7CIsXMt6iA/ASN5nFFTZlLRqIzYoI0RHiiSJjvSG
d1n4Yrar1eC8tK3Rld1Zo6rj6tOuIxfFVJajJVZykCAHjGNNvulgfhBXFwIDAQAB
AoGBAIjfxx4YU/vO1lwUC4OwyS92q3OYcPk6XdakJryZHDTb4NcLmNzjt6bqIK7b
2enyB2fMWdNRWvGiueZ2HmiRLDyOGsAVdEsHvL4qbr9EZGTqC8Qxx+zTevWWf6pB
F1zxzbXNQDFZDf9kVsSLCkbMHITnW1k4MrM++9gfCO3WrfehAkEA4nd8TyCCZazq
KMOQwFLTNaiVLeTXCtvGopl4ZNiKYZ1qI3KDXb2wbAyArFuERlotxFlylXpwtlMo
SlI/C/sYqwJBANCX1sdfRJq8DpdP44ThWqOkWFLB9rBiwyyBt8746fX8amwr8eyz
H44/z5GT/Vyp8qFsjkuDzeP93eeDnr2qE0UCP1zipRnPO6x4P5J4o+Y+EmLvwkAQ
nCLYAaCvUbILHrbq2Z2wWjEYnEO03RHUd2xjkGH4TgcBMTmW4e+ZzEIduwJACnIw
LVfWBbG5QVac3EC021EVoz9XbUnk4Eu2usS4Yrs7USN6QBJQWD1V1cKFg6h3ICJh
leKJ4wsJm9h5kKH9yQJBAN8CaX223MlTSuBOVuIOwNA+09iLfx4UCLiH1fGMKDpe
xVcmkM3qCnTqNxrAPSFdT9IyB3IXiaLWbvzl7MfiOwQ=
-----END RSA PRIVATE KEY-----
"""
csr = """Certificate:
Data:
Version: 1 (0x0)
Serial Number: 23 (0x17)
Signature Algorithm: md5WithRSAEncryption
Issuer: O=NOVA ROOT, L=Mountain View, ST=California, C=US
Validity
Not Before: Oct 2 19:31:45 2012 GMT
Not After : Oct 2 19:31:45 2013 GMT
Subject: C=US, ST=California, O=OpenStack, OU=NovaDev, """
"""CN=openstack-fake-2012-10-02T19:31:45Z
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
RSA Public Key: (1024 bit)
Modulus (1024 bit):
00:b8:87:67:7a:de:28:ed:f6:5d:1f:20:14:58:df:
b0:f7:62:3d:85:61:a8:c2:31:49:5f:b5:2a:07:34:
0e:25:13:0d:2e:4d:79:c7:26:36:dd:d2:3e:c7:36:
54:80:0d:67:80:32:e6:a8:48:33:69:ec:22:2c:5c:
cb:7a:88:0f:c0:48:de:67:14:54:d9:94:b4:6a:23:
36:28:23:44:47:8a:24:89:8e:f4:86:77:59:f8:62:
b6:ab:d5:e0:bc:b4:ad:d1:95:dd:59:a3:aa:e3:ea:
d3:ae:23:17:c5:54:96:a3:25:56:72:90:20:07:8c:
63:4d:be:e9:60:7e:10:57:17
Exponent: 65537 (0x10001)
Signature Algorithm: md5WithRSAEncryption
32:82:ff:8b:92:0e:8d:9c:6b:ce:7e:fe:34:16:2a:4c:47:4f:
c7:28:a2:33:1e:48:56:2e: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JFDSf7jSLtA
-----END CERTIFICATE-----
"""
return pk, csr

View File

@ -26,6 +26,7 @@ import nova.image.glance
from nova.openstack.common.log import logging from nova.openstack.common.log import logging
from nova import service from nova import service
from nova import test # For the flags from nova import test # For the flags
from nova.tests import fake_crypto
import nova.tests.image.fake import nova.tests.image.fake
from nova.tests.integrated.api import client from nova.tests.integrated.api import client
from nova import utils from nova import utils
@ -66,12 +67,14 @@ class _IntegratedTestBase(test.TestCase):
self.flags(**f) self.flags(**f)
self.flags(verbose=True) self.flags(verbose=True)
self.stub_module('crypto', fake_crypto)
nova.tests.image.fake.stub_out_image_service(self.stubs) nova.tests.image.fake.stub_out_image_service(self.stubs)
self.flags(compute_scheduler_driver='nova.scheduler.' self.flags(compute_scheduler_driver='nova.scheduler.'
'chance.ChanceScheduler') 'chance.ChanceScheduler')
# set up services # set up services
self.compute = self.start_service('compute') self.compute = self.start_service('compute')
self.scheduler = self.start_service('cert')
self.volume = self.start_service('volume') self.volume = self.start_service('volume')
self.network = self.start_service('network') self.network = self.start_service('network')
self.scheduler = self.start_service('scheduler') self.scheduler = self.start_service('scheduler')