示例#1
0
		AfterEach(func() {
			otherListener.Close()
		})

		It("returns an error when the port is already taken", func() {
			err := l.ListenAndServe(logger, port)
			Expect(err).To(HaveOccurred())
			Expect(err.Error()).To(ContainSubstring("address already in use"))
		})
	})

	It("listens on a given port", func() {
		err := l.ListenAndServe(logger, port)
		Expect(err).ToNot(HaveOccurred())
		url := fmt.Sprintf("https://localhost:%d/self-update", port)
		resp, err := spec.HttpPut(url, tarballPath, directorCert)
		Expect(err).ToNot(HaveOccurred())
		Expect(resp.StatusCode).To(Equal(http.StatusOK))
	})

	Describe("TLS handshaking", func() {
		var url string

		BeforeEach(func() {
			url = fmt.Sprintf("https://localhost:%d/self-update", port)
		})

		JustBeforeEach(func() {
			err := l.ListenAndServe(logger, port)
			Expect(err).ToNot(HaveOccurred())
		})
示例#2
0
				strconv.Itoa(port),
				"-certFile", spec.FixtureFilename("certs/bootstrapper.crt"),
				"-keyFile", spec.FixtureFilename("certs/bootstrapper.key"),
				"-caPemFile", spec.FixtureFilename("certs/rootCA.pem"),
				"-allowedName", "*",
			)
			var err error
			session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
			Expect(err).ToNot(HaveOccurred())
		})

		AfterEach(func() {
			session.Kill()
			Eventually(session).Should(gexec.Exit())
		})

		It("accepts PUT requests and runs the installer", func() {
			installScript := "#!/bin/bash\necho hello from install script \n"
			tarballPath := spec.CreateTarball(installScript)
			resp, err := spec.HttpPut(url, tarballPath, spec.CertFor("director"))
			Expect(err).ToNot(HaveOccurred())
			Expect(resp.StatusCode).To(Equal(http.StatusOK))

			session.Kill()
			outContents := session.Wait().Out.Contents()
			Expect(outContents).To(ContainSubstring("hello from install script"))
			Expect(outContents).To(ContainSubstring("successfully installed package"))
		})
	})
})