Skip to content

Commit a6c4a09

Browse files
committed
test case for skip dns validation
1 parent 5e7a844 commit a6c4a09

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

helpers/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type CatsConfig interface {
3939
GetIncludeVolumeServices() bool
4040
GetShouldKeepUser() bool
4141
GetSkipSSLValidation() bool
42+
GetSkipDNSValidation() bool
4243
GetUseExistingUser() bool
4344

4445
GetAddExistingUserToExistingSpace() bool

helpers/config/config_test.go

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ type testConfig struct {
2727
requiredConfig
2828

2929
// timeouts
30-
DefaultTimeout *int `json:"default_timeout,omitempty"`
31-
CfPushTimeout *int `json:"cf_push_timeout,omitempty"`
32-
LongCurlTimeout *int `json:"long_curl_timeout,omitempty"`
33-
BrokerStartTimeout *int `json:"broker_start_timeout,omitempty"`
34-
AsyncServiceOperationTimeout *int `json:"async_service_operation_timeout,omitempty"`
35-
DetectTimeout *int `json:"detect_timeout,omitempty"`
36-
SleepTimeout *int `json:"sleep_timeout,omitempty"`
30+
DefaultTimeout *int `json:"default_timeout,omitempty"`
31+
CfPushTimeout *int `json:"cf_push_timeout,omitempty"`
32+
LongCurlTimeout *int `json:"long_curl_timeout,omitempty"`
33+
BrokerStartTimeout *int `json:"broker_start_timeout,omitempty"`
34+
AsyncServiceOperationTimeout *int `json:"async_service_operation_timeout,omitempty"`
35+
DetectTimeout *int `json:"detect_timeout,omitempty"`
36+
SleepTimeout *int `json:"sleep_timeout,omitempty"`
37+
SkipDNSValidation *bool `json:"skip_dns_validation"`
3738

3839
TimeoutScale *float64 `json:"timeout_scale,omitempty"`
3940

@@ -124,6 +125,7 @@ type nullConfig struct {
124125
IsolationSegmentDomain *string `json:"isolation_segment_domain"`
125126

126127
SkipSSLValidation *bool `json:"skip_ssl_validation"`
128+
SkipDNSValidation *bool `json:"skip_dns_validation"`
127129

128130
ArtifactsDirectory *string `json:"artifacts_directory"`
129131

@@ -948,6 +950,54 @@ var _ = Describe("Config", func() {
948950
})
949951
})
950952

953+
Describe("GetSkipDNSValidation", func() {
954+
Context("when skip_dns_validation is not set", func() {
955+
It("returns false (default)", func() {
956+
config, err := cfg.NewCatsConfig(tmpFilePath)
957+
Expect(err).NotTo(HaveOccurred())
958+
Expect(config.GetSkipDNSValidation()).To(BeFalse())
959+
})
960+
})
961+
962+
Context("when skip_dns_validation is set to true", func() {
963+
BeforeEach(func() {
964+
testCfg.SkipDNSValidation = ptrToBool(true)
965+
})
966+
967+
It("returns true", func() {
968+
config, err := cfg.NewCatsConfig(tmpFilePath)
969+
Expect(err).NotTo(HaveOccurred())
970+
Expect(config.GetSkipDNSValidation()).To(BeTrue())
971+
})
972+
973+
It("skips DNS lookup for apps domain", func() {
974+
testCfg.AppsDomain = ptrToString("apps.domain.example.com")
975+
config, err := cfg.NewCatsConfig(tmpFilePath)
976+
Expect(err).NotTo(HaveOccurred())
977+
Expect(config.GetAppsDomain()).To(Equal("apps.domain.example.com"))
978+
})
979+
})
980+
981+
Context("when skip_dns_validation is set to false", func() {
982+
BeforeEach(func() {
983+
testCfg.SkipDNSValidation = ptrToBool(false)
984+
})
985+
986+
It("returns false", func() {
987+
config, err := cfg.NewCatsConfig(tmpFilePath)
988+
Expect(err).NotTo(HaveOccurred())
989+
Expect(config.GetSkipDNSValidation()).To(BeFalse())
990+
})
991+
992+
It("performs DNS lookup for apps domain", func() {
993+
testCfg.AppsDomain = ptrToString("domain.example.com.does-not-exist")
994+
_, err := cfg.NewCatsConfig(tmpFilePath)
995+
Expect(err).To(HaveOccurred())
996+
Expect(err.Error()).To(ContainSubstring("no such host"))
997+
})
998+
})
999+
})
1000+
9511001
Describe("GetAdminUser", func() {
9521002
It("returns the admin user", func() {
9531003
c, err := cfg.NewCatsConfig(tmpFilePath)

0 commit comments

Comments
 (0)