コード例 #1
0
        /// <summary>
        /// Delete the keys we created
        /// </summary>
        ///
        public static void tearDownClass()
        {
            // delete all keys when done
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();

            try {
                instance.deleteKey(new Name("/test/KEY/123"));
            } catch (Exception e) {
                System.Console.Error.WriteLine("Failed to clean up generated keys");
            }

            try {
                instance.deleteKey(new Name("/test/KEY/temp1"));
            } catch (Exception e_0) {
                // Not all tests create this key so ignore if we don't delete it.
            }
        }
コード例 #2
0
        /// <summary>
        /// Test of generateKeyPair method, of class FilePrivateKeyStorage.
        /// </summary>
        ///
        public void testGenerateAndDeleteKeys()
        {
            // create some more key files
            FilePrivateKeyStorage instance = new FilePrivateKeyStorage();

            instance.generateKeyPair(new Name("/test/KEY/temp1"), new RsaKeyParams(
                                         2048));
            // check if files created
            FileInfo[] files            = ndnFolder_.listFiles();
            int        createdFileCount = files.Length;

            Assert.AssertTrue(createdFileCount >= 2);             // 2 pre-created + 2 created now + some created by NFD
            // delete these keys
            instance.deleteKey(new Name("/test/KEY/temp1"));
            files = ndnFolder_.listFiles();
            int deletedfileCount = files.Length;

            Assert.AssertTrue(createdFileCount - 2 == deletedfileCount);
        }