Пример #1
0
        public void CreateCmdLetTest()
        {
            BundleAnchorsCommand cmd = new BundleAnchorsCommand();
            Assert.IsAssignableFrom<Cmdlet>(cmd);

            SignBundleCommand signCmd = new SignBundleCommand();
            Assert.IsAssignableFrom<Cmdlet>(signCmd);
        }
Пример #2
0
        public void CreateSigneBundleTest()
        {
            BundleAnchorsCommand cmd = new BundleAnchorsCommand();
            string[] ignoreArray = new string[] { "Direct.Drhisp.Com Root CAKey.der" };
            cmd.Name = @".\Certificates\nhind\IncomingAnchors";
            cmd.Ignore = ignoreArray;

            IEnumerator result = cmd.Invoke().GetEnumerator();
            result.MoveNext();
           

            SignBundleCommand signCmd = new SignBundleCommand();
            
            var secString = new SecureString();
            foreach (var secchar in "passw0rd!".ToCharArray())
            {
                secString.AppendChar(secchar);
            }
            signCmd.Name = @".\Certificates\redmond\Private\redmond.pfx";
            signCmd.PassKey = secString;
            signCmd.Bundle = (byte[])result.Current;

            result = signCmd.Invoke().GetEnumerator();
            result.MoveNext();
            byte[] signedCmsdata = (byte[])result.Current;

            //Assert (Using agent bundler resolver code)
            AnchorBundle anchorBundle = null;
            Assert.DoesNotThrow(() => anchorBundle = new AnchorBundle(signedCmsdata, true));
            Assert.True(!anchorBundle.Certificates.IsNullOrEmpty());
            Assert.Equal(4, anchorBundle.Certificates.Count);
            Assert.Null(anchorBundle.Metadata);
        }