Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mentat Test 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
Mentat Test 3
Commits
c9f73188
Commit
c9f73188
authored
2 years ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Check GeoIP locations from config file. (Redmine issue: #7539)
parent
46ed419d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/mentat/daemon/component/test_enricher.py
+5
-2
5 additions, 2 deletions
lib/mentat/daemon/component/test_enricher.py
lib/mentat/plugin/enricher/test_geoip.py
+5
-9
5 additions, 9 deletions
lib/mentat/plugin/enricher/test_geoip.py
with
10 additions
and
11 deletions
lib/mentat/daemon/component/test_enricher.py
+
5
−
2
View file @
c9f73188
...
...
@@ -25,7 +25,7 @@ from unittest.mock import call
#
from
mentat.daemon.component.testsuite
import
DaemonComponentTestCase
from
mentat.daemon.component.enricher
import
EnricherDaemonComponent
from
mentat.const
import
CKEY_CORE_SERVICES
,
CKEY_CORE_SERVICES_GEOIP
#-------------------------------------------------------------------------------
# NOTE: Sorry for the long lines in this file. They are deliberate, because the
...
...
@@ -84,6 +84,9 @@ class TestMentatDaemonEnricher(DaemonComponentTestCase):
# Setup daemon component.
self
.
component
.
setup
(
daemon
)
asndb
=
daemon
.
config
[
CKEY_CORE_SERVICES
][
CKEY_CORE_SERVICES_GEOIP
][
'
asndb
'
]
citydb
=
daemon
.
config
[
CKEY_CORE_SERVICES
][
CKEY_CORE_SERVICES_GEOIP
][
'
citydb
'
]
config
=
"
{
'
asn
'
:
'
%s
'
,
\n
'
city
'
:
'
%s
'
,
\n
'
country
'
: None}
"
%
(
asndb
,
citydb
)
self
.
_verbose_print
(
"
TEST01: Daemon mock calls after component setup
"
,
daemon
.
mock_calls
)
daemon
.
c
.
assert_has_calls
([
...
...
@@ -91,7 +94,7 @@ class TestMentatDaemonEnricher(DaemonComponentTestCase):
])
daemon
.
logger
.
assert_has_calls
([
call
.
info
(
"
[STATUS] Component
'
%s
'
: Configuring enrichment plugin
'
%s
'
.
'
%s
'"
,
'
enricher
'
,
'
mentat.plugin.enricher.geoip
'
,
'
GeoipEnricherPlugin
'
),
call
.
info
(
"
Initialized
'
%s
'
enricher plugin: %s
"
,
'
GeoipEnricherPlugin
'
,
"
{
'
asn
'
:
'
/usr/share/GeoIP/GeoLite2-ASN.mmdb
'
,
\n
'
city
'
:
'
/usr/share/GeoIP/GeoLite2-City.mmdb
'
,
\n
'
country
'
: None}
"
),
call
.
info
(
"
Initialized
'
%s
'
enricher plugin: %s
"
,
'
GeoipEnricherPlugin
'
,
config
),
call
.
info
(
"
[STATUS] Component
'
%s
'
: Configuring enrichment plugin
'
%s
'
.
'
%s
'"
,
'
enricher
'
,
'
mentat.plugin.enricher.logger
'
,
'
LoggerEnricherPlugin
'
),
call
.
debug
(
"
Initialized
'
%s
'
enricher plugin
"
,
'
LoggerEnricherPlugin
'
),
call
.
info
(
"
[STATUS] Component
'
%s
'
: Successfully set up all enrichment plugins
"
,
'
enricher
'
)
...
...
This diff is collapsed.
Click to expand it.
lib/mentat/plugin/enricher/test_geoip.py
+
5
−
9
View file @
c9f73188
...
...
@@ -25,6 +25,7 @@ from unittest.mock import call
#
from
mentat.plugin.enricher.testsuite
import
MentatEnricherPluginTestCase
from
mentat.plugin.enricher.geoip
import
GeoipEnricherPlugin
from
mentat.const
import
CKEY_CORE_SERVICES
,
CKEY_CORE_SERVICES_GEOIP
#-------------------------------------------------------------------------------
...
...
@@ -56,10 +57,13 @@ class TestMentatGeoipEnricherPlugin(MentatEnricherPluginTestCase):
mapplication
=
self
.
_build_application_mock
([])
self
.
plugin
.
setup
(
mapplication
)
asndb
=
mapplication
.
config
[
CKEY_CORE_SERVICES
][
CKEY_CORE_SERVICES_GEOIP
][
'
asndb
'
]
citydb
=
mapplication
.
config
[
CKEY_CORE_SERVICES
][
CKEY_CORE_SERVICES_GEOIP
][
'
citydb
'
]
config
=
"
{
'
asn
'
:
'
%s
'
,
\n
'
city
'
:
'
%s
'
,
\n
'
country
'
: None}
"
%
(
asndb
,
citydb
)
self
.
_verbose_print
(
"
TEST01: daemon mock calls after plugin
'
setup
'"
,
mapplication
.
mock_calls
)
mapplication
.
assert_has_calls
([
call
.
logger
.
info
(
"
Initialized
'
%s
'
enricher plugin: %s
"
,
'
GeoipEnricherPlugin
'
,
"
{
'
asn
'
:
'
/usr/share/GeoIP/GeoLite2-ASN.mmdb
'
,
\n
'
city
'
:
'
/usr/share/GeoIP/GeoLite2-City.mmdb
'
,
\n
'
country
'
: None}
"
)
call
.
logger
.
info
(
"
Initialized
'
%s
'
enricher plugin: %s
"
,
'
GeoipEnricherPlugin
'
,
config
)
])
def
test_02_process_01
(
self
):
...
...
@@ -76,10 +80,6 @@ class TestMentatGeoipEnricherPlugin(MentatEnricherPluginTestCase):
}
self
.
plugin
.
setup
(
mapplication
)
mapplication
.
assert_has_calls
([
call
.
logger
.
info
(
"
Initialized
'
%s
'
enricher plugin: %s
"
,
'
GeoipEnricherPlugin
'
,
"
{
'
asn
'
:
'
/usr/share/GeoIP/GeoLite2-ASN.mmdb
'
,
\n
'
city
'
:
'
/usr/share/GeoIP/GeoLite2-City.mmdb
'
,
\n
'
country
'
: None}
"
),
])
mapplication
.
reset_mock
()
result
=
self
.
plugin
.
process
(
mapplication
,
'
msgid
'
,
msg
)
self
.
_verbose_print
(
"
TEST02: daemon mock calls after plugin
'
setup
'"
,
mapplication
.
mock_calls
)
...
...
@@ -114,10 +114,6 @@ class TestMentatGeoipEnricherPlugin(MentatEnricherPluginTestCase):
}
self
.
plugin
.
setup
(
mapplication
)
mapplication
.
assert_has_calls
([
call
.
logger
.
info
(
"
Initialized
'
%s
'
enricher plugin: %s
"
,
'
GeoipEnricherPlugin
'
,
"
{
'
asn
'
:
'
/usr/share/GeoIP/GeoLite2-ASN.mmdb
'
,
\n
'
city
'
:
'
/usr/share/GeoIP/GeoLite2-City.mmdb
'
,
\n
'
country
'
: None}
"
),
])
mapplication
.
reset_mock
()
result
=
self
.
plugin
.
process
(
mapplication
,
'
msgid
'
,
msg
)
self
.
_verbose_print
(
"
TEST02: daemon mock calls after plugin
'
setup
'"
,
mapplication
.
mock_calls
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment