forked from cloudfoundry/cf-acceptance-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wildcard_routes.go
103 lines (84 loc) · 3.5 KB
/
wildcard_routes.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package apps
import (
. "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-incubator/cf-test-helpers/workflowhelpers"
"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"
)
var _ = AppsDescribe("Wildcard Routes", func() {
var appNameCatnip string
var appNameSimple string
var domainName string
var orgName string
var spaceName string
curlRoute := func(hostName string, path string) string {
uri := Config.Protocol() + hostName + "." + domainName + path
curlCmd := helpers.CurlSkipSSL(true, uri).Wait()
Expect(curlCmd).To(Exit(0))
Expect(string(curlCmd.Err.Contents())).To(HaveLen(0))
return string(curlCmd.Out.Contents())
}
BeforeEach(func() {
orgName = TestSetup.RegularUserContext().Org
spaceName = TestSetup.RegularUserContext().Space
domainName = random_name.CATSRandomName("DOMAIN") + "." + Config.GetAppsDomain()
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("create-shared-domain", domainName).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
})
appNameCatnip = random_name.CATSRandomName("APP")
appNameSimple = random_name.CATSRandomName("APP")
Expect(cf.Cf(
"push", appNameCatnip,
"-b", Config.GetBinaryBuildpackName(),
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().Catnip,
"-c", "./catnip",
"-d", Config.GetAppsDomain(),
).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
Expect(cf.Cf(
"push", appNameSimple,
"-b", Config.GetRubyBuildpackName(),
"-m", DEFAULT_MEMORY_LIMIT,
"-p", assets.NewAssets().HelloWorld,
"-d", Config.GetAppsDomain(),
).Wait(Config.CfPushTimeoutDuration())).To(Exit(0))
})
AfterEach(func() {
app_helpers.AppReport(appNameCatnip)
app_helpers.AppReport(appNameSimple)
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("target", "-o", orgName).Wait()).To(Exit(0))
Expect(cf.Cf("delete-shared-domain", domainName, "-f").Wait()).To(Exit(0))
})
Expect(cf.Cf("delete", appNameCatnip, "-f", "-r").Wait()).To(Exit(0))
Expect(cf.Cf("delete", appNameSimple, "-f", "-r").Wait()).To(Exit(0))
})
Describe("Adding a wildcard route to a domain", func() {
It("completes successfully", func() {
wildCardRoute := "*"
regularRoute := "bar"
workflowhelpers.AsUser(TestSetup.AdminUserContext(), Config.DefaultTimeoutDuration(), func() {
Expect(cf.Cf("target", "-o", orgName).Wait()).To(Exit(0))
Expect(cf.Cf("create-route", spaceName, domainName, "-n", wildCardRoute).Wait()).To(Exit(0))
})
Expect(cf.Cf("create-route", spaceName, domainName, "-n", regularRoute).Wait()).To(Exit(0))
Expect(cf.Cf("map-route", appNameCatnip, domainName, "-n", wildCardRoute).Wait()).To(Exit(0))
Expect(cf.Cf("map-route", appNameSimple, domainName, "-n", regularRoute).Wait()).To(Exit(0))
Eventually(func() string {
return curlRoute(regularRoute, "/")
}).Should(ContainSubstring("Hello"))
Eventually(func() string {
return curlRoute("foo", "/")
}).Should(ContainSubstring("Catnip?"))
Eventually(func() string {
return curlRoute("foo.baz", "/")
}).Should(ContainSubstring("Catnip?"))
})
})
})