From 7bc2c11caf85bc7dea3e0953fbb3b2dd8c38c904 Mon Sep 17 00:00:00 2001 From: aliculPix4D Date: Thu, 3 Oct 2024 11:38:51 +0200 Subject: [PATCH] go-concourse: http agent: add the removed test back to http agent test suite Signed-off-by: aliculPix4D --- .../concourse/internal/http_agent_test.go | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 go-concourse/concourse/internal/http_agent_test.go diff --git a/go-concourse/concourse/internal/http_agent_test.go b/go-concourse/concourse/internal/http_agent_test.go new file mode 100644 index 00000000000..d4daeee58cf --- /dev/null +++ b/go-concourse/concourse/internal/http_agent_test.go @@ -0,0 +1,57 @@ +package internal_test + +import ( + "net/http" + + "github.com/concourse/concourse/atc" + . "github.com/concourse/concourse/go-concourse/concourse/internal" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/onsi/gomega/ghttp" + "github.com/tedsuo/rata" +) + +var _ = Describe("HTTPAgent Client", func() { + var ( + atcServer *ghttp.Server + + agent HTTPAgent + + tracing bool + ) + + BeforeEach(func() { + atcServer = ghttp.NewServer() + + agent = NewHTTPAgent(atcServer.URL(), nil, tracing) + }) + + Describe("#Send", func() { + Describe("Different status codes", func() { + Describe("403 response", func() { + BeforeEach(func() { + atcServer = ghttp.NewServer() + + agent = NewHTTPAgent(atcServer.URL(), nil, tracing) + atcServer.AppendHandlers( + ghttp.CombineHandlers( + ghttp.VerifyRequest("DELETE", "/api/v1/teams/main/pipelines/foo"), + ghttp.RespondWith(http.StatusForbidden, "problem"), + ), + ) + }) + It("returns back 403", func() { + resp, err := agent.Send(Request{ + RequestName: atc.DeletePipeline, + Params: rata.Params{ + "pipeline_name": "foo", + "team_name": atc.DefaultTeamName, + }, + }) + Expect(resp.StatusCode).To(Equal(http.StatusForbidden)) + Expect(err).ToNot(HaveOccurred()) + }) + }) + }) + }) +})