Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Engineering Digital Service
Metabase
Commits
cd758c96
Unverified
Commit
cd758c96
authored
3 years ago
by
Cam Saul
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix failing geolocation test
(#17707)
parent
65932665
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/metabase/api/login_history_test.clj
+35
-26
35 additions, 26 deletions
test/metabase/api/login_history_test.clj
test/metabase/server/request/util_test.clj
+20
-20
20 additions, 20 deletions
test/metabase/server/request/util_test.clj
with
55 additions
and
46 deletions
test/metabase/api/login_history_test.clj
+
35
−
26
View file @
cd758c96
...
...
@@ -2,7 +2,8 @@
(
:require
[
clojure.test
:refer
:all
]
[
metabase.models
:refer
[
LoginHistory
Session
User
]]
[
metabase.test
:as
mt
]
[
metabase.util
:as
u
]))
[
metabase.util
:as
u
]
[
schema.core
:as
s
]))
(
def
^
:private
windows-user-agent
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/89.0.4389.86 Safari/537.36"
)
...
...
@@ -42,28 +43,36 @@
:device_id
"e9b49ec7-bc64-4a83-9b1a-ecd3ae26ba9d"
:device_description
windows-user-agent
:ip_address
"52.206.149.9"
}]]
(
is
(
=
[{
:timestamp
"2021-03-18T20:55:50.955232Z"
:device_description
"Mobile Browser (Mobile Safari/iOS)"
:ip_address
"0:0:0:0:0:0:0:1"
:active
false
:location
"Unknown location"
:timezone
nil
}
{
:timestamp
"2021-03-18T20:04:24.7273Z"
:device_description
"Library (Apache-HttpClient/JVM (Java))"
:ip_address
"127.0.0.1"
:active
false
:location
"Unknown location"
:timezone
nil
}
{
:timestamp
"2021-03-18T20:52:41.808482+01:00"
:device_description
"Browser (Chrome/Windows)"
:ip_address
"185.233.100.23"
:active
true
:location
"Talence, Nouvelle-Aquitaine, France"
:timezone
"CET"
}
{
:timestamp
"2021-03-18T15:52:20.172351-04:00"
:device_description
"Browser (Chrome/Windows)"
:ip_address
"52.206.149.9"
:active
false
:location
"Ashburn, Virginia, United States"
:timezone
"ET"
}]
(
mt/client
session-id
:get
200
"login-history/current"
)))))))
(
is
(
schema=
[(
s/one
{
:timestamp
(
s/eq
"2021-03-18T20:55:50.955232Z"
)
:device_description
(
s/eq
"Mobile Browser (Mobile Safari/iOS)"
)
:ip_address
(
s/eq
"0:0:0:0:0:0:0:1"
)
:active
(
s/eq
false
)
:location
(
s/eq
"Unknown location"
)
:timezone
(
s/eq
nil
)}
"localhost ipv6"
)
(
s/one
{
:timestamp
(
s/eq
"2021-03-18T20:04:24.7273Z"
)
:device_description
(
s/eq
"Library (Apache-HttpClient/JVM (Java))"
)
:ip_address
(
s/eq
"127.0.0.1"
)
:active
(
s/eq
false
)
:location
(
s/eq
"Unknown location"
)
:timezone
(
s/eq
nil
)}
"localhost ipv4"
)
(
s/one
{
:timestamp
(
s/eq
"2021-03-18T20:52:41.808482+01:00"
)
:device_description
(
s/eq
"Browser (Chrome/Windows)"
)
:ip_address
(
s/eq
"185.233.100.23"
)
:active
(
s/eq
true
)
:location
#
"France"
:timezone
(
s/eq
"CET"
)}
"France"
)
(
s/one
{
:timestamp
(
s/eq
"2021-03-18T15:52:20.172351-04:00"
)
:device_description
(
s/eq
"Browser (Chrome/Windows)"
)
:ip_address
(
s/eq
"52.206.149.9"
)
:active
(
s/eq
false
)
:location
(
s/eq
"Ashburn, Virginia, United States"
)
:timezone
(
s/eq
"ET"
)}
"Virginia"
)]
(
mt/client
session-id
:get
200
"login-history/current"
)))))))
This diff is collapsed.
Click to expand it.
test/metabase/server/request/util_test.clj
+
20
−
20
View file @
cd758c96
...
...
@@ -4,7 +4,8 @@
[
java-time
:as
t
]
[
metabase.server.request.util
:as
request.u
]
[
metabase.test
:as
mt
]
[
ring.mock.request
:as
ring.mock
]))
[
ring.mock.request
:as
ring.mock
]
[
schema.core
:as
s
]))
(
deftest
https?-test
(
doseq
[[
headers
expected
]
{{
"x-forwarded-proto"
"https"
}
true
...
...
@@ -75,34 +76,33 @@
(
request.u/ip-address
mock-request
)))))))))
(
deftest
geocode-ip-addresses-test
(
are
[
ip-addresses
expected
]
(
=
expected
(
request.u/geocode-ip-addresses
ip-addresses
))
(
are
[
ip-addresses
expected
]
(
schema
=
expected
(
request.u/geocode-ip-addresses
ip-addresses
))
[
"8.8.8.8"
]
{
"8.8.8.8"
{
:description
"United States"
,
:timezone
(
t/zone-id
"America/Chicago"
)}}
{(
s/required-key
"8.8.8.8"
)
{
:description
(
s/eq
"United States"
)
:timezone
(
s/eq
(
t/zone-id
"America/Chicago"
))}}
;; this is from the MaxMind sample high-risk IP address list https://www.maxmind.com/en/high-risk-ip-sample-list
[
"185.233.100.23"
]
{
"185.233.100.23"
{
:description
"Talence, Nouvelle-Aquitaine, France"
,
:timezone
(
t/zone-id
"Europe/Paris"
)}}
{(
s/required-key
"185.233.100.23"
)
{
:description
#
"France"
:timezone
(
s/eq
(
t/zone-id
"Europe/Paris"
))}}
[
"127.0.0.1"
]
{
"127.0.0.1"
{
:description
"Unknown location"
,
:timezone
nil
}}
{(
s/required-key
"127.0.0.1"
)
{
:description
(
s/eq
"Unknown location"
)
:timezone
(
s/eq
nil
)}}
[
"0:0:0:0:0:0:0:1"
]
{
"0:0:0:0:0:0:0:1"
{
:description
"Unknown location"
,
:timezone
nil
}}
{(
s/required-key
"0:0:0:0:0:0:0:1"
)
{
:description
(
s/eq
"Unknown location"
)
:timezone
(
s/eq
nil
)}}
;; multiple addresses at once
;; store.metabase.com, Google DNS
[
"52.206.149.9"
"2001:4860:4860::8844"
]
{
"52.206.149.9"
{
:description
"Ashburn, Virginia, United States"
,
:timezone
(
t/zone-id
"America/New_York"
)}
"2001:4860:4860::8844"
{
:description
"United States"
,
:timezone
(
t/zone-id
"America/Chicago"
)}}
[
"wow"
]
nil
[
" "
]
nil
[]
nil
nil
nil
))
{(
s/required-key
"52.206.149.9"
)
{
:description
(
s/eq
"Ashburn, Virginia, United States"
)
:timezone
(
s/eq
(
t/zone-id
"America/New_York"
))}
(
s/required-key
"2001:4860:4860::8844"
)
{
:description
(
s/eq
"United States"
)
:timezone
(
s/eq
(
t/zone-id
"America/Chicago"
))}}
[
"wow"
]
(
s/eq
nil
)
[
" "
]
(
s/eq
nil
)
[]
(
s/eq
nil
)
nil
(
s/eq
nil
)))
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