Skip to content
This repository has been archived by the owner on Jun 4, 2021. It is now read-only.

Commit

Permalink
Fix platform specific error checking in IpLookupsEnrichmentSpec (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFradet authored and oguzhanunlu committed May 29, 2020
1 parent 679bb68 commit 5669f67
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,11 @@ class IpLookupsEnrichmentSpec extends Specification with DataTables with Validat

def e1 =
"SPEC NAME" || "IP ADDRESS" | "EXPECTED LOCATION" |
"blank IP address" !! "" ! Some(Failure("The address 127.0.0.1 is not in the database.")) |
"null IP address" !! null ! Some(Failure("The address 127.0.0.1 is not in the database.")) |
"invalid IP address #1" !! "localhost" ! Some(Failure("The address 127.0.0.1 is not in the database.")) |
"invalid IP address #2" !! "hello" ! Some(Failure("hello: unknown error")) |
// "invalid IP address #2" !! "hello" ! Some(Failure("hello: Name or service not known")) |
"valid IP address" !! "175.16.199.0" !
"blank IP address" !! "" ! Some(Failure("AddressNotFoundException")) |
"null IP address" !! null ! Some(Failure("AddressNotFoundException")) |
"invalid IP address #1" !! "localhost" ! Some(Failure("AddressNotFoundException")) |
"invalid IP address #2" !! "hello" ! Some(Failure("UnknownHostException")) |
"valid IP address" !! "175.16.199.0" !
IpLocation( // Taken from scala-maxmind-geoip. See that test suite for other valid IP addresses
countryCode = "CN",
countryName = "China",
Expand All @@ -71,7 +70,7 @@ class IpLookupsEnrichmentSpec extends Specification with DataTables with Validat
metroCode = None,
regionName = Some("Jilin Sheng")
).success.some |> { (_, ipAddress, expected) =>
config.extractIpInformation(ipAddress).ipLocation.map(_.leftMap(_.getMessage)) must_== expected
config.extractIpInformation(ipAddress).ipLocation.map(_.leftMap(_.getClass.getSimpleName)) must_== expected
}

def e2 = config.extractIpInformation("70.46.123.145").isp must_== "FDN Communications".success.some
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class PiiPseudonymizerEnrichmentSpec extends Specification with ValidationMatche
expected.user_ipaddress = "dd9720903c89ae891ed5c74bb7a9f2f90f6487927ac99afe73b096ad0287f3f5"
expected.ip_domain = null
expected.user_fingerprint = "27abac60dff12792c6088b8d00ce7f25c86b396b8c3740480cd18e21068ecff4"
expected.geo_city = null
expected.geo_city = null
expected.etl_tstamp = "1970-01-18 08:40:00.000"
expected.collector_tstamp = "2017-07-14 03:39:39.000"
output.size must_== 1
Expand Down

0 comments on commit 5669f67

Please sign in to comment.