Ejemplo n.º 1
0
func NewWindowsCertManager(fs boshsys.FileSystem, runner boshsys.CmdRunner, dirProvider boshdir.Provider, logger logger.Logger) Manager {
	return &windowsCertManager{
		fs:          fs,
		runner:      runner,
		dirProvider: dirProvider,
		logger:      logger,
		backupPath:  path.Join(dirProvider.TmpDir(), "rootCertBackup.sst"),
	}
}
Ejemplo n.º 2
0
				dirProvider = boshdir.NewProvider(tempDir)
				certManager = cert.NewWindowsCertManager(fs, boshsys.NewExecCmdRunner(log), dirProvider, log)
			})

			AfterEach(func() {
				for _, thumbprint := range certThumbprints {
					cmd := exec.Command("powershell", "-Command", fmt.Sprintf(removeCertScript, `Cert:\LocalMachine\Root\`+thumbprint))
					session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
					Expect(err).To(BeNil())
					Eventually(session).Should(gexec.Exit(0))
				}
				os.RemoveAll(tempDir)
			})

			It("should create the tmpDir if doesn't exist", func() {
				_, err := os.Stat(dirProvider.TmpDir())
				fmt.Println("BEfore", dirProvider.TmpDir(), err)
				missing := os.IsNotExist(err)
				Expect(missing).To(BeTrue())
				err = certManager.UpdateCertificates(validCerts)
				Expect(err).To(BeNil())
				_, err = os.Stat(dirProvider.TmpDir())
				Expect(err).To(BeNil())
			})

			Context("When TempDir exists", func() {
				BeforeEach(func() {
					err := fs.MkdirAll(dirProvider.TmpDir(), os.FileMode(0777))
					Expect(err).To(BeNil())
				})
				It("adds certs to the trusted cert chain", func() {