mirror of
https://github.com/go-sigma/sigma.git
synced 2026-10-29 01:06:51 +08:00
Add tlsVerify configuration field to control TLS certificate verification for the builder API client. Update all sample config files and helm templates to include the new setting, and add supporting code to handle the config value, pass it through the client chain, and add tests for both the config parsing and client behavior. Verification: go test ./pkg/builder/... ./pkg/config/...
48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
// Copyright 2026 sigma
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package builder
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestNewAPIClientTLSVerify(t *testing.T) {
|
|
client := newAPIClient("token", "https://sigma.example", true)
|
|
transport, err := client.cli.HTTPTransport()
|
|
require.NoError(t, err)
|
|
require.False(t, tlsInsecureSkipVerify(transport))
|
|
}
|
|
|
|
func TestNewAPIClientTLSVerifyDisabled(t *testing.T) {
|
|
client := newAPIClient("token", "https://sigma.example", false)
|
|
transport, err := client.cli.HTTPTransport()
|
|
require.NoError(t, err)
|
|
require.True(t, tlsInsecureSkipVerify(transport))
|
|
}
|
|
|
|
func TestNewAPIClientTLSVerifyDisabledForHTTP(t *testing.T) {
|
|
client := newAPIClient("token", "http://sigma.example", false)
|
|
transport, err := client.cli.HTTPTransport()
|
|
require.NoError(t, err)
|
|
require.False(t, tlsInsecureSkipVerify(transport))
|
|
}
|
|
|
|
func tlsInsecureSkipVerify(transport *http.Transport) bool {
|
|
return transport != nil && transport.TLSClientConfig != nil && transport.TLSClientConfig.InsecureSkipVerify
|
|
}
|