Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CentralNic
Badcow-DNS
Commits
56e44569
Commit
56e44569
authored
May 03, 2019
by
Samuel Williams
Browse files
Merge branch 'fix-rr'
parents
91e6aa75
4b2abbd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
docs/Validation.md
0 → 100644
View file @
56e44569
Validation
==========
Very little validation is done automatically when setting RData or Resource Record objects, so the onus is on the
implementor to validate the resource data and the zone record. Contained within the library, however, are some useful
validation tools. These are static functions contained within
`Badcow\DNS\Validator`
(here, simply referred to as
`Validator`
).
## Validate the Zone
`Validator::zone()`
will inspect a number of properties of a Zone, namely:
*
There is exactly one SOA record,
*
There are NS records, and
*
There is exactly one record class (while it is permissible to use obsolete classes such as CHAOS, in all modern
contexts, this is always IN).
The return value is a binary sum of error codes which can be determined using boolean operands. A valid zone will
return
`0`
, AKA
`Validator::ZONE_OKAY`
. _Exempli gratia:_
```
php
$zone
//Some Badcow\DNS\Zone
if
(
Validator
::
zone
(
$zone
)
&
Validator
::
ZONE_NO_SOA
)
echo
"There are no SOA Records"
;
if
(
Validator
::
zone
(
$zone
)
&
Validator
::
ZONE_TOO_MANY_CLASSES
)
echo
"There are too many classes."
;
```
The return codes are:
*
`ZONE_NO_SOA`
*
`ZONE_TOO_MANY_SOA`
*
`ZONE_NO_NS`
*
`ZONE_NO_CLASS`
*
`ZONE_TOO_MANY_CLASSES`
*
`ZONE_OKAY`
tests/ResourceRecordTest.php
View file @
56e44569
...
...
@@ -51,4 +51,16 @@ class ResourceRecordTest extends TestCase
$this
->
assertEquals
(
$comment
,
$rr
->
getComment
());
$this
->
assertEquals
(
$a
->
getType
(),
$rr
->
getType
());
}
public
function
testUnsetTtl
()
{
$rr
=
new
ResourceRecord
(
'example.com.'
);
$ttl
=
10800
;
$this
->
assertNull
(
$rr
->
getTtl
());
$rr
->
setTtl
(
$ttl
);
$this
->
assertEquals
(
$ttl
,
$rr
->
getTtl
());
$rr
->
setTtl
(
null
);
$this
->
assertNull
(
$rr
->
getTtl
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment