<div dir="ltr">Hi,<div>thanks for the suggestions. So there are two options </div><div>1. overwrite the file in intelmq/etc/.</div><div>2. merge the loaded harmonization in the specific test cases with the custom event fields.</div><div><br></div><div>This might be a good addition to the documentation. </div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Sincerely,<div>Václav Brůžek</div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 28 Feb 2024 at 09:04, Kamil Mankowski <<a href="mailto:mankowski@cert.at">mankowski@cert.at</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I overcome such a problem by creating a custom test base, look at those <br>
snippets as an example:<br>
<br>
import intelmq.lib.test as test<br>
<br>
ADDITIONAL_HARMONIZATION = ["contrib/constituency.harmonization.part.json"]<br>
<br>
def load_harmonization():<br>
harmonization = pkg_resources.resource_filename(<br>
"intelmq_extensions", "etc/harmonization.conf"<br>
)<br>
extensions = []<br>
for file in ADDITIONAL_HARMONIZATION:<br>
with open(pathlib.Path(__file__).parent.parent.parent / file) as f:<br>
extensions.append(json.load(f))<br>
return merge_harmonization(extensions, harmonization)<br>
<br>
class TestCaseMixin:<br>
harmonization = load_harmonization()<br>
<br>
class BotTestCase(TestCaseMixin, test.BotTestCase):<br>
"""Provides test class with additional changes required for <br>
extension bots"""<br>
<br>
In my case, I'm merging the default harmonization with additional <br>
fields, but you can just load your own.<br>
<br>
Best regards<br>
<br>
// Kamil Mańkowski <<a href="mailto:mankowski@cert.at" target="_blank">mankowski@cert.at</a>> - T: +43 676 898 298 7204<br>
// CERT Austria - <a href="https://www.cert.at/" rel="noreferrer" target="_blank">https://www.cert.at/</a><br>
// CERT.at GmbH, FB-Nr. 561772k, HG Wien<br>
<br>
On 2/28/24 08:52, Sebix wrote:<br>
> Dear Václav,<br>
> <br>
> Which harmonization file did you change?<br>
> <br>
> The test library loads the harmonization config from the package itself:<br>
> <br>
> <a href="https://github.com/certtools/intelmq/blob/ac6aa4e306b1431b6db89158e25ed4c2c5a356bd/intelmq/lib/test.py#L190-L191" rel="noreferrer" target="_blank">https://github.com/certtools/intelmq/blob/ac6aa4e306b1431b6db89158e25ed4c2c5a356bd/intelmq/lib/test.py#L190-L191</a><br>
> <br>
> harmonization = <br>
> utils.load_configuration(pkg_resources.resource_filename('intelmq',<br>
> 'etc/harmonization.conf'))<br>
> <br>
> best regards<br>
> Sebastian<br>
> <br>
> Institute for Common Good Technology<br>
> gemeinnütziger Kulturverein - nonprofit cultural society<br>
> <a href="https://commongoodtechnology.org/" rel="noreferrer" target="_blank">https://commongoodtechnology.org/</a><br>
> ZVR 1510673578<br>
> <br>
> On 2/28/24 08:39, Vaclav Bruzek wrote:<br>
>> Dear IntelMQ Developers & Users,<br>
>> I'm trying to incorporate my custom fields in Events and Reports as <br>
>> well as test cases for my custom bots in unit tests. What I¨m still <br>
>> encountering is that the Github actions are failing since my custom <br>
>> fields in harmonization are not known. I've added step which should <br>
>> create the harmonization file in /opt/intelmq/etc/ like so which is <br>
>> the only change to the action:<br>
>><br>
>> - name: Include custom harmonization names<br>
>> run: mkdir -p /opt/intelmq/etc/ && cp <br>
>> docker/fast/harmonization.conf /opt/intelmq/etc/<br>
>><br>
>> However, intelmq still falls back to the default one. If I try to run <br>
>> manually load_configuration("/opt/intelmq/etc/harmonization.conf") the <br>
>> correct result is displayed.<br>
>><br>
>> Does anybody know how to supply the custom configuration to unit tests?<br>
>><br>
>> Sincerely,<br>
>> Václav Brůžek<br>
>><br>
> <br>
</blockquote></div>