Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96191604
AlmanacNamesTestCase.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
Mon, Dec 23, 14:59
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 14:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23134760
Attached To
rPH Phabricator
AlmanacNamesTestCase.php
View Options
<?php
final
class
AlmanacNamesTestCase
extends
PhabricatorTestCase
{
public
function
testServiceOrDeviceNames
()
{
$map
=
array
(
''
=>
false
,
'a'
=>
false
,
'ab'
=>
false
,
'...'
=>
false
,
'ab.'
=>
false
,
'.ab'
=>
false
,
'A-B'
=>
false
,
'A!B'
=>
false
,
'A.B'
=>
false
,
'a..b'
=>
false
,
'1.2'
=>
false
,
'127.0.0.1'
=>
false
,
'1.b'
=>
false
,
'a.1'
=>
false
,
'a.1.b'
=>
false
,
'-.a'
=>
false
,
'-a.b'
=>
false
,
'a-.b'
=>
false
,
'a.-'
=>
false
,
'a.-b'
=>
false
,
'a.b-'
=>
false
,
'-.-'
=>
false
,
'a--b'
=>
false
,
'abc'
=>
true
,
'a.b'
=>
true
,
'db.phacility.instance'
=>
true
,
'web002.useast.example.com'
=>
true
,
'master.example-corp.com'
=>
true
,
// Maximum length is 100.
str_repeat
(
'a'
,
100
)
=>
true
,
str_repeat
(
'a'
,
101
)
=>
false
,
);
foreach
(
$map
as
$input
=>
$expect
)
{
$caught
=
null
;
try
{
AlmanacNames
::
validateName
(
$input
);
}
catch
(
Exception
$ex
)
{
$caught
=
$ex
;
}
$this
->
assertEqual
(
$expect
,
!(
$caught
instanceof
Exception
),
$input
);
}
}
}
Event Timeline
Log In to Comment