Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88510259
LogCensorTest.scala
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Oct 19, 05:23
Size
1 KB
Mime Type
text/x-c++
Expires
Mon, Oct 21, 05:23 (2 d)
Engine
blob
Format
Raw Data
Handle
21784028
Attached To
R2664 SHRINE MedCo Fork
LogCensorTest.scala
View Options
package
net.shrine.log
import
net.shrine.util.ShouldMatchersForJUnit
import
org.junit.Test
/**
* @author david
* @since 7/24/15
*/
class
LogCensorTest
extends
ShouldMatchersForJUnit
{
@Test
def
testCensorI2b2
()
=
{
val
i2b2PasswordString
=
"""<password is_token="false" token_ms_timeout="1800000">kapow</password>"""
val
expectedI2b2PasswordString
=
"""<password is_token="false" token_ms_timeout="1800000">REDACTED</password>"""
val
result
=
LogCensor
.
censor
(
i2b2PasswordString
)
result
should
be
(
expectedI2b2PasswordString
)
}
@Test
def
testCensorBasicAuthWithMore
()
=
{
val
basicAuthLine
=
"HttpRequest(GET,https://shrine-qa1.hms.harvard.edu:6443/qep/approvedTopics/user/shrine,List(Host: shrine-qa1.hms.harvard.edu:6443, Authorization: Basic cWVwOnRydXN0bWU=, User-Agent: spray-can/1.3.3),Empty,HTTP/1.1)"
val
expectedBasicAuthLine
=
"HttpRequest(GET,https://shrine-qa1.hms.harvard.edu:6443/qep/approvedTopics/user/shrine,List(Host: shrine-qa1.hms.harvard.edu:6443, Authorization: Basic REDACTED, User-Agent: spray-can/1.3.3),Empty,HTTP/1.1)"
val
result
=
LogCensor
.
censor
(
basicAuthLine
)
result
should
be
(
expectedBasicAuthLine
)
}
//Request: HttpRequest(POST,http://example.com/steward/rejectTopic/topic/1,List(Authorization: Basic ZGF2ZTprYWJsYW0=),Empty,HTTP/1.1)
@Test
def
testCensorBasicAuthLast
()
=
{
val
basicAuthLine
=
"Request: HttpRequest(POST,http://example.com/steward/rejectTopic/topic/1,List(Authorization: Basic ZGF2ZTprYWJsYW0=),Empty,HTTP/1.1)"
val
expectedBasicAuthLine
=
"Request: HttpRequest(POST,http://example.com/steward/rejectTopic/topic/1,List(Authorization: Basic REDACTED),Empty,HTTP/1.1)"
val
result
=
LogCensor
.
censor
(
basicAuthLine
)
result
should
be
(
expectedBasicAuthLine
)
}
}
Event Timeline
Log In to Comment