forked from cloudfoundry/cf-acceptance-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_dns_resolution.go
69 lines (55 loc) · 2.19 KB
/
app_dns_resolution.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package internet_dependent_test
import (
"encoding/json"
"fmt"
. "github.com/cloudfoundry/cf-acceptance-tests/cats_suite_helpers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/cloudfoundry-incubator/cf-test-helpers/cf"
"github.com/cloudfoundry-incubator/cf-test-helpers/helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/app_helpers"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/assets"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/random_name"
"github.com/cloudfoundry/cf-acceptance-tests/helpers/skip_messages"
)
type CatnipCurlResponse struct {
Stdout string
Stderr string
ReturnCode int `json:"return_code"`
}
func pushApp(appName, buildpack string) {
Expect(cf.Cf("push",
appName,
"-b", buildpack,
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().Catnip,
"-c", "./catnip",
"-d", Config.GetAppsDomain()).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
}
func testAppConnectivity(clientAppName string, privateHost string, privatePort int) CatnipCurlResponse {
var catnipCurlResponse CatnipCurlResponse
curlResponse := helpers.CurlApp(Config, clientAppName, fmt.Sprintf("/curl/%s/%d", privateHost, privatePort))
json.Unmarshal([]byte(curlResponse), &catnipCurlResponse)
return catnipCurlResponse
}
var _ = InternetDependentDescribe("App container DNS behavior", func() {
var clientAppName string
var catnipCurlResponse CatnipCurlResponse
BeforeEach(func() {
if !Config.GetIncludeInternetDependent() {
Skip(skip_messages.SkipInternetDependentMessage)
}
})
AfterEach(func() {
app_helpers.AppReport(clientAppName)
Expect(cf.Cf("delete", clientAppName, "-f", "-r").Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
})
It("allows app containers to resolve public DNS", func() {
clientAppName = random_name.CATSRandomName("APP")
pushApp(clientAppName, Config.GetBinaryBuildpackName())
By("Connecting from running container to an external destination")
catnipCurlResponse = testAppConnectivity(clientAppName, "www.google.com", 80)
Expect(catnipCurlResponse.ReturnCode).To(Equal(0), "Expected external traffic to be allowed from app containers to external addresses.")
})
})