Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: python3 setup.py sdist

- name: Install Python module
run: pip3 install ./dist/microesb-1.1.tar.gz
run: pip3 install ./dist/microesb-1.1.1.tar.gz

- name: Run tests
run: pytest --cov --cov-branch --cov-report=xml
Expand Down
7 changes: 3 additions & 4 deletions docker/examples.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM postgres:18-bookworm
MAINTAINER Claus Prüfer

ADD ./example /
COPY ./dist/microesb-1.1.tar.gz /
COPY ./dist/microesb-1.1.1.tar.gz /

COPY ./example/01-hosting-use-case/01-create-schema-sequence.sql /docker-entrypoint-initdb.d/
COPY ./example/01-hosting-use-case/02-create-table.sql /docker-entrypoint-initdb.d/
Expand All @@ -11,8 +11,7 @@ COPY ./example/01-hosting-use-case/04-insert-user-data.sql /docker-entrypoint-in

RUN apt-get -qq update -y

RUN apt-get -qq install python3-pip python3-sphinx python3-sphinx-rtd-theme -y
RUN apt-get -qq install python3-pytest python3-pytest-pep8 -y
RUN apt-get -qq install python3-pip -y
RUN apt-get -qq install python3-psycopg2 python3-pymongo -y
RUN apt-get -qq install curl -y

Expand All @@ -25,7 +24,7 @@ RUN apt-get -qq install mongodb-org -y

RUN mkdir -p /data/db

RUN pip3 install /microesb-1.1.tar.gz --break-system-packages
RUN pip3 install /microesb-1.1.1.tar.gz --break-system-packages

ENV POSTGRES_USER postgres
ENV POSTGRES_PASSWORD password
Expand Down
10 changes: 10 additions & 0 deletions example/01-hosting-use-case/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys
import logging
import psycopg2

from microesb import microesb
Expand All @@ -8,6 +10,14 @@
from service_call_metadata import service_metadata


logging.getLogger().addHandler(
logging.StreamHandler(sys.stdout)
)

logging.getLogger().setLevel(
logging.INFO
)

class_mapper = microesb.ClassMapper(
class_references=class_reference,
class_mappings=class_mapping,
Expand Down
2 changes: 1 addition & 1 deletion example/02-pki-management/00-main-ca.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

from pymongo import MongoClient


client = MongoClient('mongodb://127.0.0.1/')
mongodb = client.get_database('microesb')


logging.getLogger().addHandler(
logging.StreamHandler(sys.stdout)
)
Expand Down
3 changes: 3 additions & 0 deletions example/02-pki-management/service_call_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'SYSServiceID': 'generateCertCA',
'data': [
{
'SYSBackendMethod': { 'CertCA': 'gen_cert' },
'CertCA': {
'id': 'test-ca1',
'Smartcard': {
Expand All @@ -28,6 +29,7 @@
'SYSServiceID': 'generateCertServer',
'data': [
{
'SYSBackendMethod': { 'CertServer': 'gen_cert' },
'CertServer': {
'id': 'test-server1',
'CertCA': {
Expand Down Expand Up @@ -57,6 +59,7 @@
'SYSServiceID': 'generateCertClient',
'data': [
{
'SYSBackendMethod': { 'CertClient': 'gen_cert' },
'CertClient': {
'id': 'test-client1',
'CertCA': {
Expand Down
3 changes: 0 additions & 3 deletions example/02-pki-management/service_properties.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
service_properties = {
'SYSBackendMethods': [
('gen_cert', 'on_recursion_finish')
],
'Cert': {
'properties': {
'id': {
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "microesb"
version = "1.1"
version = "1.1.1"

authors = [
{ name="Claus Prüfer", email="pruefer@webcodex.de" },
Expand Down
41 changes: 29 additions & 12 deletions src/microesb.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def set_json_dict(self):
self.logger.debug('processing property:{}'.format(property_id))
self.json_dict[property_id] = getattr(self, property_id)

# Remove optional service method key if present; ignore if absent.
# remove optional service method key if present; ignore if absent.
self.json_dict.pop('SYSServiceMethod', None)

self.logger.debug('self._SYSProperties:{}'.format(self._SYSProperties))
Expand Down Expand Up @@ -482,6 +482,16 @@ def get_class_hierarchy(self):
"""
return self._class_hierarchy

def get_class_properties(self):
""" get_class_properties() method.

:return: self._class_properties
:rtype: dict

Get class properties dictionary.
"""
return self._class_properties

def _map(
self,
*,
Expand Down Expand Up @@ -564,17 +574,24 @@ def __init__(self, *, class_mapper, service_call_data):

self._map(**call_dict)

try:
for class_ref, class_props in class_references.items():
for method_def in class_mapper._class_properties['SYSBackendMethods']:
if method_def[1] == 'on_recursion_finish':
self.logger.debug('SYSBackendMethod:{}'.format(method_def[0]))
try:
getattr(getattr(self._class_mapper, class_ref), method_def[0])()
except (TypeError, AttributeError) as e:
pass
except (KeyError, TypeError, AttributeError) as e:
self.logger.debug('SYSBackendMethods processing exception:{}'.format(e))
class_properties = self._class_mapper.get_class_properties()

if 'SYSBackendMethod' in service_call_data:

bm_root = service_call_data['SYSBackendMethod']
self.logger.debug('SYSBackendMethod:{}'.format(bm_root))
bm_class_id, bm_method = next(iter(bm_root.items()))
bm_class_call_id = copy.deepcopy(bm_class_id)

try:
bm_class_id = class_references[bm_class_id]['property_ref']
except KeyError as e:
self.logger.debug(
'BackendMethod no class_ref:{} exception:{}'.format(bm_class_id, e)
)

if bm_method in class_properties[bm_class_id]['methods']:
getattr(getattr(self._class_mapper, bm_class_call_id), bm_method)()

def _map(
self,
Expand Down
Loading