|
|
@@ -1,42 +1,61 @@
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
using Renci.SshNet.Security.Cryptography.Ciphers.Paddings;
|
|
|
-using Renci.SshNet.Tests.Common;
|
|
|
|
|
|
namespace Renci.SshNet.Tests.Classes.Security.Cryptography.Ciphers.Paddings
|
|
|
{
|
|
|
- /// <summary>
|
|
|
- ///This is a test class for PKCS7PaddingTest and is intended
|
|
|
- ///to contain all PKCS7PaddingTest Unit Tests
|
|
|
- ///</summary>
|
|
|
- [TestClass()]
|
|
|
- public class PKCS7PaddingTest : TestBase
|
|
|
+ [TestClass]
|
|
|
+ public class PKCS7PaddingTest
|
|
|
{
|
|
|
- /// <summary>
|
|
|
- ///A test for Pad
|
|
|
- ///</summary>
|
|
|
+ private PKCS7Padding _padding;
|
|
|
+
|
|
|
+ [TestInitialize]
|
|
|
+ public void SetUp()
|
|
|
+ {
|
|
|
+ _padding = new PKCS7Padding();
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ public void Pad_BlockSizeAndInput_LessThanBlockSize()
|
|
|
+ {
|
|
|
+ var input = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 };
|
|
|
+ var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x03, 0x03, 0x03 };
|
|
|
+
|
|
|
+ var actual = _padding.Pad(8, input);
|
|
|
+
|
|
|
+ Assert.IsTrue(expected.IsEqualTo(actual));
|
|
|
+ }
|
|
|
+
|
|
|
[TestMethod]
|
|
|
- [Ignore] // placeholder for actual test
|
|
|
- public void PadTest()
|
|
|
+ public void Pad_BlockSizeAndInput_MoreThanBlockSizeButNoMultipleOfBlockSize()
|
|
|
{
|
|
|
- PKCS7Padding target = new PKCS7Padding(); // TODO: Initialize to an appropriate value
|
|
|
- int blockSize = 0; // TODO: Initialize to an appropriate value
|
|
|
- byte[] input = null; // TODO: Initialize to an appropriate value
|
|
|
- byte[] expected = null; // TODO: Initialize to an appropriate value
|
|
|
- byte[] actual;
|
|
|
- actual = target.Pad(blockSize, input);
|
|
|
- Assert.AreEqual(expected, actual);
|
|
|
- Assert.Inconclusive("Verify the correctness of this test method.");
|
|
|
+ var input = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 };
|
|
|
+ var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 };
|
|
|
+
|
|
|
+ var actual = _padding.Pad(8, input);
|
|
|
+
|
|
|
+ Assert.IsTrue(expected.IsEqualTo(actual));
|
|
|
+ }
|
|
|
+
|
|
|
+ [TestMethod]
|
|
|
+ public void Pad_BlockSizeAndInputAndOffsetAndLength_LessThanBlockSize()
|
|
|
+ {
|
|
|
+ var input = new byte[] { 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
|
|
+ var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x03, 0x03, 0x03 };
|
|
|
+
|
|
|
+ var actual = _padding.Pad(8, input, 1, input.Length - 2);
|
|
|
+
|
|
|
+ Assert.IsTrue(expected.IsEqualTo(actual));
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- ///A test for PKCS7Padding Constructor
|
|
|
- ///</summary>
|
|
|
[TestMethod]
|
|
|
- [Ignore] // placeholder
|
|
|
- public void PKCS7PaddingConstructorTest()
|
|
|
+ public void Pad_BlockSizeAndInputAndOffsetAndLength_MoreThanBlockSizeButNoMultipleOfBlockSize()
|
|
|
{
|
|
|
- PKCS7Padding target = new PKCS7Padding();
|
|
|
- Assert.Inconclusive("TODO: Implement code to verify target");
|
|
|
+ var input = new byte[] { 0x0f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10 };
|
|
|
+ var expected = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07 };
|
|
|
+
|
|
|
+ var actual = _padding.Pad(8, input, 1, input.Length - 2);
|
|
|
+
|
|
|
+ Assert.IsTrue(expected.IsEqualTo(actual));
|
|
|
}
|
|
|
}
|
|
|
}
|