Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: golden path integration test #953

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions integrationtest/fixtures/golden-path/fake-uuid-bind.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "random_uuid" "random" {}

output bind_output { value = random_uuid.random.result }
3 changes: 3 additions & 0 deletions integrationtest/fixtures/golden-path/fake-uuid-provision.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "random_uuid" "random" {}

output provision_output { value = random_uuid.random.result }
27 changes: 27 additions & 0 deletions integrationtest/fixtures/golden-path/fake-uuid-service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: 1
name: fake-uuid-service
id: f18d50e2-cbf0-11ee-a64b-f7a425623295
description: description
display_name: Fake
image_url: https://example.com/icon.jpg
documentation_url: https://example.com
support_url: https://example.com/support.html
plans:
- name: standard
id: fd01df6a-cbf0-11ee-ac5b-fba53664a953
description: Standard plan
display_name: Standard
provision:
template_refs:
main: fake-uuid-provision.tf
outputs:
- field_name: provision_output
type: string
details: provision output
bind:
template_refs:
main: fake-uuid-bind.tf
outputs:
- field_name: bind_output
type: string
details: bind output
18 changes: 18 additions & 0 deletions integrationtest/fixtures/golden-path/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
packversion: 1
name: fake-brokerpak
version: 0.1.0
metadata:
author: [email protected]
platforms:
- os: linux
arch: amd64
- os: darwin
arch: amd64
terraform_binaries:
- name: terraform
version: 1.5.7
source: https://github.com/hashicorp/terraform/archive/v1.5.7.zip
- name: terraform-provider-random
version: 3.1.0
service_definitions:
- fake-uuid-service.yml
51 changes: 51 additions & 0 deletions integrationtest/golden_path_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package integrationtest_test

import (
"encoding/json"

"github.com/cloudfoundry/cloud-service-broker/integrationtest/packer"
"github.com/cloudfoundry/cloud-service-broker/internal/testdrive"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var _ = Describe("Golden Path", func() {
const (
serviceOfferingGUID = "f18d50e2-cbf0-11ee-a64b-f7a425623295"
servicePlanGUID = "fd01df6a-cbf0-11ee-ac5b-fba53664a953"
)

var (
brokerpak string
broker *testdrive.Broker
)

BeforeEach(func() {
brokerpak = must(packer.BuildBrokerpak(csb, fixtures("golden-path")))
broker = must(testdrive.StartBroker(csb, brokerpak, database))

DeferCleanup(func() {
Expect(broker.Stop()).To(Succeed())
cleanup(brokerpak)
})
})

It("can create and delete a service instance and a binding", func() {
instance := must(broker.Provision(serviceOfferingGUID, servicePlanGUID))

binding := must(broker.CreateBinding(instance))
var receiver struct {
Credentials struct {
BindOutput string `json:"bind_output"`
ProvisionOutput string `json:"provision_output"`
} `json:"credentials"`
}
Expect(json.Unmarshal([]byte(binding.Body), &receiver)).To(Succeed())
Expect(receiver.Credentials.ProvisionOutput).To(MatchRegexp(`^[-0-9a-f]{36}$`))
Expect(receiver.Credentials.BindOutput).To(MatchRegexp(`^[-0-9a-f]{36}$`))

Expect(broker.DeleteBinding(instance, binding.GUID)).To(Succeed())
Expect(broker.Deprovision(instance)).To(Succeed())
})
})
Loading