Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100482159
PhutilOpaqueEnvelopeTestCase.php
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
Fri, Jan 31, 03:43
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 2, 03:43 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23973535
Attached To
rPHU libphutil
PhutilOpaqueEnvelopeTestCase.php
View Options
<?php
final
class
PhutilOpaqueEnvelopeTestCase
extends
PhutilTestCase
{
public
function
testOpaqueEnvelope
()
{
// NOTE: When run via "arc diff", this test's trace may include portions of
// the diff itself, and thus this source code. Since we look for the secret
// in traces later on, split it apart here so that invocation via
// "arc diff" doesn't create a false test failure.
$secret
=
'hunter'
.
'2'
;
$envelope
=
new
PhutilOpaqueEnvelope
(
$secret
);
$this
->
assertFalse
(
strpos
(
var_export
(
$envelope
,
true
),
$secret
));
$this
->
assertFalse
(
strpos
(
print_r
(
$envelope
,
true
),
$secret
));
ob_start
();
var_dump
(
$envelope
);
$dump
=
ob_get_clean
();
$this
->
assertFalse
(
strpos
(
$dump
,
$secret
));
try
{
$this
->
throwTrace
(
$envelope
);
}
catch
(
Exception
$ex
)
{
$trace
=
$ex
->
getTrace
();
$this
->
assertFalse
(
strpos
(
print_r
(
$trace
,
true
),
$secret
));
}
$backtrace
=
$this
->
getBacktrace
(
$envelope
);
$this
->
assertFalse
(
strpos
(
print_r
(
$backtrace
,
true
),
$secret
));
$this
->
assertEqual
(
$secret
,
$envelope
->
openEnvelope
());
}
private
function
throwTrace
(
$v
)
{
throw
new
Exception
(
'!'
);
}
private
function
getBacktrace
(
$v
)
{
return
debug_backtrace
();
}
}
Event Timeline
Log In to Comment