Skip to content

Commit

Permalink
Common: fix PiiPseudonymizerEnrichment for arrays and improve unit te…
Browse files Browse the repository at this point in the history
…sts coverage (close #334)
  • Loading branch information
dilyand committed Sep 15, 2020
1 parent efac498 commit 60af0f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"type": "string"
}
}
},
"field4": {
"type": "string",
"maxLength": 64
}
},
"required": ["field"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class PiiPseudonymizerEnrichmentSpec extends Specification with ValidatedMatcher
| "data": {
| "field" : ["hello", "world"],
| "field2" : null,
| "field3": null
| "field3": null,
| "field4": ""
| }
| }
| ]
Expand Down Expand Up @@ -363,6 +364,11 @@ class PiiPseudonymizerEnrichmentSpec extends Specification with ValidatedMatcher
fieldMutator = JsonMutators("unstruct_event"),
schemaCriterion = SchemaCriterion("com.mailgun", "message_clicked", "jsonschema", 1, 0, 0),
jsonPath = "$.ip"
),
PiiJson(
fieldMutator = JsonMutators("contexts"),
schemaCriterion = SchemaCriterion("com.test", "array", "jsonschema", 1, 0, 0),
jsonPath = "$.field4"
)
),
false,
Expand Down Expand Up @@ -447,7 +453,12 @@ class PiiPseudonymizerEnrichmentSpec extends Specification with ValidatedMatcher
.downField("field3")
.focus must beSome.like { case json => json.isNull })

first and second and third
// Test that empty string in Pii field gets hashed
val fourth = contextJThirdElement
.downField("data")
.get[String]("field4") must beRight("7a3477dad66e666bd203b834c54b6dfe8b546bdbc5283462ad14052abfb06600")

first and second and third and fourth
}

size and validOut
Expand Down

1 comment on commit 60af0f9

@benjben
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dilyand don't we want to leave an empty string empty in the hashed output ?

Please sign in to comment.