1
# Copyright 2015 Canonical Limited.
2
# This file provides common functions for amulet tests for the rabbitmq-server
6
from charmhelpers.contrib.ssl.service import ServiceCA
11
Represents the certificate authority for use in RabbitMQ amulet tests.
13
# The name of the rabbit certificate authority.
14
CA_NAME = 'rabbit-server-ca'
16
# Put the certificate authority in a temporary location since
17
# it is rebuilt for each amulet run.
18
CA_PATH = '/tmp/rabbit-server-ca'
20
# The common name for the certificate itself.
21
COMMON_NAME = 'rabbitmq-server'
24
self.ca = ServiceCA(self.CA_NAME, self.CA_PATH)
26
self.ca.get_or_create_cert(self.COMMON_NAME)
28
def _load_file(self, path):
36
Returns the contents of the rabbitmq private key.
38
key_path = os.path.join(self.CA_PATH, 'certs', 'rabbitmq-server.key')
39
return self._load_file(key_path)
43
Returns the contents of the rabbitmq certificate.
45
cert_path = os.path.join(self.CA_PATH, 'certs', 'rabbitmq-server.crt')
46
return self._load_file(cert_path)
48
def ca_cert_path(self):
50
Returns the certificate authority certificate path.
52
return os.path.join(self.CA_PATH, 'cacert.pem')