steinfletcher/apitest

Private pair authentication to api

evgmoskalenko opened this issue · 3 comments

Hi, are you planning to add private pair authentication for rest client?

KeyPair ("client-crt.pem", "client-key.pem")

func TestHealthy(t *testing.T) {

	cert, err := tls.LoadX509KeyPair(settings.Get().ClientCRT, settings.Get().ClientKey)
	if err != nil {
		log.Fatalf("server: loadkeys: %s", err)
	}

	tr := &http.Transport{
		TLSClientConfig: &tls.Config{
			Certificates: []tls.Certificate{cert},
			InsecureSkipVerify: true,
		},
	}

	client := &http.Client{
		Transport: tr,
	}

	t.Run("Validate healthcheck status", func(t *testing.T) {
		apitest.New().
			EnableNetworking(client).
			Get("/api/health/").
			Expect(t).
			Status(http.StatusOK).
			Assert(jsonpath.Equal(`$.db_default.status`, "SUCCESS")).
			End()
	})
}

Hi @evgmoskalenko. I would be happy to take a PR for this. It's not something I have a use case for right now so I am not planning on implementing it myself. Many thanks

Closing due to inactivity