Skip to content

Commit cedf3c2

Browse files
committed
added unit tests
Signed-off-by: Gunish Matta <[email protected]>
1 parent 7d49160 commit cedf3c2

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

controllers/event_handling_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net/http"
99
"net/http/httptest"
10+
"net/url"
1011
"testing"
1112
"time"
1213

@@ -78,6 +79,9 @@ func TestEventHandler(t *testing.T) {
7879
},
7980
}
8081

82+
webhook_url, err := url.Parse(provider.Spec.Address)
83+
g.Expect(err).ToNot(HaveOccurred())
84+
g.Expect(webhook_url.Scheme).To(Equal("http"))
8185
g.Expect(k8sClient.Create(context.Background(), provider)).To(Succeed())
8286
g.Eventually(func() bool {
8387
var obj notifyv1.Provider

main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func main() {
7272
leaderElectionOptions leaderelection.Options
7373
aclOptions acl.Options
7474
rateLimiterOptions helper.RateLimiterOptions
75-
insecureNoTLS bool
75+
insecureAllowHTTP bool
7676
)
7777

7878
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
@@ -83,7 +83,7 @@ func main() {
8383
flag.BoolVar(&watchAllNamespaces, "watch-all-namespaces", true,
8484
"Watch for custom resources in all namespaces, if set to false it will only watch the runtime namespace.")
8585
flag.DurationVar(&rateLimitInterval, "rate-limit-interval", 5*time.Minute, "Interval in which rate limit has effect.")
86-
flag.BoolVar(&insecureNoTLS, "insecure-no-tls", false, "Enable the use of HTTP Scheme (no TLS) across all controller level objects. This is not recommended for production environments")
86+
flag.BoolVar(&insecureAllowHTTP, "insecure-allow-http", false, "Enable the use of HTTP Scheme (no HTTPS) across all controller level objects. This is not recommended for production environments")
8787
clientOptions.BindFlags(flag.CommandLine)
8888
logOptions.BindFlags(flag.CommandLine)
8989
leaderElectionOptions.BindFlags(flag.CommandLine)
@@ -171,7 +171,7 @@ func main() {
171171
Registry: crtlmetrics.Registry,
172172
}),
173173
})
174-
eventServer := server.NewEventServer(eventsAddr, log, mgr.GetClient(), aclOptions.NoCrossNamespaceRefs, insecureNoTLS)
174+
eventServer := server.NewEventServer(eventsAddr, log, mgr.GetClient(), aclOptions.NoCrossNamespaceRefs, insecureAllowHTTP)
175175
go eventServer.ListenAndServe(ctx.Done(), eventMdlw, store)
176176

177177
setupLog.Info("starting webhook receiver server", "addr", receiverAddr)

0 commit comments

Comments
 (0)