Ejemplo n.º 1
0
def create_main_app(global_config, **local_conf):
    """uWSGI factory method for the Barbican-API application"""

    # Configure oslo logging and configuration services.
    config.parse_args()
    log.setup('barbican')

    # Crypto Plugin Manager
    crypto_mgr = ext.CryptoExtensionManager()

    # Resources
    versions = res.VersionResource()
    secrets = res.SecretsResource(crypto_mgr)
    secret = res.SecretResource(crypto_mgr)
    orders = res.OrdersResource()
    order = res.OrderResource()

    wsgi_app = api = falcon.API()
    api.add_route('/', versions)
    api.add_route('/v1/{keystone_id}/secrets', secrets)
    api.add_route('/v1/{keystone_id}/secrets/{secret_id}', secret)
    api.add_route('/v1/{keystone_id}/orders', orders)
    api.add_route('/v1/{keystone_id}/orders/{order_id}', order)

    return wsgi_app
Ejemplo n.º 2
0
    def setUp(self):
        self.requestor = 'requestor1234'
        self.order = models.Order()
        self.order.id = "id1"
        self.order.requestor = self.requestor

        self.secret_name = "name"
        self.secret_algorithm = "AES"
        self.secret_bit_length = 256
        self.secret_mode = "CBC"
        self.secret_expiration = timeutils.utcnow()
        self.secret_payload_content_type = 'application/octet-stream'

        self.keystone_id = 'keystone1234'
        self.tenant_id = 'tenantid1234'
        self.tenant = models.Tenant()
        self.tenant.id = self.tenant_id
        self.tenant.keystone_id = self.keystone_id
        self.tenant_repo = mock.MagicMock()
        self.tenant_repo.get.return_value = self.tenant

        self.order.status = models.States.PENDING
        self.order.tenant_id = self.tenant_id
        self.order.secret_name = self.secret_name
        self.order.secret_algorithm = self.secret_algorithm
        self.order.secret_bit_length = self.secret_bit_length
        self.order.secret_mode = self.secret_mode
        self.order.secret_expiration = self.secret_expiration
        self.order.secret_payload_content_type = self\
            .secret_payload_content_type

        self.order_repo = mock.MagicMock()
        self.order_repo.get.return_value = self.order

        self.secret_repo = mock.MagicMock()
        self.secret_repo.create_from.return_value = None

        self.tenant_secret_repo = mock.MagicMock()
        self.tenant_secret_repo.create_from.return_value = None

        self.datum_repo = mock.MagicMock()
        self.datum_repo.create_from.return_value = None

        self.kek_repo = mock.MagicMock()

        self.conf = mock.MagicMock()
        self.conf.crypto.namespace = 'barbican.test.crypto.plugin'
        self.conf.crypto.enabled_crypto_plugins = ['test_crypto']
        self.crypto_mgr = em.CryptoExtensionManager(conf=self.conf)

        self.resource = resources.BeginOrder(self.crypto_mgr, self.tenant_repo,
                                             self.order_repo, self.secret_repo,
                                             self.tenant_secret_repo,
                                             self.datum_repo, self.kek_repo)
Ejemplo n.º 3
0
 def __init__(self, crypto_manager=None, tenant_repo=None, order_repo=None,
              secret_repo=None, tenant_secret_repo=None,
              datum_repo=None, kek_repo=None):
     LOG.debug('Creating BeginOrder task processor')
     self.order_repo = order_repo or rep.OrderRepo()
     self.tenant_repo = tenant_repo or rep.TenantRepo()
     self.secret_repo = secret_repo or rep.SecretRepo()
     self.tenant_secret_repo = tenant_secret_repo or rep.TenantSecretRepo()
     self.datum_repo = datum_repo or rep.EncryptedDatumRepo()
     self.kek_repo = kek_repo or rep.KEKDatumRepo()
     self.crypto_manager = crypto_manager or em.CryptoExtensionManager()
Ejemplo n.º 4
0
def create_main_app(global_config, **local_conf):
    """uWSGI factory method for the Barbican-API application"""

    # Configure oslo logging and configuration services.
    config.parse_args()
    log.setup('barbican')

    # Crypto Plugin Manager
    crypto_mgr = ext.CryptoExtensionManager()

    # Queuing initialization
    CONF = cfg.CONF
    queue.init(CONF)

    # Resources
    versions = res.VersionResource()
    secrets = res.SecretsResource(crypto_mgr)
    secret = res.SecretResource(crypto_mgr)
    orders = res.OrdersResource()
    order = res.OrderResource()
    verifications = res.VerificationsResource()
    verification = res.VerificationResource()
    containers = res.ContainersResource()
    container = res.ContainerResource()

    # For performance testing only
    performance = res.PerformanceResource()
    performance_uri = 'mu-1a90dfd0-7e7abba4-4e459908-fc097d60'

    wsgi_app = api = falcon.API()
    if newrelic_loaded:
        wsgi_app = newrelic.agent.WSGIApplicationWrapper(wsgi_app)

    api.add_route('/', versions)
    api.add_route('/v1/{keystone_id}/secrets', secrets)
    api.add_route('/v1/{keystone_id}/secrets/{secret_id}', secret)
    api.add_route('/v1/{keystone_id}/orders', orders)
    api.add_route('/v1/{keystone_id}/orders/{order_id}', order)
    api.add_route('/v1/{keystone_id}/verifications', verifications)
    api.add_route('/v1/{keystone_id}/verifications/{verification_id}',
                  verification)
    api.add_route('/v1/{keystone_id}/containers/', containers)
    api.add_route('/v1/{keystone_id}/containers/{container_id}', container)

    # For performance testing only
    api.add_route('/{0}'.format(performance_uri), performance)

    return wsgi_app
Ejemplo n.º 5
0
def create_main_app(global_config, **local_conf):
    """uWSGI factory method for the Barbican-API application."""

    # Configure oslo logging and configuration services.
    config.parse_args()
    log.setup('barbican')
    config.setup_remote_pydev_debug()
    # Crypto Plugin Manager
    crypto_mgr = ext.CryptoExtensionManager()

    # Queuing initialization
    CONF = cfg.CONF
    queue.init(CONF)

    class RootController(object):
        secrets = secrets.SecretsController(crypto_mgr)
        orders = orders.OrdersController()
        containers = containers.ContainersController()
        transport_keys = transportkeys.TransportKeysController()

    wsgi_app = PecanAPI(RootController(), force_canonical=False)
    if newrelic_loaded:
        wsgi_app = newrelic.agent.WSGIApplicationWrapper(wsgi_app)
    return wsgi_app
Ejemplo n.º 6
0
 def setUp(self):
     self.manager = em.CryptoExtensionManager()
Ejemplo n.º 7
0
 def setUp(self):
     super(WhenTestingCryptoExtensionManager, self).setUp()
     self.manager = em.CryptoExtensionManager()