github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/topgun/runtime/resource_certs_test.go (about)

     1  package topgun_test
     2  
     3  import (
     4  	. "github.com/pf-qiu/concourse/v6/topgun/common"
     5  	_ "github.com/lib/pq"
     6  	. "github.com/onsi/ginkgo"
     7  	. "github.com/onsi/gomega"
     8  	"github.com/onsi/gomega/gexec"
     9  )
    10  
    11  var _ = Describe("Resource Certs", func() {
    12  	BeforeEach(func() {
    13  		Deploy(
    14  			"deployments/concourse.yml",
    15  			"-o", "operations/add-other-worker.yml",
    16  			"-o", "operations/other-worker-no-certs.yml",
    17  		)
    18  	})
    19  
    20  	Context("with a certs path configured on the resource", func() {
    21  		BeforeEach(func() {
    22  			By("setting a pipeline that has a tagged resource")
    23  			Fly.Run("set-pipeline", "-n", "-c", "pipelines/certs-tagged-resources.yml", "-p", "resources")
    24  
    25  			By("unpausing the pipeline pipeline")
    26  			Fly.Run("unpause-pipeline", "-p", "resources")
    27  		})
    28  
    29  		It("bind mounts the certs volume if the worker has one", func() {
    30  			By("running the checks")
    31  			Fly.Run("check-resource", "-r", "resources/no-certs")
    32  			Fly.Run("check-resource", "-r", "resources/certs")
    33  
    34  			hijackSession := Fly.Start("hijack", "-c", "resources/no-certs", "--", "ls", "/etc/ssl/certs")
    35  			<-hijackSession.Exited
    36  
    37  			certsContent := string(hijackSession.Out.Contents())
    38  			Expect(certsContent).To(HaveLen(0))
    39  
    40  			hijackSession = Fly.Start("hijack", "-c", "resources/certs", "--", "ls", "/etc/ssl/certs")
    41  			<-hijackSession.Exited
    42  
    43  			certsContent = string(hijackSession.Out.Contents())
    44  			Expect(certsContent).ToNot(HaveLen(0))
    45  		})
    46  
    47  		It("bind mounts the certs volume to resource get containers", func() {
    48  			trigger := Fly.Start("trigger-job", "-w", "-j", "resources/use-em")
    49  			<-trigger.Exited
    50  			Expect(trigger.ExitCode()).To(Equal(1))
    51  
    52  			hijackSession := Fly.Start("hijack", "-j", "resources/use-em", "-s", "certs", "--", "ls", "/etc/ssl/certs")
    53  			<-hijackSession.Exited
    54  			certsContent := string(hijackSession.Out.Contents())
    55  			Expect(certsContent).ToNot(HaveLen(0))
    56  		})
    57  
    58  		It("bind mounts the certs volume to resource put containers", func() {
    59  			trigger := Fly.Start("trigger-job", "-w", "-j", "resources/use-em")
    60  			<-trigger.Exited
    61  			Expect(trigger.ExitCode()).To(Equal(1))
    62  
    63  			hijackSession := Fly.Start("hijack", "-j", "resources/use-em", "-s", "put-certs", "--", "ls", "/etc/ssl/certs")
    64  			Eventually(hijackSession).Should(gexec.Exit(0))
    65  
    66  			certsContent := string(hijackSession.Out.Contents())
    67  			Expect(certsContent).ToNot(HaveLen(0))
    68  		})
    69  	})
    70  })