stabilize tests

This commit is contained in:
master
2026-02-01 21:37:40 +02:00
parent 55744f6a39
commit 5d5e80b2e4
6435 changed files with 33984 additions and 13802 deletions

View File

@@ -1,6 +1,8 @@
using StellaOps.Cryptography;
using System;
using System.Collections.Generic;
using StellaOps.Cryptography;
namespace StellaOps.Configuration;

View File

@@ -1,9 +1,11 @@
using Microsoft.Extensions.Configuration;
using StellaOps.Authority.Plugins.Abstractions;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Microsoft.Extensions.Configuration;
using StellaOps.Authority.Plugins.Abstractions;
namespace StellaOps.Configuration;

View File

@@ -1,10 +1,12 @@
using Microsoft.Extensions.Configuration;
using NetEscapades.Configuration.Yaml;
using StellaOps.Authority.Plugins.Abstractions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Extensions.Configuration;
using NetEscapades.Configuration.Yaml;
using StellaOps.Authority.Plugins.Abstractions;
namespace StellaOps.Configuration;

View File

@@ -1,6 +1,8 @@
using StellaOps.Cryptography;
using System;
using System.Collections.Generic;
using StellaOps.Cryptography;
namespace StellaOps.Configuration;

View File

@@ -1,12 +1,14 @@
using StellaOps.Auth.Abstractions;
using StellaOps.Authority.Plugins.Abstractions;
using StellaOps.Cryptography;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.RateLimiting;
using StellaOps.Auth.Abstractions;
using StellaOps.Authority.Plugins.Abstractions;
using StellaOps.Cryptography;
namespace StellaOps.Configuration;

View File

@@ -1,6 +1,8 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
namespace StellaOps.Configuration;

View File

@@ -1,6 +1,7 @@
using System;
using Microsoft.Extensions.Configuration;
using NetEscapades.Configuration.Yaml;
using System;
namespace StellaOps.Configuration;

View File

@@ -1,5 +1,6 @@
using System;
using Microsoft.Extensions.Configuration;
using System;
namespace StellaOps.Configuration;

View File

@@ -1,7 +1,8 @@
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
namespace StellaOps.Configuration;

View File

@@ -1,9 +1,9 @@
using StellaOps.Cryptography;
using StellaOps.Cryptography.DependencyInjection;
using StellaOps.Cryptography.Plugin.Pkcs11Gost;
#if STELLAOPS_CRYPTO_PRO
using StellaOps.Cryptography.Plugin.CryptoPro;
#endif
using StellaOps.Cryptography.Plugin.Pkcs11Gost;
namespace StellaOps.Configuration;

View File

@@ -1,13 +1,13 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using StellaOps.Cryptography;
using StellaOps.Cryptography.DependencyInjection;
using StellaOps.Cryptography.Plugin.Pkcs11Gost;
#if STELLAOPS_CRYPTO_PRO
using StellaOps.Cryptography.Plugin.CryptoPro;
#endif
using StellaOps.Cryptography.Plugin.Pkcs11Gost;
using System;
namespace StellaOps.Configuration;

View File

@@ -1,5 +1,6 @@
using System;
using Microsoft.Extensions.Configuration;
using System;
namespace StellaOps.Configuration;

View File

@@ -1,10 +1,15 @@
# StellaOps Configuration Task Board
This board mirrors active sprint tasks for this module.
Source of truth: `docs-archived/implplan/2025-12-29-csproj-audit/SPRINT_20251229_049_BE_csproj_audit_maint_tests.md`.
Source of truth: `docs/implplan/SPRINT_20260130_002_Tools_csproj_remediation_solid_review.md` (active) and `docs-archived/implplan/2025-12-29-csproj-audit/SPRINT_20251229_049_BE_csproj_audit_maint_tests.md`.
| Task ID | Status | Notes |
| --- | --- | --- |
| AUDIT-0049-M | DONE | Revalidated 2026-01-08; open findings tracked in audit report. |
| AUDIT-0049-T | DONE | Revalidated 2026-01-08; open findings tracked in audit report. |
| AUDIT-0049-A | TODO | Requires MAINT/TEST + approval. |
| REMED-20260130-002-S0 | DONE | Stage 0 Tier 0 remediation for AuthorityPluginConfigurationAnalyzer.cs (using sort + re-audit). |
| REMED-20260130-002-S1 | DONE | Stage 1 Tier 0 remediation batch (5 files) logged in remediation-log-20260130-114501.csv. |
| REMED-20260130-002-S2 | DONE | Stage 2 Tier 0 remediation for StellaOps.Configuration; build/test pass; re-audit delta recorded. |
| REMED-20260130-002-SOLID-01 | DOING | SOLID review notes added for Authority/Configuration option files; remaining project files pending. |
| REMED-06 | DONE | SOLID review notes captured for SPRINT_20260130_002. |

View File

@@ -0,0 +1,163 @@
import os
from logs.default_json_logger import default_json_logger
import time
import pandas as pd
from pricing_premium_adjustment.filters.post.base_post_filter import BasePostFilter
from pricing_premium_adjustment.filters.pre.base_pre_filter import BasePreFilter
from pricing_premium_adjustment.filters.base_filter import BaseFilter
from table_interpreter import TableInterpreter
from pricing_premium_adjustment.rates_overwriter import RatesOverwriter
from pricing_premium_adjustment.dict_table_overwriter import DictTableOverwriter
from gen_utils import parse_int_date
from cachetools import cachedmethod
from functools import wraps
import dill
import importlib.util
from model_inference import ModelInference
from api.custom_exceptions import ResourceNotFound
LOGGER = default_json_logger(__name__)
class CustomInterpreter(TableInterpreter):
def __init__(self, anl_pool=None, sys_pool=None, cache=None):
super().__init__(anl_pool, sys_pool, cache=cache)
self.effective_date = None
self.rates_overwriter = RatesOverwriter()
self.dict_table_overwriter = DictTableOverwriter()
def set_effective_date(self, effective_date):
self.effective_date = effective_date
def do_prefilter(self, request):
if not self.pre_filter:
return request
return self.pre_filter.do_filter(request)
def do_postfilter(self, response, request):
st_time = time.time()
if not self.post_filter:
return response
if 'max_dfs' in self.dict_table and hasattr(self.post_filter, 'max_dfs'):
self.post_filter.max_dfs = self.dict_table['max_dfs']
new_resp = self.post_filter.do_filter(response, request)
LOGGER.info(f"Post filter time was {(time.time() - st_time) * 1000: .3f} ms")
return new_resp
#Override
def get_rates(self, request):
self.set_product_code_and_date(request)
self.set_template_code(request)
self.set_version_id()
self.set_filters(self.filter_id, self.version_id)
filtered_request = self.do_prefilter(request)
filtered_response = self.do_postfilter(
super().get_rates(filtered_request, calc_wp=(self.product_id != 2)), filtered_request)
self.restore_dict()
self.reset_fields()
return self.rates_overwriter.do_overwrite(filtered_response, filtered_request)
def set_product_code_and_date(self, request):
if 'productCode' in request:
self.product_code = request['productCode']
assert 'date' in request, 'Missing required field "date"'
self.str_date = self.get_datetime(request['date']).strftime('%Y-%m-%d')
else:
self.str_date = self.get_datetime(parse_int_date(request['insureDate'])).strftime('%Y-%m-%d')
self.product_code = request["goodsId"]
self.set_product_id_and_country_id()
#Override
def gen_save_dict(self):
tmp_dict = super().gen_save_dict()
return tmp_dict
#Override
def basic_load(self, tmp_dict):
super().basic_load(tmp_dict)
if self.apply_max_df:
self.safe_set('max_dfs', self.dict_table)
self.safe_set('exempt_lds', self.dict_table)
#Override
def dict_overwrite(self, request):
self.dict_table_overwriter.do_overwrite(request, self.dict_table)
def restore_dict(self):
if 'fields_to_restore' not in self.dict_table:
return
for f, dict in self.dict_table.pop('fields_to_restore').items():
for k, v in dict.items():
self.dict_table[f][k] = v
def get_cache(self):
return self._cache
def set_filters(self, filter_id, version_id):
self.pre_filter, self.post_filter = self.get_filters(filter_id, version_id)
# @cachedmethod(get_cache)
def get_filters(self, filter_id, version_id):
prefilter = BasePreFilter()
postfilter = BasePostFilter()
prefilter.gen_filter
if filter_id is None:
return prefilter, postfilter
sql = 'select FILTER_TYPE, PREFILTER_CLASS, POSTFILTER_CLASS, PREFILTER_BLOB, POSTFILTER_BLOB from custom_filters where custom_filter_id =:custom_filter_id'
# cursor = self.conn.cursor()
# cursor.execute(sql, custom_filter_id=filter_id)
# result = cursor.fetchall()
df = pd.read_sql(sql, self.conn, params={'custom_filter_id': filter_id})
if df['FILTER_TYPE'][0] == "CLASS":
prefilter_class = df['PREFILTER_CLASS'][0]
postfilter_class = df['POSTFILTER_CLASS'][0]
if prefilter_class:
prefilter = self.load_filter("pre", prefilter_class)
prefilter.gen_filter(self.effective_date)
if postfilter_class:
postfilter = self.load_filter("post", postfilter_class)
postfilter.gen_filter(self.effective_date)
if df['FILTER_TYPE'][0] == "BLOB":
if df['PREFILTER_BLOB'][0].read() is not None:
try:
prefilter = dill.loads(df['PREFILTER_BLOB'][0].read())
prefilter.gen_filter(conn=self.conn, product_code=self.product_code)
except Exception as ex:
LOGGER.error(f'Loading prefilter failed with exeption {ex}')
else:
LOGGER.error('No prefilter found')
if df['POSTFILTER_BLOB'][0] is not None:
try:
postfilter: BasePostFilter = dill.loads(df['POSTFILTER_BLOB'][0].read())
postfilter.gen_filter(ModelInference)
except Exception as ex:
LOGGER.error(f'Loading postfilter failed with exeption {ex}')
else:
LOGGER.error('No postfilter found')
return prefilter, postfilter
# @cachedmethod(get_cache)
def load_filter(self, filter_type, class_name) -> BaseFilter:
current_file_path = os.path.dirname(__file__)
filter_path = os.path.join(current_file_path, 'pricing_premium_adjustment', 'filters', filter_type, f'{class_name}.py')
# filter_path = f'pricing_premium_adjustment/filters/{filter_type}/{class_name}.py'
if not os.path.exists(filter_path):
raise ResourceNotFound(f'{class_name} filter not found.')
spec = importlib.util.spec_from_file_location(f'{class_name}', filter_path)
if spec:
filter_module = importlib.util.module_from_spec(spec)
if spec.loader:
spec.loader.exec_module(filter_module)
base_class = filter_module.BasePreFilter if filter_type == 'pre' else filter_module.BasePostFilter
for attr in dir(filter_module):
attr_value = getattr(filter_module, attr)
if isinstance(attr_value, type) and issubclass(attr_value, base_class) and attr_value is not base_class:
return attr_value()
raise ResourceNotFound(f'No valid post-filter class found in {filter_path}')
# EOF