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
bfe76f53
Commit
bfe76f53
authored
Mar 24, 2012
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code coverage 94.86%
parent
b9a776fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
DnsTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
+68
-0
RandomDnsExtensions.cs
...t/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
+2
-0
No files found.
PcapDotNet/src/PcapDotNet.Packets.Test/DnsTests.cs
View file @
bfe76f53
...
@@ -219,6 +219,15 @@ namespace PcapDotNet.Packets.Test
...
@@ -219,6 +219,15 @@ namespace PcapDotNet.Packets.Test
}
}
}
}
[
TestMethod
]
public
void
DnsResourceDataOptionsParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataOptions
(
new
DnsOptions
(
new
DnsOptionLongLivedQuery
(
0
,
DnsLongLivedQueryOpCode
.
Setup
,
DnsLongLivedQueryErrorCode
.
Static
,
1
,
2
)));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Opt
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Opt
,
resourceData
,
-
1
);
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
InvalidOperationException
))]
[
ExpectedException
(
typeof
(
InvalidOperationException
))]
public
void
DnsQueryResourceRecordTtlGetTest
()
public
void
DnsQueryResourceRecordTtlGetTest
()
...
@@ -836,6 +845,65 @@ namespace PcapDotNet.Packets.Test
...
@@ -836,6 +845,65 @@ namespace PcapDotNet.Packets.Test
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
MailExchange
,
resourceData
,
-
14
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
MailExchange
,
resourceData
,
-
14
);
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
))]
public
void
DnsResourceDataDelegationSignerConstructorNullDigestTest
()
{
var
resourceData
=
new
DnsResourceDataDelegationSigner
(
1
,
DnsAlgorithm
.
PrivateDns
,
DnsDigestType
.
Sha1
,
null
);
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
[
TestMethod
]
public
void
DnsResourceDataDomainNameParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataDomainName
(
new
DnsDomainName
(
"pcapdot.net"
));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Ns
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Ns
,
resourceData
,
-
1
);
}
[
TestMethod
]
public
void
DnsResourceDataIsdnParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataIsdn
(
new
DataSegment
(
new
byte
[
5
]),
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Isdn
,
resourceData
,
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Isdn
,
resourceData
,
-
1
);
}
[
TestMethod
]
public
void
DnsResourceDataKeyParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataKey
(
false
,
true
,
false
,
true
,
false
,
true
,
DnsKeyNameType
.
NonZoneEntity
,
DnsKeySignatoryAttributes
.
General
,
DnsKeyProtocol
.
Email
,
DnsAlgorithm
.
Indirect
,
1
,
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Key
,
resourceData
,
-
8
);
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
))]
public
void
DnsResourceDataNamingAuthorityPointerConstructorNullFlagsTest
()
{
var
resourceData
=
new
DnsResourceDataNamingAuthorityPointer
(
1
,
2
,
null
,
DataSegment
.
Empty
,
DataSegment
.
Empty
,
DnsDomainName
.
Root
);
Assert
.
IsNull
(
resourceData
);
Assert
.
Fail
();
}
[
TestMethod
]
public
void
DnsResourceDataSignatureParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataSignature
(
DnsType
.
A
,
DnsAlgorithm
.
RsaSha512
,
2
,
3
,
4
,
5
,
6
,
new
DnsDomainName
(
"pcapdot.net"
),
new
DataSegment
(
new
byte
[
5
]));
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Signature
,
resourceData
,
-
6
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Signature
,
resourceData
,
-
19
);
}
[
TestMethod
]
public
void
DnsResourceDataUriParseWrongLengthTest
()
{
var
resourceData
=
new
DnsResourceDataUri
(
1
,
2
,
new
List
<
DataSegment
>
{
new
DataSegment
(
new
byte
[
5
]),
new
DataSegment
(
new
byte
[
5
])});
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Uri
,
resourceData
,
-
1
);
TestResourceRecordIsNotCreatedWithNewLength
(
DnsType
.
Uri
,
resourceData
,
-
13
);
}
private
static
void
TestDomainNameCompression
(
int
expectedCompressionBenefit
,
DnsLayer
dnsLayer
)
private
static
void
TestDomainNameCompression
(
int
expectedCompressionBenefit
,
DnsLayer
dnsLayer
)
{
{
dnsLayer
.
DomainNameCompressionMode
=
DnsDomainNameCompressionMode
.
Nothing
;
dnsLayer
.
DomainNameCompressionMode
=
DnsDomainNameCompressionMode
.
Nothing
;
...
...
PcapDotNet/src/PcapDotNet.Packets.TestUtils/RandomDnsExtensions.cs
View file @
bfe76f53
...
@@ -25,6 +25,8 @@ namespace PcapDotNet.Packets.TestUtils
...
@@ -25,6 +25,8 @@ namespace PcapDotNet.Packets.TestUtils
dnsLayer
.
IsRecursionDesired
=
random
.
NextBool
();
dnsLayer
.
IsRecursionDesired
=
random
.
NextBool
();
dnsLayer
.
IsRecursionAvailable
=
random
.
NextBool
();
dnsLayer
.
IsRecursionAvailable
=
random
.
NextBool
();
dnsLayer
.
FutureUse
=
random
.
NextBool
();
dnsLayer
.
FutureUse
=
random
.
NextBool
();
dnsLayer
.
IsAuthenticData
=
random
.
NextBool
();
dnsLayer
.
IsCheckingDisabled
=
random
.
NextBool
();
dnsLayer
.
ResponseCode
=
random
.
NextEnum
(
DnsResponseCode
.
BadVersionOrBadSignature
,
DnsResponseCode
.
BadKey
,
DnsResponseCode
.
BadTime
,
DnsResponseCode
.
BadMode
,
dnsLayer
.
ResponseCode
=
random
.
NextEnum
(
DnsResponseCode
.
BadVersionOrBadSignature
,
DnsResponseCode
.
BadKey
,
DnsResponseCode
.
BadTime
,
DnsResponseCode
.
BadMode
,
DnsResponseCode
.
BadName
,
DnsResponseCode
.
BadAlgorithm
,
DnsResponseCode
.
BadTruncation
);
DnsResponseCode
.
BadName
,
DnsResponseCode
.
BadAlgorithm
,
DnsResponseCode
.
BadTruncation
);
dnsLayer
.
DomainNameCompressionMode
=
random
.
NextEnum
<
DnsDomainNameCompressionMode
>();
dnsLayer
.
DomainNameCompressionMode
=
random
.
NextEnum
<
DnsDomainNameCompressionMode
>();
...
...
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