-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added tls support to cloud service broker app
When running as an app in CF we can rely on the platform to handle TLS setup, but on a VM currently there is no way to have encrypted traffic. TPCF-26820
- Loading branch information
1 parent
8860e24
commit 290446f
Showing
4 changed files
with
201 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package integrationtest_test | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/cloudfoundry/cloud-service-broker/v2/integrationtest/packer" | ||
"github.com/cloudfoundry/cloud-service-broker/v2/internal/testdrive" | ||
) | ||
|
||
var _ = Describe("Starting Server", func() { | ||
|
||
const userProvidedPlan = `[{"name": "user-plan-unique","id":"8b52a460-b246-11eb-a8f5-d349948e2481"}]` | ||
|
||
var brokerpak string | ||
|
||
BeforeEach(func() { | ||
brokerpak = must(packer.BuildBrokerpak(csb, fixtures("service-catalog"))) | ||
|
||
DeferCleanup(func() { | ||
cleanup(brokerpak) | ||
}) | ||
}) | ||
|
||
When("TLS data is provided", func() { | ||
When("Valid data exists", func() { | ||
It("Should accept HTTPS requests", func() { | ||
isValid := true | ||
broker, err := testdrive.StartBroker(csb, brokerpak, database, testdrive.WithTLSConfig(isValid), testdrive.WithEnv(fmt.Sprintf("GSB_SERVICE_ALPHA_SERVICE_PLANS=%s", userProvidedPlan)), testdrive.WithOutputs(GinkgoWriter, GinkgoWriter)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
_, err = http.Get(fmt.Sprintf("https://localhost:%d", broker.Port)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
}) | ||
|
||
When("Invalid data exists", func() { | ||
It("Should fail to start", func() { | ||
notValid := false | ||
_, err := testdrive.StartBroker(csb, brokerpak, database, testdrive.WithTLSConfig(notValid), testdrive.WithEnv(fmt.Sprintf("GSB_SERVICE_ALPHA_SERVICE_PLANS=%s", userProvidedPlan)), testdrive.WithOutputs(GinkgoWriter, GinkgoWriter)) | ||
Expect(err).To(HaveOccurred()) | ||
}) | ||
}) | ||
}) | ||
|
||
When("No TLS data is provided", func() { | ||
It("Should return an error for HTTPS requests", func() { | ||
broker, err := testdrive.StartBroker(csb, brokerpak, database, testdrive.WithEnv(fmt.Sprintf("GSB_SERVICE_ALPHA_SERVICE_PLANS=%s", userProvidedPlan)), testdrive.WithOutputs(GinkgoWriter, GinkgoWriter)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
_, err = http.Get(fmt.Sprintf("https://localhost:%d", broker.Port)) | ||
Expect(err).To(HaveOccurred()) | ||
}) | ||
|
||
It("Should succeed for HTTP requests", func() { | ||
broker, err := testdrive.StartBroker(csb, brokerpak, database, testdrive.WithEnv(fmt.Sprintf("GSB_SERVICE_ALPHA_SERVICE_PLANS=%s", userProvidedPlan)), testdrive.WithOutputs(GinkgoWriter, GinkgoWriter)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
|
||
_, err = http.Get(fmt.Sprintf("http://localhost:%d", broker.Port)) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters