From b3335bdb9ee7921b579689a965f852524635191d Mon Sep 17 00:00:00 2001 From: Marco Dinis Date: Thu, 12 Oct 2023 16:13:17 +0100 Subject: [PATCH] Update teleport in tests to 14.0.3 and fix tests add test for access list audit recurrence frequency improve fluentfake used in tests It was using the content length of the http request and it included some extra chars "\x0". We are now using the `io.ReadAll` from the Body instead of pre-creating the array. --- .drone.yml | 4 ++-- .github/workflows/terraform-tests.yaml | 2 +- .github/workflows/unit-tests.yaml | 2 +- event-handler/fake_fluentd_test.go | 17 +++++++---------- terraform/test/access_list_test.go | 1 + terraform/test/fixtures/access_list_0_create.tf | 4 +++- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.drone.yml b/.drone.yml index e2664e940..2b9719d63 100644 --- a/.drone.yml +++ b/.drone.yml @@ -30,7 +30,7 @@ steps: TELEPORT_ENTERPRISE_LICENSE: from_secret: TELEPORT_ENTERPRISE_LICENSE TERRAFORM_VERSION: 1.5.6-1 - TELEPORT_VERSION: 14.0.0 + TELEPORT_VERSION: 14.0.3 commands: - echo Testing plugins against Teleport $TELEPORT_VERSION - apt update && apt install -y gnupg software-properties-common @@ -1081,6 +1081,6 @@ steps: from_secret: PRODUCTION_TERRAFORM_REGISTRY_SIGNING_KEY --- kind: signature -hmac: 7329d41f2acd4c65f990204ced4435154add3fed15634bc7bcab06791dec41a1 +hmac: 63e4d9ad2fc74400265609424f058f2ccbd18c52d60c5e884ba07181c3cdd637 ... diff --git a/.github/workflows/terraform-tests.yaml b/.github/workflows/terraform-tests.yaml index 92cae4bba..10d2d5cdc 100644 --- a/.github/workflows/terraform-tests.yaml +++ b/.github/workflows/terraform-tests.yaml @@ -36,7 +36,7 @@ jobs: - name: Install Teleport uses: teleport-actions/setup@v1 with: - version: 14.0.0 + version: 14.0.3 enterprise: true - name: make test-terraform diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 824662991..53f16f10b 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -30,7 +30,7 @@ jobs: - name: Install Teleport uses: teleport-actions/setup@v1 with: - version: 14.0.0 + version: 14.0.3 enterprise: true - name: Run unit tests diff --git a/event-handler/fake_fluentd_test.go b/event-handler/fake_fluentd_test.go index 67b99ca75..1713a7252 100644 --- a/event-handler/fake_fluentd_test.go +++ b/event-handler/fake_fluentd_test.go @@ -21,11 +21,11 @@ import ( "crypto/tls" "crypto/x509" "fmt" + "io" "net/http" "net/http/httptest" "os" "path" - "strings" "time" "github.com/gravitational/teleport/integrations/lib/logger" @@ -153,17 +153,14 @@ func (f *FakeFluentd) GetURL() string { // Respond is the response function func (f *FakeFluentd) Respond(w http.ResponseWriter, r *http.Request) { - var req = make([]byte, r.ContentLength) - - _, err := r.Body.Read(req) - // We omit err here because it always returns weird EOF. - // It has something to do with httptest, known bug. - // TODO: find out and resolve. - if !trace.IsEOF(err) { - logger.Standard().WithError(err).Error("FakeFluentd Respond() failed") + req, err := io.ReadAll(r.Body) + if err != nil { + logger.Standard().WithError(err).Error("FakeFluentd Respond() failed to read body") + fmt.Fprintln(w, "NOK") + return } - f.chMessages <- strings.TrimSpace(string(req)) + f.chMessages <- string(req) fmt.Fprintln(w, "OK") } diff --git a/terraform/test/access_list_test.go b/terraform/test/access_list_test.go index fa8861aa5..2e6071a67 100644 --- a/terraform/test/access_list_test.go +++ b/terraform/test/access_list_test.go @@ -48,6 +48,7 @@ func (s *TerraformSuite) TestAccessList() { resource.TestCheckResourceAttr(name, "spec.owners.0.name", "gru"), resource.TestCheckResourceAttr(name, "spec.membership_requires.roles.0", "minion"), resource.TestCheckResourceAttr(name, "spec.grants.roles.0", "crane-operator"), + resource.TestCheckResourceAttr(name, "spec.audit.recurrence.frequency", "6"), ), }, { diff --git a/terraform/test/fixtures/access_list_0_create.tf b/terraform/test/fixtures/access_list_0_create.tf index 53b3fe9fa..75a80ca33 100644 --- a/terraform/test/fixtures/access_list_0_create.tf +++ b/terraform/test/fixtures/access_list_0_create.tf @@ -26,7 +26,9 @@ resource "teleport_access_list" "test" { } title = "Hello" audit = { - frequency = "3600h" + recurrence = { + frequency = 6 + } } } }