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
b47f8f31
Commit
b47f8f31
authored
Mar 24, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code coverage 94.6%
parent
62def0bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
DnsTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
+65
-0
DnsResourceDataNInfo.cs
...apDotNet.Packets/Dns/ResourceData/DnsResourceDataNInfo.cs
+1
-1
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
View file @
b47f8f31
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Text
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
...
...
@@ -584,6 +585,15 @@ namespace PcapDotNet.Packets.Test
Assert
.
IsTrue
(
dnsAddressPrefix
.
Equals
((
object
)
dnsAddressPrefix
));
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
))]
public
void
DnsAddressPrefixConstructorNullAddressFamilyDependentPartTtest
()
{
var
dnsAddressPrefix
=
new
DnsAddressPrefix
(
AddressFamily
.
IpV4
,
0
,
false
,
null
);
Assert
.
IsNull
(
dnsAddressPrefix
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
))]
public
void
DnsResourceDataNextDomainSecure3NextHashedOwnerNameTooBigTest
()
...
...
@@ -638,6 +648,25 @@ namespace PcapDotNet.Packets.Test
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
))]
public
void
DnsResourceDataCertificationAuthorityAuthorizationConstructorNullTagTest
()
{
var
resourceData
=
new
DnsResourceDataCertificationAuthorityAuthorization
(
DnsCertificationAuthorityAuthorizationFlags
.
Critical
,
null
,
DataSegment
.
Empty
);
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
[
TestMethod
]
public
void
DnsResourceDataCertificationAuthorityAuthorizationParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataCertificationAuthorityAuthorization
(
DnsCertificationAuthorityAuthorizationFlags
.
Critical
,
new
DataSegment
(
new
byte
[
5
]),
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
CertificationAuthorityAuthorization
,
resourceData
,
-
6
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
CertificationAuthorityAuthorization
,
resourceData
,
-
11
);
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
))]
public
void
DnsResourceDataA6ConstructorAddressSuffixTooSmallTest
()
...
...
@@ -674,6 +703,42 @@ namespace PcapDotNet.Packets.Test
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Apl
,
resourceData
,
-
1
);
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
))]
public
void
DnsResourceDataNInfoConstructorNullStringsTest
()
{
var
resourceData
=
new
DnsResourceDataNInfo
(
null
as
ReadOnlyCollection
<
DataSegment
>);
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentOutOfRangeException
))]
public
void
DnsResourceDataNInfoConstructorTooFewStringsTest
()
{
var
resourceData
=
new
DnsResourceDataNInfo
();
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
[
TestMethod
]
public
void
DnsResourceDataNInfoParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataNInfo
(
new
DataSegment
(
new
byte
[
5
]),
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
NInfo
,
resourceData
,
-
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
NInfo
,
resourceData
,
-
12
);
}
[
TestMethod
]
public
void
DnsResourceDataGeographicalPositionWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataGeographicalPosition
(
"5.03"
,
"-44.4"
,
"22.1"
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
GPos
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
GPos
,
resourceData
,
-
5
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
GPos
,
resourceData
,
-
10
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
GPos
,
resourceData
,
-
14
);
}
private
static
void
TestDomainNameCompression
(
int
expectedCompressionBenefit
,
DnsLayer
dnsLayer
)
{
dnsLayer
.
DomainNameCompressionMode
=
DnsDomainNameCompressionMode
.
Nothing
;
...
...
PcapDotNet/src/PcapDotNet.Packets/Dns/ResourceData/DnsResourceDataNInfo.cs
View file @
b47f8f31
...
...
@@ -49,7 +49,7 @@ namespace PcapDotNet.Packets.Dns
internal
override
DnsResourceData
CreateInstance
(
DataSegment
data
)
{
List
<
DataSegment
>
strings
=
ReadStrings
(
data
,
MinNumStrings
);
if
(
strings
==
null
||
strings
.
Count
<
1
)
if
(
strings
==
null
||
strings
.
Count
<
MinNumStrings
)
return
null
;
return
new
DnsResourceDataNInfo
(
strings
.
AsReadOnly
());
...
...
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