Skip to content

Commit

Permalink
deps(bindplane): Update to v1.55.0 (#85)
Browse files Browse the repository at this point in the history
* bump to 1.55

* fix test-end-to-end docker compose

* fit integration tests

* replace 1.37 with 1.55

* fix local tests by creating first config

* fix account init password in curl command

---------

Co-authored-by: Joe Sirianni <joe.sirianni@observiq.com>
  • Loading branch information
dpaasman00 and jsirianni authored May 10, 2024
1 parent 15eb4d8 commit 1220050
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 74 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ jobs:
bindplane_version:
- "latest"
- "module" # Use the current Go module version
- "v1.55.0"
- "v1.53.0"
- "v1.52.0"
- "v1.51.0"
- "v1.50.0"
- "v1.49.0"
- "v1.48.0"
- "v1.44.0"
- "v1.37.0" # Extension support added in v1.37.0
steps:
- name: Check out source code
uses: actions/checkout@v4
Expand Down Expand Up @@ -306,7 +306,6 @@ jobs:
- BINDPLANE_PASSWORD=password
- BINDPLANE_REMOTE_URL=http://localhost:3001
- BINDPLANE_SESSION_SECRET=2c23c9d3-850f-4062-a5c8-3f9b814ae144
- BINDPLANE_SECRET_KEY=8a5353f7-bbf4-4eea-846d-a6d54296b781
- BINDPLANE_LOG_OUTPUT=stdout
- BINDPLANE_ACCEPT_EULA=true
- BINDPLANE_TRANSFORM_AGENT_ENABLE_REMOTE=true
Expand All @@ -322,6 +321,18 @@ jobs:
BINDPLANE_LICENSE: ${{ secrets.BINDPLANE_LICENSE }}
VERSION: ${{ matrix.bindplane_version }}

- name: Init BindPlane Account
uses: nick-fields/retry@v2
with:
timeout_minutes: 1
polling_interval_seconds: 2
max_attempts: 3
shell: bash
command: |
curl \
-u admin:password http://localhost:3001/v1/accounts \
-X POST -d '{"displayName": "init"}' -v
- name: Get docker compose config (debug)
if: always()
run: cat docker-compose.yml | grep -v BINDPLANE_LICENSE
Expand Down
139 changes: 95 additions & 44 deletions client/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ package client

import (
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"os"
"path"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -96,6 +102,77 @@ func bindplaneContainer(t *testing.T, env map[string]string) testcontainers.Cont
return container
}

func bindplaneInit(endpoint url.URL, username, password string) error {
client := &http.Client{}

switch endpoint.Scheme {
case "http":
case "https":
clientCert, err := tls.LoadX509KeyPair("tls/test-client.crt", "tls/test-client.key")
if err != nil {
return fmt.Errorf("failed to load client cert: %w", err)
}
client.Transport = &http.Transport{
TLSClientConfig: &tls.Config{
Certificates: []tls.Certificate{clientCert},
InsecureSkipVerify: true,
},
}
default:
return fmt.Errorf("unsupported scheme: %s", endpoint.Scheme)
}

endpoint.Path = "/v1/accounts"

data := strings.NewReader(`{"displayName": "init"}`)

req, err := http.NewRequest("POST", endpoint.String(), data)
if err != nil {
return err
}
req.Header.Set("Content-Type", "application/json")
req.SetBasicAuth(username, password)
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("failed to make request: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusCreated {
return fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}

type AccountResp struct {
Account struct {
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Metadata struct {
ID string `json:"id"`
Name string `json:"name"`
DisplayName string `json:"displayName"`
Labels struct {
} `json:"labels"`
Hash string `json:"hash"`
Version int `json:"version"`
DateModified time.Time `json:"dateModified"`
} `json:"metadata"`
Spec struct {
SecretKey string `json:"secretKey"`
AlternateSecretKeys interface{} `json:"alternateSecretKeys"`
} `json:"spec"`
Status struct {
} `json:"status"`
} `json:"account"`
}

body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}

var account AccountResp
return json.Unmarshal(body, &account)
}

func TestIntegration_http_config(t *testing.T) {
license := os.Getenv("BINDPLANE_LICENSE")
if license == "" {
Expand All @@ -106,7 +183,6 @@ func TestIntegration_http_config(t *testing.T) {
"BINDPLANE_USERNAME": username,
"BINDPLANE_PASSWORD": password,
"BINDPLANE_SESSION_SECRET": "524abde2-d9f8-485c-b426-bac229686d13",
"BINDPLANE_SECRET_KEY": "ED9B4232-C127-4580-9B86-62CEC420E7BB",
"BINDPLANE_LOGGING_OUTPUT": "stdout",
"BINDPLANE_ACCEPT_EULA": "true",
"BINDPLANE_LICENSE": license,
Expand All @@ -124,10 +200,12 @@ func TestIntegration_http_config(t *testing.T) {
require.NoError(t, err)

endpoint := url.URL{
Host: fmt.Sprintf("%s:%d", hostname, bindplaneExtPort),
Host: net.JoinHostPort(hostname, fmt.Sprintf("%d", bindplaneExtPort)),
Scheme: "http",
}

require.NoError(t, bindplaneInit(endpoint, username, password), "failed to initialize bindplane")

i, err := newTestConfig(
endpoint.String(),
username,
Expand Down Expand Up @@ -291,7 +369,6 @@ func TestIntegration_invalidProtocol(t *testing.T) {
"BINDPLANE_USERNAME": username,
"BINDPLANE_PASSWORD": password,
"BINDPLANE_SESSION_SECRET": "524abde2-d9f8-485c-b426-bac229686d13",
"BINDPLANE_SECRET_KEY": "ED9B4232-C127-4580-9B86-62CEC420E7BB",
"BINDPLANE_LOGGING_OUTPUT": "stdout",
"BINDPLANE_ACCEPT_EULA": "true",
"BINDPLANE_LICENSE": license,
Expand All @@ -310,6 +387,11 @@ func TestIntegration_invalidProtocol(t *testing.T) {
Scheme: "https",
}

// Fix up the Scheme because this test purposefully uses the wrong scheme
u := endpoint
u.Scheme = "http"
require.NoError(t, bindplaneInit(u, username, password), "failed to initialize bindplane")

i, err := newTestConfig(
endpoint.String(),
username,
Expand All @@ -334,7 +416,6 @@ func TestIntegration_https(t *testing.T) {
"BINDPLANE_TLS_CERT": "/tmp/bindplane.crt",
"BINDPLANE_TLS_KEY": "/tmp/bindplane.key",
"BINDPLANE_SESSION_SECRET": "524abde2-d9f8-485c-b426-bac229686d13",
"BINDPLANE_SECRET_KEY": "ED9B4232-C127-4580-9B86-62CEC420E7BB",
"BINDPLANE_LOGGING_OUTPUT": "stdout",
"BINDPLANE_ACCEPT_EULA": "true",
"BINDPLANE_LICENSE": license,
Expand All @@ -353,6 +434,8 @@ func TestIntegration_https(t *testing.T) {
Scheme: "https",
}

require.NoError(t, bindplaneInit(endpoint, username, password), "failed to initialize bindplane")

i, err := newTestConfig(
endpoint.String(),
username,
Expand All @@ -368,56 +451,22 @@ func TestIntegration_https(t *testing.T) {
require.NoError(t, err)
}

// func TestIntegration_mtls_fail(t *testing.T) {
// env := map[string]string{
// "BINDPLANE_USERNAME": username,
// "BINDPLANE_PASSWORD": password,
// "BINDPLANE_TLS_CERT": "/tmp/bindplane.crt",
// "BINDPLANE_TLS_KEY": "/tmp/bindplane.key",
// "BINDPLANE_TLS_CA": "/tmp/bindplane-ca.crt",
// "BINDPLANE_SESSION_SECRET": "524abde2-d9f8-485c-b426-bac229686d13",
// "BINDPLANE_SECRET_KEY": "ED9B4232-C127-4580-9B86-62CEC420E7BB",
// "BINDPLANE_LOGGING_OUTPUT": "stdout",
// "BINDPLANE_ACCEPT_EULA": "true",
// }

// container := bindplaneContainer(t, env)
// defer func() {
// require.NoError(t, container.Terminate(context.Background()))
// time.Sleep(time.Second * 1)
// }()
// hostname, err := container.Host(context.Background())
// require.NoError(t, err)

// endpoint := url.URL{
// Host: fmt.Sprintf("%s:%d", hostname, bindplaneExtPort),
// Scheme: "https",
// }

// i, err := New(
// WithEndpoint(endpoint.String()),
// WithUsername(username),
// WithPassword(password),
// WithTLSTrustedCA("tls/bindplane-ca.crt"),
// )
// require.NoError(t, err)

// _, err = i.Client.Version(context.Background())
// require.Error(t, err, "expect an error when client not in mtls mode")
// require.Contains(t, err.Error(), "remote error: tls: bad certificate")
// }

func TestIntegration_mtls(t *testing.T) {
license := os.Getenv("BINDPLANE_LICENSE")
if license == "" {
t.Fatal("BINDPLANE_LICENSE must be set in the environment")
}

env := map[string]string{
"BINDPLANE_USERNAME": username,
"BINDPLANE_PASSWORD": password,
"BINDPLANE_TLS_CERT": "/tmp/bindplane.crt",
"BINDPLANE_TLS_KEY": "/tmp/bindplane.key",
"BINDPLANE_TLS_CA": "/tmp/bindplane-ca.crt",
"BINDPLANE_SESSION_SECRET": "524abde2-d9f8-485c-b426-bac229686d13",
"BINDPLANE_SECRET_KEY": "ED9B4232-C127-4580-9B86-62CEC420E7BB",
"BINDPLANE_LOGGING_OUTPUT": "stdout",
"BINDPLANE_ACCEPT_EULA": "true",
"BINDPLANE_LICENSE": license,
}

container := bindplaneContainer(t, env)
Expand All @@ -433,6 +482,8 @@ func TestIntegration_mtls(t *testing.T) {
Scheme: "https",
}

require.NoError(t, bindplaneInit(endpoint, username, password), "failed to initialize bindplane")

i, err := newTestConfig(
endpoint.String(),
username,
Expand Down
31 changes: 22 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
module github.com/observiq/terraform-provider-bindplane

go 1.21
go 1.21.8

toolchain go1.21.1
toolchain go1.22.2

require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0
github.com/observiq/bindplane-op-enterprise v1.54.0
github.com/observiq/bindplane-op-enterprise v1.55.0
github.com/stretchr/testify v1.9.0
github.com/testcontainers/testcontainers-go v0.30.0
go.uber.org/zap v1.27.0
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute v1.24.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/auth v0.2.2 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/pubsub v1.37.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/99designs/gqlgen v0.17.45 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20220621081337-cb9428e4ac1e // indirect
github.com/IBM/sarama v1.43.1 // indirect
Expand All @@ -28,11 +30,13 @@ require (
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/agnivade/levenshtein v1.1.1 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/asaskevich/EventBus v0.0.0-20200907212545-49d423059eef // indirect
github.com/auth0/go-jwt-middleware/v2 v2.2.1 // indirect
github.com/bytedance/sonic v1.11.2 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/containerd/containerd v1.7.12 // indirect
Expand Down Expand Up @@ -73,6 +77,7 @@ require (
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
Expand Down Expand Up @@ -127,6 +132,8 @@ require (
github.com/oklog/run v1.0.0 // indirect
github.com/oklog/ulid/v2 v2.1.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/golden v0.98.0 // indirect
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.98.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
Expand All @@ -139,10 +146,13 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/segmentio/analytics-go/v3 v3.3.0 // indirect
github.com/segmentio/backo-go v1.0.0 // indirect
github.com/sendgrid/rest v2.6.9+incompatible // indirect
github.com/sendgrid/sendgrid-go v3.14.0+incompatible // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sosodev/duration v1.2.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -154,12 +164,14 @@ require (
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/vektah/gqlparser/v2 v2.5.11 // indirect
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xplorfin/gql-bigint v0.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/zclconf/go-cty v1.14.0 // indirect
go.opencensus.io v0.24.0 // indirect
Expand All @@ -176,22 +188,23 @@ require (
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/oauth2 v0.19.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/api v0.172.0 // indirect
google.golang.org/api v0.175.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.29.2 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
Expand Down
Loading

0 comments on commit 1220050

Please sign in to comment.