Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Update teleport in tests to 14.0.3 and fix tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marcoandredinis committed Oct 12, 2023
1 parent f36cc91 commit b3335bd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1081,6 +1081,6 @@ steps:
from_secret: PRODUCTION_TERRAFORM_REGISTRY_SIGNING_KEY
---
kind: signature
hmac: 7329d41f2acd4c65f990204ced4435154add3fed15634bc7bcab06791dec41a1
hmac: 63e4d9ad2fc74400265609424f058f2ccbd18c52d60c5e884ba07181c3cdd637

...
2 changes: 1 addition & 1 deletion .github/workflows/terraform-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 7 additions & 10 deletions event-handler/fake_fluentd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
}

Expand Down
1 change: 1 addition & 0 deletions terraform/test/access_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down
4 changes: 3 additions & 1 deletion terraform/test/fixtures/access_list_0_create.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ resource "teleport_access_list" "test" {
}
title = "Hello"
audit = {
frequency = "3600h"
recurrence = {
frequency = 6
}
}
}
}

0 comments on commit b3335bd

Please sign in to comment.