Commit Graph
48 Commits
Author SHA1 Message Date
rosstimothy 6590c944b6 Inject modules into keygen (#62843)
Contributes to #62799.
2026-01-16 18:52:50 +00:00
Gavin Frazar 47fa5142f9 fix aws e2e test (#62528)
* Fix data race in e2e AWS tests

* replace pgx.Conn with pgxpool.Pool, which is safe for concurrent usage
* remove redundant mutex

* Format retry wait duration as a readable string

* Update healthcheck logger component

To disambiguate from normal user connections, the health checker will
use a new logger component: "db:health".

* Skip granting teleport-auto-user to Redshift admin

This is not necessary for Redshift and the syntax is not correct either,
because Redshift grants must use "GRANT ROLE" instead of "GRANT".
This removes a superfluous log message about bad grant syntax.

* Run proxy and local proxy tests sequentially

This potentially fixes test flakiness.
The Redshift deactivation and deletion SQL scripts both check
stv_sessions for active user connections, which can cause failures when
a parallel test is still running.

* Log on test cleanup failure
2025-12-31 05:20:03 +00:00
STeve (Xin) Huang 90039a7bea Fix "invalid name syntax" connection error for PostgreSQL auto-provisioned users with email usernames (#61487)
* use email address in some e2e tests, this should fail e2e without the coming fix

* to_regrole(QUOTE_IDENT(username))
2025-11-20 18:55:32 +00:00
Yassine Bounekhla b6095c95c5 bump playwright to 1.55.1 (#60501) 2025-10-23 13:53:22 +00:00
Tiago Silva 1dbed0ad03 Revert "Skip AWS E2E tests to unblock merges (#59949)" (#59976)
This reverts commit e1492739e2.
2025-10-07 09:54:34 +00:00
Tiago Silva e1492739e2 Skip AWS E2E tests to unblock merges (#59949)
Our weekly destroy&reconstruct AWS infrastructure script is broken and
we are unable to run AWS E2E tests for the time being.

This PR temporarily skips running AWS E2E tests in our CI.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2025-10-06 10:39:34 +00:00
Tiago Silva 64ae08da62 Refactor test assertions to use consistent variable naming in require.EventuallyWithT calls (#58997)
* Refactor test assertions to use consistent variable naming in `require.EventuallyWithT` calls

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>

* handle code review comment

* handle code review comment

---------

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2025-09-15 15:19:53 +00:00
Zac Bergquist a6e54a5f3a Prefer net.JoinHostPort over fmt.Sprintf (#56967)
net.JoinHostPart is the more specific tool, and handles things
like IPv6 addresses.
2025-07-23 14:59:41 +00:00
rosstimothy 7541d6d7d0 Introduce logtest package (#56741)
Moves all test related logger initialization and creation to the
logtest package to reduce testing symbols in production code. The
existing helpers in lib/utils have been left in place until the
enterprise references can be converted.

Updates #51023.
2025-07-15 18:11:10 +00:00
Zac Bergquist 22eb8c6645 Modernize tool/, examples/, and e2e/ (#55881) 2025-06-19 01:38:35 +00:00
Yassine Bounekhla a4b98b401a fix import order (#55234) 2025-05-29 14:44:08 +00:00
Guillaume J. Charmes 2c73757c8b Pass k8s api group around. (#54760)
* Pass the api group around. Set the default value as wildcard. No behavior/logic change.

* Revert presets back to v7 to pass the merge queue tests.
2025-05-22 23:38:27 +00:00
Yassine Bounekhla 503af6b1fe use testify package for assert (#55039) 2025-05-22 14:12:35 +00:00
Yassine Bounekhla 999533b4b7 implement e2e testing for the webui (#54094) 2025-05-16 18:57:02 +00:00
Noah StrideandMarco Dinis 0586278cde Migrate GetClusterName to gRPC (#53164)
* Adjust GetClusterName method signature to include context.Context

* Start hacking on gRPC GetClusterName impl

* Fix test mocks to match signature

* Fix integration tests

* Fix integrations tests

* Missing ctx

* New GetClusterName RPC implementatin

* Add fallback cluster name

* Correct godoc comment

* Remove unused method

* Remove unused import

* Fix E2E test

* Fix tests

* Fix deferred context cancel in test conflicting with parallel subtests

* Fix import

* Fix imports

* Update lib/auth/auth_with_roles.go

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>

---------

Co-authored-by: Marco Dinis <marco.dinis@goteleport.com>
2025-03-20 10:07:02 +00:00
rosstimothy 48d685ebf4 Fix test flakes related to Kubernetes user cert generation (#52442)
#52109 added a dependency on the unified resource cache to user
cert generation to reduce resource consumption. A number of tests
that exercise generating Kubernetes user certs were either not
waiting for the Kubernetes resources to exist prior to authentication
and getting lucky, or checking that the resources were in the auth
cache, but not the unified resource cache.

This attempts to cover any tests which generate Kubernetes user
certificates to verify that the unified resource cache contains
the expected cluster before proceeding.

Fixes #52157.
Fixes #52441.
2025-02-26 18:51:10 +00:00
Gavin Frazar f4e3a4fddb Wait for fine-grain user permissions to be revoked (#52162)
* use separate users for the RDS postgres super/nonsuper db admin tests
* parallelize the super/nonsuper db admin tests
2025-02-16 02:01:58 +00:00
Gavin Frazar 0bcabee6b4 Fix database user auto-provisioning (#51945)
* Use a custom query to find user db privileges on tables to avoid the
  "grantor" filter condition in the information_schema.tables_privileges
  view. This fixes the cases where the grantor for a privilege is set to
  the table owner rather than the user (teleport) who issued the grant.
  Most notably, this happens when a superuser grants privileges on a
  table they do not own to a user.
* Grant USAGE on schemas that contain tables where we intend to grant
  table privileges. This is necessary to use the table privileges we
  grant.
* Wrap all remaining plpgsql procedure creation/calls with retries.
* Add a db permissions e2e test for RDS
* Expand e2e tests to test with and without a superuser db admin
* Significantly speed up the RDS e2e tests by wrapping EventuallyWithT
  in a helper func that tries the condition func immediately rather than
  waiting for the first tick duration.
2025-02-12 02:51:33 +00:00
rosstimothy 852fc7d605 Remove unused servicecfg.Config.Console field (#50944)
Depends on https://github.com/gravitational/teleport.e/pull/5829
2025-01-13 16:58:27 +00:00
Gavin Frazar c589ae29cc Handle retryable errors in postgres e2e tests (#50605)
This wraps the test pgx.Conn in a helper struct that adds
retries for retryable failures for all calls to Exec.
2025-01-08 18:47:29 +00:00
rosstimothy 2c764e14b5 Reduce reliance on servicecfg.Config logrus logger (#50817)
Converts most items to use servicecfg.Config.Logger instead of
servicecfg.Config.Log. The deprecated logrus logger unfortunately
cannot be removed yet as it's still used in e. Additionally all
logging within the config package was converted to use slog.
2025-01-07 20:09:30 +00:00
Gavin Frazar 579db5e628 add retries for postgres auto user proc creation (#47305)
* add retries for postgres auto user proc creation

* bump the conn timeout up
2024-10-08 17:09:19 +00:00
STeve (Xin) Huang 7b0e857ee1 MySQL fork driver update (#47159)
* MySQL fork driver update

* fix CIs attempt 1

* fix CIs attempt 2

* update go.mod in integrations
2024-10-04 18:20:14 +00:00
Gavin Frazar f2c7ef3f92 re-enable mysql e2e test (#45787) 2024-08-26 20:49:38 +00:00
Tim Buckley 523e0d62ff Temporarily disable the TestDatabases/rds/mysql e2e test (#45684)
This test is failing consistently and blocking other fixes from
merging.

See also: https://github.com/gravitational/teleport/issues/45672
2024-08-22 04:33:24 +00:00
Nic Klaassen 00c9dd4658 rename client.Key to KeyRing and un-embed PrivateKey (#44484)
* rename client.Key to KeyRing and un-embed PrivateKey

As part of RFD 136 we will no longer be using a single private key
associated with all user certificates - each cert will have its own
unique key. This PR makes a preparatory step of renaming client.Key to
KeyRing, and un-embeds keys.PrivateKey so that all current uses are
easier to identify.

* fix terraform testlib
2024-07-22 08:58:04 +00:00
Nic Klaassen b5cb34a307 support separate SSH and TLS keys in generateUserCert (#43894)
* support separate SSH and TLS keys in `generateUserCert`

This PR splits the SSH and TLS public keys passed to
`auth.(*Server).generateUserCert`. The attestation statement associated
with the public key is also split.

Now, `sshPublicKey` will be the subject public key of the returned SSH
certificate, and `tlsPublicKey` will be the subject public key of the
returned TLS certificate. If either is not provided, the corresponding
certificate is not generated or returned.

This does not update any code paths to actually use different keys here,
but prepares for that in the future.

* use public key conversion func

* fix public key format in db tests
2024-07-10 16:50:53 +00:00
Gavin Frazar f2c2e42f19 fix redshift auto user deadlocking (#43335) 2024-07-02 01:04:41 +00:00
Gavin Frazar e0e5f9a17c reenable redshift serverless e2e test (#42602) 2024-06-07 17:07:30 +00:00
Gavin Frazar 03c65e4538 add redshift cluster e2e tests (#41195)
* test redshift cluster iam role and existing db user iam auth
* test redshift cluster auto user provisioning
* add error checking in test cleanup
2024-05-13 23:36:38 +00:00
Brian Joerger 8c328a880b MFA for App Access - tsh proxy app and Teleport Connect (#40857)
* Add key.DBTLSCert and key.AppTLSCert helper methods.

* Add TSH_APP_LOCAL_PROXY user certs requester option.

* Break up app login into multiple methods.

* Generalize cert checker local proxy middleware and add an app cert implementation.

* Use AppCertChecker for tsh proxy app.

* Add test check for proxy mfa certs being kept off disk.

* Apply changes to Teleport Connect.

* Addressed bl-nero's comments.

* Address comments from ravicious.

* Add proxy app cert ttl test.

* Restore v15 fallback for tsh proxy app session creation; Minor naming refactors.

* Add cluster flag to app logout.

* Refactor teleterm test to cleanup session MFA requirement.

* Address comments.
2024-05-06 19:29:53 +00:00
Gavin FrazarandEdoardo Spadolini 5a0347aca6 skip redshift serverless e2e test (#41206)
* skip redshift serverless e2e test

* Update e2e/aws/redshift_test.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2024-05-06 08:19:08 +00:00
Gavin Frazar cfa364f28c add Redshift Serverless e2e tests (#40237)
* add Redshift Serverless e2e tests

* update license year in new files

* use a test cleanup func to close local proxy

* adjust test timeouts

* use a longer conn retry interval
2024-04-29 17:18:55 +00:00
Gavin Frazar 54d2e903d5 add RDS MariaDB e2e tests (#40066)
* add AWS RDS MariaDB e2e tests

* fix spurious teardown error logs

* if a role or user doesn't exist, that is not an error nor is it worth
  logging during auto user teardown.

* check for admin option

* add some extra secret fetching checkings

* only drop redshift user if the user exists
2024-04-08 21:46:17 +00:00
Gavin Frazar 2ec63c886d update AWS RDS db e2e tests (#40065)
* update AWS RDS db e2e tests

* update GHA workflow env vars to be RDS specific
* add auto db user provisioning tests
* provision any db users needed in test code as setup, instead of
  relying on the cloud-terraform repo provisioning them

* fix data race

* rename myDBName to mysqlDBName

* fix flakiness on first run

* remove db_users for auto user roles

* test role assignments in postgres

* reuse rand string util

* test role assignments in mysql

* rearrange subtests to clearly outline dependencies

* verify AWS CA when provisioning

* fix imports
2024-04-02 17:56:31 +00:00
Anton Miniailoandrosstimothy a576cb2a91 Remove assigning by default first alphabetical kube cluster to a user. (#37242)
* Remove assigning by default first alphabetical kube cluster to a user.

* Fix tests.

* Address review comments

* Fix tests.

* Fix error message.

* Use default value.

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

* Fix error message.

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
2024-01-29 22:47:34 +00:00
Mike Jensen 09a33d86d6 Remove account lockout from failed recovery attempts (#35325)
* Remove account lockout from failed recovery attempts

This account lockout looks to be unecessary and potentially problematic.  Recovery codes and recovery through MFA are not possible to brute force.

In addition the potential to lockout an account from being able to use a recovery method could result in them being unable to unlock their account from other potential abuse cases (for example an attacker locking the account from failed password attempts).

As discussed in the RFD (https://github.com/gravitational/teleport/pull/35533) this includes the removal of all the API used for this locking mechanism.

* accountrecovery: Update `WithLock` function names

* accountrecovery: Combine verifyRecoveryCode and verifyRecoveryCodeWithRecord into one function

* Further GRPC cleanup after PR feedback

* Apply PR Feedback
2024-01-24 18:17:52 +00:00
fheinecke b178b8b732 Updated Teleport codebase to AGPL3 license (#35259)
Signed-off-by: Fred Heinecke <fred.heinecke@goteleport.com>
2023-12-01 17:48:14 +00:00
Anton MiniailoandNic Klaassen a4be12fbcf Reorganize service config test fields (#34208)
* Reorganize process config test fields

* Move PollingPeriod back from Testing field

* Fix comment text

Co-authored-by: Nic Klaassen <nic@goteleport.com>

---------

Co-authored-by: Nic Klaassen <nic@goteleport.com>
2023-11-16 05:29:07 +00:00
rosstimothy d5a796c056 Enable testify lint (#34222)
Updates our golangci-lint configuration to enable testifylint and
fixes all issues found.

Bump e ref to include gravitational/teleport.e#2567
2023-11-06 20:38:38 +00:00
Marco André Dinis 44209ce8dc DiscoveryMatchers: move checkandset to types package (#32857)
* DiscoveryMatchers: move checkandset to types package

* add opensearch to iamrole as users
2023-10-04 13:48:09 +00:00
Zac Bergquist c3e6173651 Remove use of require assertions inside Eventually calls (#31112)
* Remove use of require assertions inside Eventually calls

require.Eventually runs the predicate function in a background
goroutine. It is invalid to use require to make assertions
inside the eventually, because require will fail the test if the
assertion fails, and tests can only be failed from the test's
main goroutine.

* Use EventuallyWithT
2023-08-30 16:54:53 +00:00
Edoardo SpadoliniandZac Bergquist bc4cb48518 Fix undefined name in test-only package (#31109)
* Fix undefined variable in test-only package

* Update e2e/aws/doc.go

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>

---------

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2023-08-28 21:59:01 +00:00
Gavin Frazar 8a31113413 add mysql test (#30385) 2023-08-16 23:22:05 +00:00
Gavin Frazar 2cb26477f2 Add RDS Postgres end-to-end tests (#29755)
* test RDS database discovery
* test RDS postgres instance connection
* organize some common test helpers for eks/rds e2e tests
* exclude e2e tests from flaky test base step
* exclude e2e tests in other test flows
* skip e2e db tests by default via env var check
* add postgres web conn test
2023-08-16 22:37:20 +00:00
Jakub Nyckowski e1e0b79096 Add Playwright E2E tests boilerplates (#29286)
* Add end-to-end tests with Playwright

This commit introduces end-to-end tests with Docker Compose to improve code quality and provide a more robust testing environment. This involves adding a GitHub workflow for manually triggering the test suite, Makefile commands for running, the tests, and configurations. This addition will enable easier testing and provide a platform for future test development.

* Cleanup

* Only allow manual CI trigger

* Ignore e2e tests in Jest configuration

Added 'testPathIgnorePatterns' field to the Jest configuration in order to ignore end-to-end tests when running unit tests.

* Address code review comments

* Update e2e test environment for multi-architecture support

Modified the end-to-end test setup scripts and docker files to support both Linux and MacOS architectures. The build process now detects the system architecture and downloads the appropriate version of `mkcert`. Also, there is a control flow to build binaries only if they don't exist and the build files are now mounted from the build directory instead of being copied. These changes aim to make the e2e tests more robust and adaptable to different development environments.

* Update Makefile and teleport.yaml for testing improvements

Continued refinement of testing process by updating the Makefile and teleport.yaml. Changes to the Makefile include additional phony targets, modification of build-binaries, and a new 'all' target which runs key steps in sequence. The teleport.yaml file was updated to version v3.

* Fix makefile on MacOS

* Add Readme
2023-08-07 23:59:22 +00:00
Tiago Silva 6fb9f08108 Fix AWS EKS E2E tests (#29869)
After merging #28845, the cluster name is different and the test failed.
Since the AWS E2E tests are not required, the merge happened and broke
all tests.

Signed-off-by: Tiago Silva <tiago.silva@goteleport.com>
2023-08-01 17:59:16 +00:00
Tiago Silva 5840ae7169 Add AWS EKS End-To-End tests (#29109)
This PR enables AWS E2E integration tests for EKS auto-discovery.

This process uses Github's OIDC connector to access AWS API by assuming the `arn:aws:iam::307493967395:role/tf-aws-e2e-gha-role` role.

```yaml
      - name: Configure AWS Credentials
        uses: aws-actions/configure-aws-credentials@v2
        with:
          aws-region: ${{ env.AWS_REGION }}
          role-to-assume: ${{ env.GHA_ASSUME_ROLE }}
```

`aws-actions/configure-aws-credentials` action generates a new ID token with the information required and signs it using Github's OIDC workflow.

The role `arn:aws:iam::307493967395:role/tf-aws-e2e-gha-role` is an intermediate role for the runner to be able to assume two distinct roles:

-  `arn:aws:iam::307493967395:role/tf-eks-discovery-ci-cluster-kubernetes-service-access-role` - used by Kubernetes Service
-  `arn:aws:iam::307493967395:role/tf-eks-discovery-ci-cluster-discovery-service-access-role` - used by Discovery Service

The Discovery service will assume role  `arn:aws:iam::307493967395:role/tf-eks-discovery-ci-cluster-discovery-service-access-role` which defines the following policy:

- `eks:ListClusters`
- `eks:DescribeCluster`

These are the minimal permissions required to list the available clusters and retrieve their state and labels.

Teleport Discovery Service will pull the EKS cluster available and for each cluster to import, it will create a `kube_cluster` object in Auth Server.

Once the cluster is discovered and the `kube_cluster` exists in Auth server, the Teleport Kubernetes Service will start proxying the cluster.

For that, it must pull the cluster API endpoint and its CA data to create a client.  Role `arn:aws:iam::307493967395:role/tf-eks-discovery-ci-cluster-kubernetes-service-access-role` allows Kubernetes Service to describe the cluster and retrieve its details.

- `eks:DescribeCluster`

The IAM role used by the Kubernetes Service must be mapped to a Kubernetes Group that allows impersonation in order to be able to proxy requests with the user's permissions.

```yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: teleport-role
rules:
- apiGroups:
  - ""
  resources:
  - users
  - groups
  - serviceaccounts
  verbs:
  - impersonate
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - get
- apiGroups:
  - "authorization.k8s.io"
  resources:
  - selfsubjectaccessreviews
  - selfsubjectrulesreviews
  verbs:
  - create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: teleport-crb
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: teleport-role
subjects:
- kind: Group
  name: ${group_name}

```

During the cluster provisioning phase, we mapped the Kubernetes Service IAM role into a Kubernetes Group ` ${group_name}`.

```yaml

mapRoles:
- groups:
  - ${group_name}
  rolearn:arn:aws:iam::307493967395:role/tf-eks-discovery-ci-cluster-kubernetes-service-access-role
  username: "eleport:{{SessionName}}
```

The final step is to validate the client is working correctly and that the Kubernetes Service was able to generate a valid token that can impersonate Kubernetes groups and users.

For that, we simulate a user calling `kubectl get services -n default` through Teleport that must return 1 entry, the default service `kubernetes`.

Implements #27156
2023-07-19 08:19:05 +00:00