def testLoadFromDefaults():
    #set os env
    os.environ['EZCONFIGURATION_DIR'] = resource_filename(__name__, 'config')

    config = EzConfiguration()
    nt.eq_(properties.get('application.name', ''),
           config.getProperties().get('application.name'))
def setupTests():
    loader = DirectoryConfigurationLoader(resource_filename("tests", "config"))
    ezconfig = EzConfiguration(loader)
    cryptoPassword = "******"
    cryptoImplementor = SharedSecretTextCryptoImplementation(cryptoPassword)
    ezprops = ezconfig.getProperties(cryptoImplementor)
    global CONFIG
    CONFIG = AccumuloConfiguration(ezprops)
Esempio n. 3
0
class BaseEzSecurityMiddleware(object):

    def __init__(self):

        self.ez_config = EzConfiguration()
        self.ez_props = self.ez_config.getProperties()
        self.ez_security_client = EzSecurityClient(self.ez_props)
def getEzProperties():
    #load default configurations
    config = EzConfiguration()
    logger.info("loaded default ezbake configuration properties")

    #load configuration overrides
    overrideLoader = DirectoryConfigurationLoader(gConfig.ezconfig_dir)
    config = EzConfiguration(PropertiesConfigurationLoader(config.getProperties()), overrideLoader)
    logger.info("loaded property overrides")

    #load cryptoImpl
    cryptoImpl = SystemConfiguration(config.getProperties()).getTextCryptoImplementer()
    if not isinstance(cryptoImpl, SharedSecretTextCryptoImplementation):
        logger.warn("Couldn't get a SharedSecretTextCryptoImplementation. Is the EZB shared secret set properly?")

    return config.getProperties(cryptoImpl)
Esempio n. 5
0
    def setUp(self):
        self.setup_zookeeper()
        zoo_host = ":".join(str(x) for x in self.client.hosts[0])

        ezConfig = EzConfiguration().getProperties()
        ezConfig[
            EzBakePropertyConstants.ZOOKEEPER_CONNECTION_STRING] = zoo_host
        ezConfig[caservice.EzCAHandler.CLIENT_CERTS] = "client"
        ezConfig[caservice.EzCAHandler.CLIENT_CERT_O] = "tmpcerts"

        # make direcotry for client certs
        try:
            os.mkdir('tmpcerts')
            os.mkdir('tmpcerts/server')
            os.mkdir('tmpcerts/client')
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise e

        #caservice.setup_logging(True, ezConfig)
        # Start the server
        self.serverProcess = Process(target=caservice.ca_server,
                                     args=(ezConfig, ),
                                     kwargs={
                                         'port': 5049,
                                         'host': 'localhost',
                                         'verify_pattern': r"client",
                                         "ssldir": "tmpcerts/server"
                                     })
        self.serverProcess.start()
        # Starting the server takes a while
        time.sleep(5)

        # Write out the client certs
        ca.EzbakeCA.setup(FilePersist(caservice.EzCAHandler.TABLE_NAME))
        cert.Cert.setup(FilePersist(caservice.EzCAHandler.TABLE_NAME))
        try:
            ca_certs = ca.EzbakeCA.get_named("ezbakeca")
        except KeyError:
            ca_certs = ca.EzbakeCA(name="ezbakeca")
            ca_certs.save()

        client_certs = cert.Cert.get_named("client")
        with open(os.path.join("tmpcerts/client", "ezbakeca.crt"), 'w') as f:
            f.write(ca_certs.cert_string())
        with open(os.path.join("tmpcerts/client", "application.crt"),
                  'w') as f:
            f.write(client_certs.cert_string())
        with open(os.path.join("tmpcerts/client", "application.priv"),
                  'w') as f:
            f.write(client_certs.pkey_string())
Esempio n. 6
0
    def get_client(self, port):
        ezConfig = EzConfiguration().getProperties()
        ezConfig[EzBakePropertyConstants.
                 EZBAKE_CERTIFICATES_DIRECTORY] = "tmpcerts/client"

        host = 'localhost'

        transport = EzSSLSocket.TSSLSocket(ezConfig,
                                           host=host,
                                           port=port,
                                           validate=True,
                                           verify_pattern=r"Ez.*")
        transport = TTransport.TBufferedTransport(transport)
        protocol = TBinaryProtocol.TBinaryProtocol(transport)
        transport.open()
        return ezbake.ezca.EzCA.Client(protocol)
Esempio n. 7
0
    def __init__(self, ca_name, ezconfig=EzConfiguration().getProperties()):
        mode = ezconfig.get(EzCAHandler.PERSIST_MODE, "file")
        if mode == "file":
            store = FilePersist(EzCAHandler.TABLE_NAME)
        elif mode == "accumulo":
            raise NotImplementedError("accumulo persistance not supported by EzCA yet")
        else:
            store = MemoryPersist()
        EzbakeCA.setup(store=store)
        Cert.setup(store=store)

        self.store = store
        try:
            logger.info("Reading CA certificate {}".format(ca_name))
            self.ca = EzbakeCA.get_named(ca_name)
        except KeyError:
            self.ca = EzbakeCA(name=ca_name)
        self.ca.save()
def testSetAndGet():
    config = EzConfiguration(PropertiesConfigurationLoader({'TestKey' : 'TestValue'}))
    nt.eq_('TestValue', config.getProperties().get('TestKey'))
def testLoadFromPackage():
    config = EzConfiguration(DirectoryConfigurationLoader(__name__), PropertiesConfigurationLoader(properties), OpenShiftConfigurationLoader())
    nt.eq_(properties.get('application.name', ''),
           config.getProperties().get('application.name'))
def testZookeeperConfiguration():
    loader = DirectoryConfigurationLoader(resource_filename('tests', 'config'))
    ezconfig = EzConfiguration(loader)
    zkconfig = ZookeeperConfiguration(ezconfig.getProperties())
    nt.eq_('zoo1:2181,zoo2:2181', zkconfig.getZookeeperConnectionString())
def testBaseConfiguration():
    ezConfig = EzConfiguration(DirectoryConfigurationLoader(resource_filename('tests', 'config')))
    config = BaseConfiguration(ezConfig.getProperties())
    #private member access used for testing
    nt.eq_('testapp', config._ezprops.get('application.name'))
 def test_main(self):
     ezconf = EzConfiguration()
     ezconf.set(ApplicationConfiguration.CERTIFICATES_DIRECTORY_KEY, "test/pki/server")
     ezbakeca.caservice.main(ezconfig=ezconf)
Esempio n. 13
0
def load_configuration(dir=None):
    loaders = [DirectoryConfigurationLoader()]
    if dir:
        loaders.append(DirectoryConfigurationLoader(dir))
    return EzConfiguration(*loaders).getProperties()
Esempio n. 14
0
 def test_main(self):
     ezconf = EzConfiguration()
     ezconf.set(ApplicationConfiguration.CERTIFICATES_DIRECTORY_KEY,
                "test/pki/server")
     ezbakeca.caservice.main(ezconfig=ezconf)
def setupTests():
    loader = DirectoryConfigurationLoader(resource_filename('tests', 'config'))
    ezconfig = EzConfiguration(loader)
    global CONFIG
    CONFIG = KafkaConfiguration(ezconfig.getProperties())
def testWithNamespacePrefixing():
    ezConfig = EzConfiguration(DirectoryConfigurationLoader(resource_filename('tests', 'config')))
    config = BaseConfiguration(ezConfig.getProperties(), namespace='TestNamespace')
    #private member access used for testing
    nt.eq_('TestUserWithNamespace', config._ezprops.get(config._parseKey('accumulo.username')))
def testEZConfiguration():
    config = EzConfiguration(PropertiesConfigurationLoader(properties))
    nt.eq_(properties.get('application.name', ''),
           config.getProperties().get('application.name',''))
Esempio n. 18
0
    def __init__(self):

        self.ez_config = EzConfiguration()
        self.ez_props = self.ez_config.getProperties()
        self.ez_security_client = EzSecurityClient(self.ez_props)
def setupTests():
    loader = DirectoryConfigurationLoader(resource_filename("tests", "config"))
    ezconfig = EzConfiguration(loader)
    global CONFIG
    CONFIG = MongoDBConfiguration(ezconfig.getProperties())