Soar::Registry::Directory
Directory model and providers used by soar registries
Quick start
Example data
"mytable": [{
"uuid": "1",
"email": "[email protected]"
}, {
"uuid": "2",
"email": "[email protected]"
}]
Stub provider
Create an instance of the stub provider by passing in the name, primary key and indexes of your table.
> require 'soar/registry/directory'
> provider = Soar::Registry::Directory::Provider::Stub.new({
table: "mytable",
index: ["uuid", "email"]
})
DynamodDb Provider
> provider = Soar::Registry::Directory::Provider::DynamoDb.new({
credentials: {
username: "username",
password: "secret"
},
table: "mytable",
index:
partition_key: 'uuid',
sort_key: 'role'
config: {
region: 'us-west-2'
endpoint: 'http://localhost:8000'
}
})
MySQL/MariaDB Provider
Requires libmysqlclient-dev before running bundler.
$ sudo apt-get install libmysqlclient-dev
> provider = Soar::Registry::Directory::Provider::Mysql.new({
index: ['Client_Number', 'Notifyemail_Invoice', 'Login'],
config: {
database: 'konsoleh_genie'
table: 'Client'
host: '0.0.0.0'
port: 3306
},
attributes: ['Client_Number', 'Notifyemail_Invoice'],
credentials: {
username: 'genie'
password: 'secret'
}
})
Please note: The mysql dump of the genie database structure is out of date. Updating it should probably be automated. Since the directory is currently only used to search for Client_Number, it's not a priority.
LDAP Provider
> provider = Soar::Registry::Directory::Provider::Ldap.new({
base: 'dc=hetzner,dc=co,dc=za',
index: [:entryuuid, :mail],
config: {
host: 'localhost',
port: 636
},
attributes: ['entryuuid', 'cn', 'mail', 'sn'],
credentials: {
username: 'cn=admin,dc=hetzner,dc=co,dc=za'
password: 'secret'
}
})
Please note: Primary key is assumed to be the first element of index array.
Command to test secure LDAP connection from terminal.
$ ldapsearch -H ldaps://ldap2.cpt1.host-h.net:636 -x -D "[email protected],ou=people,dc=hetzner,dc=co,dc=za" -b "ou=people,dc=hetzner,dc=co,dc=za" -s sub "(objectclass=*)" -W -v -d 5
Command to test LDAP connection from terminal.
$ ldapsearch -h ldapadmin.hetzner.co.za -p 389 -x -D "[email protected],ou=people,dc=hetzner,dc=co,dc=za" -b "dc=hetzner,dc=co,dc=za" -W
The Model
> directory = Soar::Registry::Directory.new(provider)
Tests
Stub provider
Local
$ cucumber
CI
docker-compose --file docker-compose.stub.yml --project-name soar-registry-directory-provider-stub up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistrydirectoryproviderstub_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}")
docker-compose --file docker-compose.stub.yml --project-name soar-registry-directory-provider-stub down --rmi local
exit $EXIT_CODE
DynamoDb provider
Local
$ docker-compose --file docker-compose.dynamo_db.yml up --remove-orphans
$ CONFIG_FILE=config.dynamo_db.yml TEST_ORCHESTRATION_PROVIDER=DynamoDb cucumber
$ docker-compose --file docker-compose.dynamo_db.yml down local
CI
docker-compose --file docker-compose.ci.dynamo_db.yml --project-name soar-registry-directory-provider-dynamo_db up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistrydirectoryproviderdynamodb_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}")
docker-compose --file docker-compose.ci.dynamo_db.yml --project-name soar-registry-directory-provider-dynamo_db down --rmi local
exit $EXIT_CODE
LDAP provider
Local
$ docker-compose --file docker-compose.ldap.yml up --remove-orphans
$ CONFIG_FILE=config.ldap.yml TEST_ORCHESTRATION_PROVIDER=Ldap cucumber
$ docker-compose --file docker-compose.ldap.yml down local
CI
docker-compose --file docker-compose.ci.ldap.yml --project-name soar-registry-directory-provider-ldap up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistrydirectoryproviderldap_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}")
docker-compose --file docker-compose.ci.ldap.yml --project-name soar-registry-directory-provider-ldap down --rmi local
exit $EXIT_CODE
MySQL provider
Local
$ docker-compose --file docker-compose.mysql.yml up --remove-orphans
$ CONFIG_FILE=config.mysql.yml TEST_ORCHESTRATION_PROVIDER=Mysql cucumber
$ docker-compose --file docker-compose.mysql.yml down --rmi local
CI
docker-compose --file docker-compose.ci.mysql.yml --project-name soar-registry-directory-provider-mysql up --abort-on-container-exit --remove-orphans --build --force-recreate
EXIT_CODE=$(docker ps -a -f "name=soarregistrydirectoryprovidermysql_tests" -q | xargs docker inspect -f "{{ .State.ExitCode }}")
docker-compose --file docker-compose.ci.mysql.yml --project-name soar-registry-directory-provider-mysql down --rmi local
exit $EXIT_CODE