Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F114365437
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
Sun, May 25, 10:47
Size
1 KB
Mime Type
text/x-php
Expires
Tue, May 27, 10:47 (2 d)
Engine
blob
Format
Raw Data
Handle
26391106
Attached To
rPHU libphutil
PhutilOpaqueEnvelopeTestCase.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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
->
assertEqual
(
false
,
strpos
(
var_export
(
$envelope
,
true
),
$secret
));
$this
->
assertEqual
(
false
,
strpos
(
print_r
(
$envelope
,
true
),
$secret
));
ob_start
();
var_dump
(
$envelope
);
$dump
=
ob_get_clean
();
$this
->
assertEqual
(
false
,
strpos
(
$dump
,
$secret
));
try
{
$this
->
throwTrace
(
$envelope
);
}
catch
(
Exception
$ex
)
{
$trace
=
$ex
->
getTrace
();
$this
->
assertEqual
(
false
,
strpos
(
print_r
(
$trace
,
true
),
$secret
));
}
$backtrace
=
$this
->
getBacktrace
(
$envelope
);
$this
->
assertEqual
(
false
,
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