Example #1
0
        public void CertificateIsValid(IEnumerable <Task> tasks)
        {
            InstallParam p = new InstallParam("somename", "somevalue");

            tasks.First().LocalParams.Add(p);
            CertificateValidator val = Substitute.ForPartsOf <CertificateValidator>();

            val.WhenForAnyArgs(a => a.FindCertificates(null)).DoNotCallBase();
            X509Certificate2Collection collection = new X509Certificate2Collection();

            collection.Add(new X509Certificate2());
            val.FindCertificates(null).ReturnsForAnyArgs(collection);
            val.Data["StoreName"]  = "Root";
            val.Data["ParamNames"] = p.Name;
            val.WhenForAnyArgs(a => a.ValidateChain(null, null)).DoNotCallBase();
            val.ValidateChain(null, null).ReturnsForAnyArgs(true);

            Assert.DoesNotContain(val.Evaluate(tasks), r => r.State == Sitecore9Installer.Validation.ValidatorState.Error);
            val.Received().ValidateCertificate(collection[0]);
        }