Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
6d72e505
Commit
6d72e505
authored
Mar 24, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code coverage 95.21%
parent
bfe76f53
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
0 deletions
+89
-0
DnsTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
+89
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
View file @
6d72e505
...
...
@@ -99,6 +99,7 @@ namespace PcapDotNet.Packets.Test
Assert
.
IsTrue
(
record
.
Equals
((
object
)
record
));
Assert
.
IsInstanceOfType
(
record
.
Data
,
DnsResourceData
.
GetDnsResourceDataType
(
record
.
DnsType
)
??
typeof
(
DnsResourceDataAnything
));
Assert
.
IsTrue
(
record
.
DomainName
.
Equals
((
object
)
record
.
DomainName
));
Assert
.
IsFalse
(
record
.
Data
.
Equals
(
null
));
}
}
}
...
...
@@ -904,6 +905,94 @@ namespace PcapDotNet.Packets.Test
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Uri
,
resourceData
,
-
13
);
}
[
TestMethod
]
public
void
DnsResourceDataAtmAddressParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataAtmAddress
(
DnsAtmAddressFormat
.
E164
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
AtmA
,
resourceData
,
-
6
);
}
[
TestMethod
]
public
void
DnsResourceDataCertificateParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataCertificate
(
DnsCertificateType
.
IPkix
,
1
,
DnsAlgorithm
.
PrivateDns
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Cert
,
resourceData
,
-
6
);
}
[
TestMethod
]
public
void
DnsResourceDataDnsKeyParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataDnsKey
(
false
,
true
,
false
,
2
,
DnsAlgorithm
.
RsaSha512
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
DnsKey
,
resourceData
,
-
6
);
}
[
TestMethod
]
public
void
DnsResourceDataMailingListInfoParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataMailingListInfo
(
new
DnsDomainName
(
"pcapdot.net"
),
new
DnsDomainName
(
"pcapdotnet.codeplex.com"
));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
MInfo
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
MInfo
,
resourceData
,
-
1
);
}
[
TestMethod
]
public
void
DnsResourceDataHostInformationParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataHostInformation
(
new
DataSegment
(
new
byte
[
5
]),
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
HInfo
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
HInfo
,
resourceData
,
-
1
);
}
[
TestMethod
]
public
void
DnsResourceDataIpV4ParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataIpV4
(
IpV4Address
.
Zero
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
A
,
resourceData
,
1
);
}
[
TestMethod
]
public
void
DnsResourceDataIpV6ParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataIpV6
(
IpV6Address
.
Zero
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Aaaa
,
resourceData
,
1
);
}
[
TestMethod
]
public
void
DnsResourceDataNextDomainSecure3ParametersParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataNextDomainSecure3Parameters
(
DnsSecNSec3HashAlgorithm
.
Sha1
,
DnsSecNSec3Flags
.
OptOut
,
1
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
NSec3Parameters
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
NSec3Parameters
,
resourceData
,
-
1
);
}
[
TestMethod
]
public
void
DnsResourceDataRKeyParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataRKey
(
1
,
2
,
DnsAlgorithm
.
Indirect
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
RKey
,
resourceData
,
-
6
);
}
[
TestMethod
]
public
void
DnsResourceDataSinkParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataSink
(
DnsSinkCodingSubCoding
.
TextTaggedDataPrivate
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Sink
,
resourceData
,
-
6
);
}
[
TestMethod
]
public
void
DnsResourceDataStringParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataString
(
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
X25
,
resourceData
,
-
6
);
}
[
TestMethod
]
public
void
DnsResourceDataWellKnownServiceParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataWellKnownService
(
IpV4Address
.
Zero
,
IpV4Protocol
.
IpV6Opts
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Wks
,
resourceData
,
-
6
);
}
private
static
void
TestDomainNameCompression
(
int
expectedCompressionBenefit
,
DnsLayer
dnsLayer
)
{
dnsLayer
.
DomainNameCompressionMode
=
DnsDomainNameCompressionMode
.
Nothing
;
...
...
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