Skip to content

Commit

Permalink
feat: Added InsecureSkipTlsVerify flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Bharadwajshivam28 committed Oct 15, 2024
1 parent 0925f8f commit 9f8605a
Showing 1 changed file with 7 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,19 @@ func Test_GetRoundtripper(t *testing.T) {
},
}
tests := []struct {
name string
provider metricsapi.KeptnMetricsProvider
k8sClient client.Client
want http.RoundTripper
wantErr bool
errorStr string
insecureSkipTlsVerify bool
name string
provider metricsapi.KeptnMetricsProvider
k8sClient client.Client
want http.RoundTripper
wantErr bool
errorStr string
}{
{
name: "TestSuccess",
provider: metricsapi.KeptnMetricsProvider{
ObjectMeta: metav1.ObjectMeta{Namespace: "default"},
Spec: metricsapi.KeptnMetricsProviderSpec{
Type: "",
TargetServer: "",
TargetServer: "someTargetServer",
SecretKeyRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{
Name: "test",
Expand All @@ -145,34 +143,6 @@ func Test_GetRoundtripper(t *testing.T) {
want: config.NewBasicAuthRoundTripper("myuser", "mytoken", "", "", promapi.DefaultRoundTripper),
wantErr: false,
},
{
name: "TestSecretNotDefined",
provider: metricsapi.KeptnMetricsProvider{},
k8sClient: fake.NewClient(),
want: promapi.DefaultRoundTripper,
wantErr: false,
},
{
name: "TestErrorFromGetPrometheusSecretNotExists",
provider: metricsapi.KeptnMetricsProvider{
ObjectMeta: metav1.ObjectMeta{Namespace: "default"},
Spec: metricsapi.KeptnMetricsProviderSpec{
Type: "",
TargetServer: "",
SecretKeyRef: v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{
Name: "test",
},
Key: "",
Optional: nil,
},
},
},
k8sClient: fake.NewClient(),
want: nil,
wantErr: true,
errorStr: "not found",
},
{
name: "TestInsecureSkipTlsVerifyEnabled",
provider: metricsapi.KeptnMetricsProvider{
Expand Down Expand Up @@ -209,14 +179,6 @@ func Test_GetRoundtripper(t *testing.T) {
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("getRoundtripper() got = %v, want %v", got, tt.want)
}

if transport, ok := got.(*config.BasicAuthRoundTripper); ok {
if transport.Transport != nil {
if httpTransport, ok := transport.Transport.(*http.Transport); ok {
require.Equal(t, tt.provider.Spec.InsecureSkipTlsVerify, httpTransport.TLSClientConfig.InsecureSkipVerify, "Expected InsecureSkipTlsVerify to be set")
}
}
}
})
}
}

0 comments on commit 9f8605a

Please sign in to comment.