refactor: enhance TLS cert generation and refactor HTTP client architecture (#3638)

- Refactored HTTP client from global cache to struct-based approach (global state was shared between tests, including what certificates to use)
- Enhanced pkg/test/tls to support ECDSA and ED25519 key types
- Replaced static certificate files with dynamic generation in golang tests
- Fixed test cleanup issues and improved resource management

This eliminates dependency on external cert generation scripts and
improves test maintainability.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2025-12-13 09:47:32 +02:00
committed by GitHub
parent 1447bb24b4
commit cf8b0bdbf9
22 changed files with 1590 additions and 554 deletions
+6 -6
View File
@@ -44,7 +44,7 @@ func TestSearchCommandGQL(t *testing.T) {
Convey("query", func() {
args := []string{"query", "repo/al", "--config", "searchtest"}
cmd := NewSearchCommand(mockService{})
cmd := NewSearchCommand(newMockService())
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
@@ -62,7 +62,7 @@ func TestSearchCommandGQL(t *testing.T) {
Convey("query command errors", func() {
// no url
args := []string{"repo/al", "--config", "searchtest"}
cmd := NewSearchQueryCommand(mockService{})
cmd := NewSearchQueryCommand(newMockService())
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(buff)
@@ -76,7 +76,7 @@ func TestSearchCommandGQL(t *testing.T) {
So(err, ShouldBeNil)
args := []string{"subject", "repo:tag", "--config", "searchtest"}
cmd := NewSearchCommand(mockService{})
cmd := NewSearchCommand(newMockService())
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
@@ -93,7 +93,7 @@ func TestSearchCommandGQL(t *testing.T) {
Convey("subject command errors", func() {
// no url
args := []string{"repo:tag", "--config", "searchtest"}
cmd := NewSearchSubjectCommand(mockService{})
cmd := NewSearchSubjectCommand(newMockService())
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
cmd.SetErr(buff)
@@ -123,7 +123,7 @@ func TestSearchCommandREST(t *testing.T) {
Convey("query", func() {
args := []string{"query", "repo/al", "--config", "searchtest"}
cmd := NewSearchCommand(mockService{})
cmd := NewSearchCommand(newMockService())
buff := bytes.NewBufferString("")
cmd.SetOut(buff)
@@ -138,7 +138,7 @@ func TestSearchCommandREST(t *testing.T) {
So(err, ShouldBeNil)
args := []string{"subject", "repo:tag", "--config", "searchtest"}
cmd := NewSearchCommand(mockService{})
cmd := NewSearchCommand(newMockService())
buff := bytes.NewBufferString("")
cmd.SetOut(buff)